- Nix 97%
- Shell 3%
| .forgejo/workflows | ||
| configurations | ||
| home | ||
| modules | ||
| pkgs | ||
| secrets | ||
| .envrc | ||
| .gitignore | ||
| .sops.yaml | ||
| config.nix | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
| tylercritchlow.keys | ||
Tyler Critchlow's nix-darwin and nixos System Flake
A single Nix flake that configures all my machines — macOS (via nix-darwin) and NixOS — with home-manager handling my user environment on both.
Hosts
| Host | System | Builder | Flake attribute |
|---|---|---|---|
darwin |
aarch64-darwin |
nix-darwin | darwinConfigurations.darwin |
desktop |
x86_64-linux |
NixOS | nixosConfigurations.desktop |
Layout
flake.nix Inputs + flake-parts entrypoint. Auto-imports every
module in modules/flake/. Hosts and modules are
autowired — no flake.nix edit needed to add one.
config.nix User metadata (username, fullname, email), consumed
by flake.nix and threaded through every module.
configurations/ Per-host top-level configs, autowired into
nixosConfigurations / darwinConfigurations.
nixos/ Drop <name>.nix → nixosConfigurations.<name>.
darwin/ Drop <name>.nix → darwinConfigurations.<name>.
Files prefixed with `_` are skipped by the autowirer (internal helpers,
e.g. _hardware-configuration.nix imported by a host file).
modules/
common/ Shared by darwin + nixos (e.g. nix-settings.nix).
darwin/ macOS-only modules (homebrew, ladybird).
nixos/ NixOS-only modules (desktop, locale, nvidia, gaming, …).
home/ home-manager modules (packages, shell, terminal, git,
editors, ai-tools, gaming) + tmux.conf.
flake/ flake-parts modules (autowire, devshell, packages).
home/ home-manager entry point, imported by every host.
pkgs/ Custom package definitions + nvfetcher sources.
secrets/ sops-encrypted secrets (see Secrets below).
Hosts are assembled by the autowirer in modules/flake/autowire.nix, which
scans configurations/{nixos,darwin}/ and applies the shared overlay stack
and home-manager wiring. The username is defined once (config.nix) and
threaded through every module via specialArgs.
Rebuilding
Run from the config root:
# macOS
sudo darwin-rebuild switch --flake .#darwin
# NixOS (or whatever host you create)
sudo nixos-rebuild switch --flake .#desktop
To check a config evaluates without switching:
nix eval .#darwinConfigurations.darwin.config.system.build.toplevel.drvPath
nix eval .#nixosConfigurations.desktop.config.system.build.toplevel.drvPath
Format the tree with nix fmt (nixfmt).
Updating
# Update all flake inputs (nixpkgs, home-manager, taps, SSH keys, …)
nix flake update
# Update a single input
nix flake update nixpkgs
Custom packages
Custom packages (e.g. Helium) are tracked via
nvfetcher and exposed through the
overlay in flake.nix. To update them to the latest upstream releases:
nix run .#update-packages
This checks upstream for new release tags, fetches the assets, and rewrites
pkgs/_sources/generated.nix with updated versions and hashes. Commit the
result alongside any rebuild.
Custom packages currently include helium, drop-app, tdarr-node, and
steamless-controller. New ones go in pkgs/, are wired into pkgs/nvfetcher.toml
if they track upstream releases, and are added to the overlay in flake.nix.
Secrets
Secrets are managed with sops-nix. Encrypted
files live in secrets/, the recipients are configured in .sops.yaml, and the
age key is derived from the host's SSH key. Edit a secret with:
sops secrets/samba.yaml
Create a New NixOS Host
A NixOS host should exist per machine. To add one:
- Create
configurations/nixos/<name>.nixand copy yourhardware-configuration.nixalongside it as_hardware-configuration.nix(the_prefix keeps it out of the autowirer). Import it from your host file. - Import the shared modules you want from
../../modules/nixos/, plus any flake-input modules viaflake.inputs.<input>.nixosModules.<module>. - Set
nixpkgs.hostPlatformandsystem.stateVersion. - Build it:
sudo nixos-rebuild switch --flake .#<name>.
No flake.nix edit is required — the autowirer picks it up from the
configurations/nixos/ directory. The same applies for new darwin hosts under
configurations/darwin/.