A comprehensive Nix flake configuration supporting both NixOS (Linux) and nix-darwin (macOS) systems with home-manager integration.
This configuration provides a unified way to manage multiple machines across different platforms:
- NixOS hosts:
thegeneralist - Darwin hosts:
thegeneralist-mbp
- Nix package manager with flakes enabled
- Git for cloning the repository
-
Clone the repository:
git clone https://github.com/thegeneralist01/config.git ~/config cd ~/config
-
For NixOS systems:
sudo nixos-rebuild switch --flake .#<hostname> -
For Darwin systems:
darwin-rebuild switch --flake .#<hostname>
Enter the development shell for configuration management:
nix developThis provides:
nil- Nix language servernixpkgs-fmt- Nix formatteragenix- Secret management
├── docs/ # Documentation
├── flake.nix # Main flake configuration
├── flake.lock # Locked dependency versions
├── hosts/ # Host-specific configurations
│ ├── default.nix # Host discovery and categorization
│ └── <hostname>/ # Individual host configurations
├── lib/ # Custom library functions
│ ├── default.nix # Library entry point
│ ├── option.nix # Option utilities
│ └── system.nix # System building functions
├── modules/ # Reusable system modules
│ ├── common/ # Cross-platform modules
│ ├── darwin/ # macOS-specific modules
│ └── linux/ # Linux-specific modules
├── keys.nix # Age public keys for secrets
└── secrets.nix # Encrypted secrets
- nixpkgs: Main package repository (nixos-unstable)
- home-manager: Dotfiles and user environment management
- nix-darwin: macOS system configuration
- agenix: Age-based secret management
- ghostty: Modern terminal emulator
- fenix: Rust toolchain provider
mkSystem: Core system builder for both Linux and DarwinmkOption: Custom option utilities- Host auto-discovery and categorization
-
Create a new directory under
hosts/:mkdir hosts/new-hostname
-
Create the host's
default.nix:lib: inputs: self: lib.mkSystem "linux" ./configuration.nix # or for macOS: lib: inputs: self: lib.mkSystem "darwin" ./configuration.nix
-
Create
configuration.nixwith your host-specific settings:{ config, pkgs, ... }: { # Host-specific configuration here }
-
Rebuild your flake:
nix flake lock # Update lock file if needed nixos-rebuild switch --flake .#new-hostname
Hosts are automatically categorized based on naming conventions:
- Names ending with
mbpor containingcentral-mbp→ Darwin - All others → NixOS
thegeneralist-mbp builds N1ark/AeroSpace at d720311
from source for left/right modifier support. All Option-based bindings use lalt,
leaving right Option available for typing. Other modifiers and commands are unchanged.
Config version 2 explicitly lists persistent workspaces, preserving the workspace
set that version 1 inferred from the bindings.
The build is defined in nixpkgs-overlay/aerospace/:
aerospace-srcinflake.nixandflake.lockpins the complete source revision, including its prerequisite commits.swift-toolchain.nixpins the official Swift 6.4.0 installer and its hash, matching the source's.swift-version.- The source's
Package.resolvedsupplies Swift dependency versions/revisions;dependency-hashes.nixfixes their archive hashes. - The existing nixpkgs lock pins Apple SDK 26.0, the linker, native libraries, documentation/completion tools, and signer.
- Both executables are release builds from the fork. Only compiled icon assets are reused from nixpkgs' pinned official AeroSpace release.
- The app bundle is ad-hoc signed without a developer certificate or host keychain. No manually built artifact or installed Xcode is needed.
Build the package without activating it:
nix --extra-experimental-features pipe-operators build .#aerospace --no-linkApply it through the existing Darwin service:
sudo darwin-rebuild switch --flake .#thegeneralist-mbp \
--option extra-experimental-features pipe-operatorsRestart AeroSpace after updating if the CLI reports a client/server protocol mismatch:
the fork's CLI must be used with its matching app. macOS Accessibility approval
remains an OS-level action; a changed ad-hoc signature may require re-granting it.
Sided shortcuts do not work while Secure Input is enabled, including in password fields.
lalt matches left Option alone, not both Option keys held together.
To update the fork, change the full commit in inputs.aerospace-src.url, then run
nix flake update aerospace-src. Review Package.resolved and .swift-version at
the new revision and update the dependency/toolchain hashes when they change.
The source stays pinned during ordinary nix flake update operations.
Located in modules/common/, these are loaded on all systems:
nix.nix- Nix configuration and binary cacheshome-manager.nix- User environment managementpackages.nix- Common packagesgit.nix,neovim.nix,zsh.nix- Development toolsagenix.nix- Secret management
modules/dotfiles/omp/models.nix declares OMP's model roles, per-agent model
overrides, and saved presets. modules/common/omp.nix applies them during Home
Manager activation, alongside the custom agent definitions and prompts.
The activation replaces modelRoles, task.agentModelOverrides, and
modelPresets in ~/.omp/agent/config.yml. Other settings, including other
task options, are preserved. The file remains writable: changes saved through
OMP work immediately, but the next rebuild restores these three repo-owned
sections. Edit models.nix to make routing changes permanent across rebuilds.
The gemmysolopus, haikugemmyopus, and aura presets retain their different
default/small models, while sharing Gemini Flash Medium for tasks and Opus 5.5
High for planning. Per-agent overrides keep both reviewers on Sol High and
l-worker on Sol independently of the selected preset. Selecting a preset or
changing the active session model remains an OMP action, not a rebuild action.
modules/darwin/- macOS-specific (SSH, Karabiner, packages)modules/linux/- Linux-specific (boot, networking, X11, NVIDIA)
-
Add your module to the appropriate directory:
# modules/common/mymodule.nix { config, pkgs, ... }: { # Module configuration }
-
The module is automatically discovered and loaded
Uses agenix for encrypted secrets management:
- Add recipient public keys to
keys.nix - Define secrets in
secrets.nix - Edit secrets:
agenix -e secret-name.age - Reference in configuration:
config.age.secrets.secret-name.path
thegeneralist performs its own x86_64 builds and serves the personal binary cache.
Configured caches for improved build performance:
cache.thegeneralist01.com- Personal cachecache.garnix.io- Community cachecache.nixos.org- Official cache
nix flake updatenixpkgs-fmt **/*.nixnix flake check# Via nh (configured in home-manager)
nh clean all --keep 3 --keep-since 4d
# Manual cleanup
nix-collect-garbage -dAdd to the appropriate modules/*/packages.nix file.
Modify the home-manager configuration in your host's configuration.nix.
nixos-rebuild switch --flake .#hostname
# or
darwin-rebuild switch --flake .#hostname nixos-rebuild switch --rollback
# or
darwin-rebuild switch --rollback- Check flake lock compatibility:
nix flake update - Clear build cache:
nix-collect-garbage -d - Verify module syntax:
nix flake check
- Verify keys are properly configured in
keys.nix - Re-encrypt secrets:
agenix -r - Check file permissions on age keys
- Verify binary cache access
- Use
nhfor optimized rebuilds
- Follow existing code style and organization
- Test changes on a single host before applying broadly
- Update documentation for significant changes
- Use meaningful commit messages