- Nix 95.5%
- Shell 2.3%
- Lua 2.1%
| home | ||
| hosts | ||
| modules/darwin | ||
| packages | ||
| scripts | ||
| .gitignore | ||
| .sops.yaml | ||
| AGENTS.md | ||
| commitlint.config.js | ||
| flake.lock | ||
| flake.nix | ||
| lefthook.yml | ||
| README.md | ||
| secrets.yaml | ||
Nix Configuration
Unified NixOS and macOS (nix-darwin) configuration for personal systems.
Prerequisites
- Nix with flakes and commands enabled
- Git
macOS Setup (nix-darwin)
-
Install Xcode command line tools (if not already installed):
xcode-select --install # If already installed, you may see: "command line tools are already installed" -
Install Nix:
curl -L https://install.determinate.systems/nix | sh -s -- install --prefer-upstream-nix -
Restart shell or source profile:
source /nix/var/nix/profiles/*/etc/profile.d/nix-daemon.sh -
Generate SSH key and add to Forgejo:
ssh-keygen -t ed25519 -C "s4mxdhid@zurimail.org" # Add pub key to http://minerva.lan:8080/user/settings/keys -
Clone the config:
git clone ssh://forgejo@minerva.lan/s4mxdhid/nixos-config.git cd nixos-config -
Bootstrap nix-darwin:
sudo --set-home nix run nix-darwin/master#darwin-rebuild -- switch --flake .#<hostname>
Change hostname:
sudo scutil --set HostName <new_name>
sudo scutil --set LocalHostName <new_name>
sudo scutil --set ComputerName <new_name>
After bootstrapping, darwin-rebuild will be available in your PATH:
sudo darwin-rebuild switch --flake .#$(scutil --get LocalHostName)
Structure
nix-config/
├── flake.nix # Root flake - exports all host configurations
├── modules/ # Shared modules
│ └── darwin/ # Shared macOS configuration
│ ├── default.nix # Main shared config
│ └── netbird.nix # NetBird service
├── hosts/ # Host-specific configurations
│ ├── ares/ # MacBook Air M2 (macOS)
│ ├── vulcan/ # Mac Mini M4 (macOS)
│ ├── mars/ # MacBook Air M2 (omarchy)
│ └── minerva/ # AOOSTAR server (NixOS)
├── home/ # Shared Home Manager configuration
│ ├── home.nix # Main HM config with cross-platform imports
│ └── programs/ # Program-specific HM modules
└── programs/ # (legacy home modules directory)
Hosts
| Host | OS | Description |
|---|---|---|
ares |
macOS | MacBook Air M2 - laptop |
vulcan |
macOS | Mac Mini M4 - desktop |
mars |
omarchy | MacBook Air M2 (TODO) |
minerva |
NixOS | AOOSTAR N1 Pro |
Building
macOS (ares/vulcan)
sudo darwin-rebuild switch --flake .#$(scutil --get LocalHostName)
NixOS (minerva)
sudo nixos-rebuild switch --flake .#$(hostname)
Update flake inputs
nix flake update
Garbage collection
# macOS & NixOS
sudo nix-collect-garbage --delete-older-than 7d
Shared Configuration
Home Manager
Home Manager manages user-level packages and configurations for all hosts:
- Cross-platform: git, zsh, starship, mise, atuin, fzf, zoxide, yazi, zellij, btop, bottom, localsend, espanso, jujutsu, delta
- macOS-only: aerospace (disabled), sketchybar (disabled), paneru (window manager with gestures)
Darwin Modules
modules/darwin/ contains shared macOS configuration imported by both ares and vulcan:
- Homebrew packages and casks
- System defaults (Dock, Finder, etc.)
- Window managers (paneru)
- NetBird service
NetBird Setup
NetBird is configured to auto-connect on macOS hosts.
Setup for new machines:
-
Get a setup key from your NetBird admin dashboard
-
Create the setup key file:
echo 'YOUR_NETBIRD_SETUP_KEY' > ~/.netbird_setup_key -
Rebuild the system:
sudo darwin-rebuild switch --flake .#$(scutil --get LocalHostName)
The activation script will automatically connect NetBird using the setup key.
Adding a New Host
macOS
-
Copy an existing host directory:
cp -r hosts/ares hosts/new-host -
Update
hosts/new-host/configuration.nixcomment (line 7) -
Add to
flake.nix:darwinConfigurations."new-host" = nix-darwin.lib.darwinSystem { specialArgs = { inherit inputs; }; modules = [ ./hosts/new-host/configuration.nix # ... other modules ]; }; -
Update README.md with the new host
NixOS
- Create directory:
hosts/new-host/ - Copy
configuration.nixandhardware-configuration.nixfrom existing NixOS host - Update hostname in configuration
- Add to
flake.nixundernixosConfigurations - Update README.md
Clone the Repository (New Machine)
If setting up a new machine to use this config from the local Forgejo instance:
1. Generate an SSH key on the new PC: ssh-keygen -t ed25519 -C "s4mxdhid@zurimail.org"
2. Add the public key to Forgejo at <http://minerva.lan:8080/user/settings/keys>
3. Then clone with: git clone ssh://forgejo@minerva.lan/s4mxdhid/nixos-config.git
Troubleshooting
Build fails with "No space left on device"
sudo nix-collect-garbage --delete-older-than 7d
Cask installation fails (mv: cannot overwrite non-directory)
This error occurs when there's a stale cask directory in the Homebrew cache. The app may have been manually installed or the cache is corrupted.
# Replace 'app-name' with the failing cask (e.g., ungoogled-chromium)
rm -rf /opt/homebrew/Caskroom/app-name
rm -rf /Applications/AppName.app
Then rebuild:
sudo darwin-rebuild switch --flake .#$(scutil --get LocalHostName)
Build fails with stale inputs
nix flake update
Home Manager packages not appearing
Make sure home-manager module is included in the host's flake configuration.
Paneru not starting
Check that ~/.paneru.toml exists:
ls -la ~/.paneru.toml
If missing, rebuild the system to regenerate.
Secrets (sops-nix)
To encrypt secrets with sops:
# Generate age key (one-time setup)
mkdir -p ~/.config/sops/age
age-keygen -o ~/.config/sops/age/keys.txt
age-keygen -Y ~/.config/sops/age/keys.txt # shows public key
# Add public key to .sops.yaml
# keys: - &pubkey AGE_PUBLIC_KEY_HERE
# Encrypt secrets.yaml
sops --encrypt --in-place secrets.yaml
# Edit encrypted file
sops secrets.yaml
The encrypted file can be committed to the repo safely.
Notes
.DS_Storefiles are gitignored- Comments in Nix files are preserved
nixfmtcan be used to format Nix files:nixfmt ~/.config/nix/*.nix
Permission fix
sudo chown -R root:nixbld /nix
sudo chmod -R 755 /nix/store
sudo chmod -R 1777 /nix/var/nix/temproots
sudo pkill nix-daemon
nix-collect-garbage
nix flake update