Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tulik committed Aug 14, 2024
0 parents commit 1a51580
Show file tree
Hide file tree
Showing 13 changed files with 752 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "CI"
on:
push:
branches:
- main
pull_request:
jobs:
nix:
runs-on: ${{ matrix.system }}
strategy:
matrix:
system: [aarch64-darwin, x86_64-darwin, x86_64-linux]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: nixci
run: nixci --extra-access-tokens "github.com=${{ secrets.GITHUB_TOKEN }}" build --systems "${{ matrix.system }}"
20 changes: 20 additions & 0 deletions .github/workflows/update-flake-lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: update-flake-lock
on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00

jobs:
example-lock:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@main
with:
pr-title: "Update flake.lock"
pr-labels: |
automated
54 changes: 54 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

# Nix-specific
result
result-*
.direnv

# Home Manager
.home-manager-generation

# Editor and OS files
.vscode/
.idea/
*.swp
*~
.DS_Store

# Logs
*.log

# Nix build outputs
result
result-*

# Python-related (for custom Python packages)
__pycache__/
*.py[cod]
*.egg-info/
.installed.cfg
*.egg

# Node.js (for nodejs_22)
node_modules/

# Temporary files
*.tmp
*.temp

# Squid cache and logs (from squid.nix)
.squid/cache/
.squid/logs/

# AdGuard Home data (from adguardhome.nix)
.adguardhome/

# nix-index database
.cache/nix-index

# Any local overrides or user-specific configs
*.local
*.override

# Flake-related
.envrc

96 changes: 96 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# NixOS Darwin Home Manager

- **NixOS:** v2.23.3
- **Home Manager:** v24.05
- **Nixpkgs:** v24.05

Extra addons:
- **Squid proxy** (currently not available on MacOS Silicon - missing binaries)
- **AdGuardHome** (configuration not yet complete)

## Development Environment Manual (devenv and devbox)

This manual outlines the tools and configurations in your Nix-based development environment, focusing on devenv and devbox.

### Core Components

1. **Nixpkgs**: The primary package collection for Nix.
2. **Home Manager**: Manages user-specific configurations.

### Key Development Tools

#### devenv
devenv is not explicitly listed in your configuration, but if you want to use it, you can add it to your setup. devenv provides reproducible development environments.

#### devbox
Devbox is included in your setup. It's a tool for creating isolated, reproducible development environments.

Usage:
```bash
devbox init # Initialize a new project
devbox add # Add a package to your project
devbox shell # Enter the development environment
```

### Other Development Tools

- **ripgrep**: Fast search tool for recursive searching.
- **fd**: User-friendly alternative to `find`.
- **sd**: Intuitive find & replace CLI.
- **tree**: Displays directory contents in a tree-like format.
- **cachix**: Binary cache for Nix.
- **nil**: Nix language server.
- **nix-info**, **nixpkgs-fmt**, **nixci**, **nix-health**: Various Nix utilities.

### Version Control
- **Git**: Configured with user details and aliases.
- **LazyGit**: Terminal UI for Git commands.

### Programming Languages
- **Python**:
- **Poetry**: Dependency management for Python.
- **Node.js**:
- **node2nix**: Converts Node.js packages to Nix expressions.
- **nodejs_22**: Node.js version 22.

### Shell and Scripting
- **Bash** and **Zsh**: Configured shells with custom aliases and PATH modifications.
- **Xonsh**: Python-based shell.
- **any-nix-shell**: Allows using Nix shells with any shell.
- **direnv**: Automatically loads and unloads environment variables.

### Proxy and Networking
- **AdGuard Home**: Network-wide ad blocker.

### Configuration Files
- **home/default.nix**: Primary configuration for Home Manager.

### Usage Instructions

1. Edit `home/default.nix` to customize your Home Manager configuration.
2. Run `nix run` to apply the configuration.
3. Use `devbox` to manage project-specific development environments:
```bash
devbox init # In your project directory
devbox add python nodejs # Add required tools
devbox shell # Enter the environment
```
4. Use `direnv` to automatically load environment variables:
```bash
echo "use devbox" > .envrc
direnv allow
```

### Customization

- Add or modify packages in the `home.packages` section of `home/default.nix`.
- Create project-specific environments using devbox.
- Use direnv to automatically load project environments.

Remember to rebuild your environment after making changes to apply the new configuration:

```bash
just run
```

This setup provides a flexible development environment using devbox for project-specific setups and Home Manager for system-wide configurations. Adjust as needed for your specific development workflows.
122 changes: 122 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts";
nix-index-database = {
url = "github:Mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs@{ self, nixpkgs, flake-parts, home-manager, nix-darwin, nix-index-database, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "aarch64-darwin" "x86_64-darwin" ];

perSystem = { pkgs, system, ... }: {
formatter = pkgs.nixpkgs-fmt;

devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ nixpkgs-fmt just ];
};

packages.default = pkgs.writeShellApplication {
name = "activate";
runtimeInputs = [ inputs.home-manager.packages.${system}.default ];
text = ''
${pkgs.lib.getExe inputs.home-manager.packages.${system}.default} switch --flake .#lukasz@${system}
'';
};
};

flake = {
homeConfigurations."lukasz@aarch64-darwin" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
extraSpecialArgs = { inherit inputs; };
modules = [
./home
nix-index-database.hmModules.nix-index
{
home = {
username = "lukasz";
homeDirectory = "/Users/lukasz";
stateVersion = "24.05";
};
}
];
};

darwinConfigurations."lukasz-macbook-pro-13" = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.lukasz = import ./home;
}
{
security.pam.enableSudoTouchIdAuth = true;
system.stateVersion = 4;
}
];
};
};
};
}
Loading

0 comments on commit 1a51580

Please sign in to comment.