Nix flake for my personal machines — NixOS system + Home Manager configs for personal machines.
  • Nix 75.4%
  • Shell 18.9%
  • JavaScript 5.7%
Find a file
2026-07-02 12:02:37 +01:00
android Remove sync conflict file 2026-07-02 09:29:47 +01:00
home Add 1password git signing 2026-06-20 10:50:22 +01:00
hosts Add logitech udev rules on desktop 2026-06-30 19:34:49 +01:00
modules Add io.github.wartybix.Constrict 2026-07-02 11:56:50 +01:00
pkgs/hid-magicmouse-nobattery Patch out magic trackpad battery issue 2026-06-20 09:58:14 +01:00
secrets Add nut ups 2026-06-20 16:14:12 +01:00
.gitignore Add configuration for Android Linux VM 2026-06-27 20:07:43 +01:00
CHEATSHEET.md docs: add NixOS cheatsheet 2026-06-13 15:55:38 +01:00
flake.lock flake.lock maintenance 2026-07-02 12:02:37 +01:00
flake.nix Add configuration for Android Linux VM 2026-06-27 20:07:43 +01:00
README.md Initial commit 2026-06-05 21:17:47 +01:00

NixOS machines

Declarative config for my NixOS machines. Multi-host flake: shared config in modules/, per-machine specifics in hosts/, user environment in home/. The repo is synced across machines by Syncthing, so every host builds from ~/Code/nixos directly.

Each host's default.nix imports ../../modules plus its own hardware-configuration.nix, then sets only what's machine-specific. The flake's mkHost adds nix-flatpak, home-manager, and agenix to every host. No conditionals — a machine either imports a module or it doesn't.

Day-to-day

The flake attribute is the hostname, so bare nixos-rebuild targets the right host:

sudo nixos-rebuild switch --flake /home/jonathan/Code/nixos#laptop
sudo nixos-rebuild build  --flake /home/jonathan/Code/nixos#laptop   # check without activating
nix flake update          --flake /home/jonathan/Code/nixos          # bump inputs
sudo nixos-rebuild switch --rollback                                 # previous gen

New .nix files are picked up automatically (not a git flake, so no git add needed).

Secrets (agenix)

The GitHub packages token lives encrypted in secrets/github-token.age, decrypted at boot to /run/agenix/github-token, and read into GITHUB_PACKAGES_TOKEN by zsh. Every host that consumes a secret must be a recipient in secrets/secrets.nix — get a host's pubkey with cat /etc/ssh/ssh_host_ed25519_key.pub.

cd secrets && nix run github:ryantm/agenix -- -e github-token.age   # edit
cd secrets && nix run github:ryantm/agenix -- -r                    # re-encrypt

modules/secrets.nix guards on pathExists, so the config still evaluates before the .age exists.

Home / dotfiles

home/jonathan.nix (home-manager): zsh + oh-my-zsh + starship, git, ssh, editorconfig, Syncthing, GNOME dconf. The system only enables zsh as a login shell; all shell config is here. Conflicting pre-existing files are moved to *.hm-bak on first switch. Syncthing's device list is filtered per host so a machine never lists itself; server is the introducer.

Adding a host

  1. Install NixOS (UEFI → systemd-boot).
  2. sudo nixos-generate-config --show-hardware-config > hosts/<name>/hardware-configuration.nix
  3. Write hosts/<name>/default.nix: bootloader, networking.hostName, system.stateVersion, and imports = [ ./hardware-configuration.nix ../../modules ].
  4. Add <name> = mkHost ./hosts/<name>; to flake.nix.
  5. Add the host's SSH host key to secrets/secrets.nix, then agenix -r.
  6. sudo nixos-rebuild switch --flake /home/jonathan/Code/nixos#<name>.

Each host needs its own hardware-configuration.nix — never copy one machine's to another. Re-encrypt secrets after a fresh install: the new host gets a new SSH host key, so update secrets/secrets.nix and run agenix -r, or boot-time decryption will fail.