This repo provides a single, shared configuration you can apply to thousands of machines without per-host files in the repo. Hardware and host identity are kept host-local where needed, while the repo stays generic and pure.
- One shared Home Manager configuration applied everywhere.
- NixOS and nix-darwin manage system settings; non‑NixOS Linux uses HM‑only.
- Multi‑host support without flooding the repo with host folders.
flake.nix: Core logic, inputs/outputs, shared HM modules, NixOS/Darwin wiring.flake.lock: Pinned inputs for reproducibility.scripts/regenerate-hardware.sh: Generateshardware/<host>.nix+hardware/<host>.systemon NixOS hosts.hardware/(optional): Host hardware files created on NixOS hosts. The repo works even without it.
nixpkgs,nixpkgs-darwin,flake-utilsnix-darwin(macOS system management)home-manager(shared user config)sops-nix(placeholder for secrets)determinate-nix(recommended Nix installer on macOS/Linux)
nixosConfigurations: Built dynamically fromhardware/*.nix+*.system.- Each NixOS config includes a minimal base module (
system.stateVersion, admin user) and the shared HM for useradmin.
- Each NixOS config includes a minimal base module (
darwinConfigurations.myMac: nix-darwin config with the shared HM for useradmin.homeConfigurations.admin-linux: HM‑only profile for generic Linux (Fedora/Ubuntu), using the same shared HM modules.packages.<system>.default: Example environment derivation.
The flake defines hmSharedModules once and uses it on all platforms:
- Enable:
xdg,zsh,git,fzf,direnvwithnix-direnv,starship. - Packages:
git,curl,wget,ripgrep,fd,bat,tree,htop,neovim,podman,qemu. home.stateVersion = "24.11"is set inside HM modules when applied via NixOS/Darwin; for Linux HM‑only, it’s set in the HM output.
Multi‑host support is simple and pure:
- On the NixOS host, run:
./scripts/regenerate-hardware.sh- This writes
hardware/<host>.nixandhardware/<host>.systemin the repo.
- Push changes (optional, if you want to keep hardware in the repo):
git add hardware && git commit -m "add <host> hardware" && git push origin dev
- Switch the host:
sudo nixos-rebuild switch --flake github:aspauldingcode/.dotfiles?ref=dev#<host>
Notes:
- Each NixOS config automatically includes a minimal base module setting
system.stateVersionand creatingusers.users.adminwithwheelandsudoenabled. - The shared HM user (
admin) is applied viahome-manager.nixosModules.home-managerinside every NixOS config.
Use nix-darwin for system, with shared HM for the same admin user:
darwin-rebuild switch --flake github:aspauldingcode/.dotfiles?ref=dev#myMac- HM home directory on macOS:
/Users/admin. - The flake disables Nix management inside darwin and favors Determinate Nix.
For Fedora/Ubuntu or other non‑NixOS Linux, use the HM‑only output:
- Install Nix:
curl -fsSL https://get.determinate.systems/nix | sh -s -- install
- Ensure user
adminexists with home/home/adminand sudo per distro policy. - Switch HM:
nix run nixpkgs#home-manager -- switch --flake github:aspauldingcode/.dotfiles?ref=dev#admin-linux
- Test only (no activation):
nix build github:aspauldingcode/.dotfiles?ref=dev#homeConfigurations.admin-linux.activationPackage
You can validate NixOS configs from Fedora/Ubuntu:
- Create a stub:
mkdir -p hardwareprintf '{ ... }: { system.stateVersion = "24.11"; }\n' > hardware/devtest.nixecho x86_64-linux > hardware/devtest.system
- Build the closure:
nix build github:aspauldingcode/.dotfiles?ref=dev#nixosConfigurations.devtest.config.system.build.toplevel
- Build and run a VM:
nix build github:aspauldingcode/.dotfiles?ref=dev#nixosConfigurations.devtest.config.system.build.vm./result/bin/run-devtest-vm
If you have thousands of devices, you don’t need per‑host files in the repo:
- Host‑local flake input overrides (recommended)
- Keep the repo generic; inject hardware and identity from the host at build time.
- Command pattern:
sudo nixos-rebuild switch --flake github:aspauldingcode/.dotfiles?ref=dev#core \ --override-input host-hw path:/etc/nixos/hardware-configuration.nix \ --override-input host-params path:/etc/nixos/host.json
host.jsonexample:{ "system": "x86_64-linux", "hostname": "esmeralda", "uuids": { "/": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "/boot": "1234-ABCD" } }
- Standardize disk labels or use Disko (most pure)
- Reference
fileSystemsby label (e.g.,/dev/disk/by-label/nixos-root) or declare disks viadisko. - No per‑host hardware differences; a single config fits all machines with the same layout.
- Parameterized hardware function (
mkHost)
- Define a function that takes UUIDs/labels + hostname and returns a module:
mkHost { hostname = "esmeralda"; uuids = { "/" = "..."; "/boot" = "..."; }; }
- Feed it via
host.jsonon each machine (override input), keep the repo generic.
Specializations
- Useful for a handful of alternative profiles; not ideal for thousands.
- NixOS switch:
sudo nixos-rebuild switch --flake github:aspauldingcode/.dotfiles?ref=dev#<host> - macOS switch:
darwin-rebuild switch --flake github:aspauldingcode/.dotfiles?ref=dev#myMac - Linux HM switch:
nix run nixpkgs#home-manager -- switch --flake github:aspauldingcode/.dotfiles?ref=dev#admin-linux - Build NixOS VM:
nix build github:aspauldingcode/.dotfiles?ref=dev#nixosConfigurations.<host>.config.system.build.vm
- Shared HM is defined once and reused everywhere.
- NixOS/Darwin carry system responsibilities; Linux HM‑only focuses on user environment.
- Multi‑host hardware handled via
hardware/*.nix+*.systemor host‑local inputs, keeping the repo clean.
- HM user is
adminby default; paths are/home/admin(Linux) and/Users/admin(macOS). - You can parameterize the username per host while keeping the same shared HM modules.
sops-nixis included for future secrets management; currently unused.packages.defaultis a small example derivation; not required for usage.
- Use the
devbranch for staging; reference flake URLs with?ref=dev. - CI (optional): add
nix flake checkon pushes todevbefore merging.