- Nix 93.4%
- Python 6.6%
| .forgejo/workflows | ||
| docs | ||
| hosts | ||
| modules | ||
| pkgs | ||
| .gitignore | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| README.md | ||
| renovate.json | ||
machines
Nix config for my machines. Run all commands from the repo root.
| Host | Config | What |
|---|---|---|
MacStudio |
hosts/mac-studio/ |
Personal Mac. nix-darwin + Home Manager + Homebrew; builds Linux in a local VM, the Pi as fallback |
MB-0075 |
hosts/mb-0075/ |
Work Mac (G DATA). Same, local VM only |
Peters-MacBook-Pro-M2 |
hosts/macbook-pro/ |
Personal MacBook. Same as MacStudio, no linux-builder |
rpi5-executor |
hosts/rpi5-executor/ |
RPi5 NativeLink worker, NVMe boot. Bring-up: docs/rpi5-executor.md |
agent-image-personal, agent-image-work |
hosts/agent-image/ |
NixOS guest images for microsandbox |
Layout: hosts/<name>/ per machine, modules/darwin/ nix-darwin shared by the Macs (Nix settings, linux-builder, common Homebrew; personal.nix: both personal Macs), modules/home/ Home Manager (darwin.nix: everything shared by the Macs; personal.nix: gpg, git-age on the personal Macs), modules/common/ config files and packages shared by all, modules/nixos/ NixOS-only, pkgs/<name>/ custom packages.
Macs
sudo darwin-rebuild switch --flake .#MacStudio
sudo darwin-rebuild switch --flake . # MB-0075, Peters-MacBook-Pro-M2 (config name = LocalHostName)
sudo darwin-rebuild --rollback
darwin-rebuild build --flake . # build only, result in ./result
- CLI tools: nixpkgs-unstable in
modules/darwin/packages.nix(all Macs) orhosts/<mac>/default.nix. Check that a new one is in the binary cache, or it builds from source:nix build --dry-run .#darwinConfigurations.MB-0075.system. - Homebrew (casks, services, formulae nixpkgs lacks):
modules/darwin/homebrew.nixorhosts/<mac>/homebrew.nix, notbrew install: the next switch uninstalls anything not listed (cleanup = "uninstall"). Preview on a Mac:nix eval --raw .#darwinConfigurations.<host>.config.homebrew.brewfile > /tmp/Brewfile && brew bundle cleanup --file=/tmp/Brewfile. - First activation (no
darwin-rebuildyet):sudo nix run nix-darwin/nix-darwin-26.05#darwin-rebuild -- switch --flake .. nix-darwin refuses to overwrite unmanaged/etcfiles; rename the ones it names (/etc/nix/nix.conf,/etc/zshrc,/etc/bashrc) to*.before-nix-darwinand rerun. If the host setsnetworking.hostNameand the Mac still has its old name, pass the config name once (--flake .#Peters-MacBook-Pro-M2); the switch renames the Mac. - Edit dotfiles in the repo; most are read-only links into the Nix store. Apps that write their own config get copies (
dotfiles.mutableFiles), reset on every switch; JSON ones are merged: repo keys win, keys only the app wrote stay.
Agent images
nix build .#packages.aarch64-linux.agent-image-personal --accept-flake-config --max-jobs 0
nix build .#packages.aarch64-linux.agent-image-work --accept-flake-config --max-jobs 0
msb load --input result
GH_TOKEN=$(gh auth token) msb create --conf hosts/agent-image/msb-personal.yaml --name dev
GITLAB_TOKEN=$(glab config get token --host gitlab.gdata.de) msb create --conf hosts/agent-image/msb-work.yaml --name dev
msb ssh dev # as agent (user: in msb-*.yaml)
msb exec --user root dev -- /run/current-system/sw/bin/bash
# Host dir, owned by agent in the guest; the host path must not go through a symlink (/var → /private/var):
GH_TOKEN=$(gh auth token) msb create --conf hosts/agent-image/msb-personal.yaml --name dev \
--mount-dir ~/sources:/workspace:uid=1000,gid=100
- Shared:
hosts/agent-image/default.nix(Node, Python, uv, git tools, Claude, herdr).personal.nix: Go, Rust, Bazel, gh.work.nix: .NET 10, glab, gdata email. - No tokens in the image:
GH_TOKEN/GITLAB_TOKENhold msb's placeholder ($MSB_GH_TOKEN,$MSB_GITLAB_TOKEN); msb replaces it with the host's token only on requests to GitHub / gitlab.gdata.de (secretsinmsb-*.yaml). git usesgh/glab auth git-credentialas credential helper for those hosts. - Both images are
agent:latest; loading one replaces the other. - The full attribute path is required on macOS (
.#agent-image-worklooks inpackages.aarch64-darwin).--max-jobs 0builds on the Linux builder. - First boot installs the ponytail Claude plugin and herdr-sessionizer (needs network):
journalctl -u agent-bootstrap.
rpi5-executor
nix run nixpkgs#nixos-rebuild -- switch --flake .#rpi5-executor \
--target-host baez@rpi5-executor.local --build-host baez@rpi5-executor.local --sudo --accept-flake-config
ssh baez@rpi5-executor.local sudo nixos-rebuild switch --rollback
ssh baez@rpi5-executor.local journalctl -u nativelink-worker -f
curl http://rpi5-executor.local:9100/metrics
Update and check
nix flake update # all inputs (Renovate opens a PR for this every Monday)
nix flake update home-manager # one input
nix flake update nixpkgs-unstable # Mac CLI tools, the agent images' claude-code
nix flake check --accept-flake-config # builds every check; needs the Linux builder
Linux builder
cat /etc/nix/machines
sudo launchctl list org.nixos.linux-builder
# Trivial build on each builder (command grep: an aliased grep's color codes break the entry).
for b in linux-builder rpi5-executor; do
nix build -L --max-jobs 0 --no-link --print-out-paths --impure \
--builders "$(command grep "$b" /etc/nix/machines)" \
--expr "derivation { name = \"test-$b\"; system = \"aarch64-linux\"; builder = \"/bin/sh\"; args = [ \"-c\" \"echo ok > \$out\" ]; }"
done
Changing nix.linux-builder.config rebuilds the VM image, which needs a running Linux builder. A Mac without one switches to a copy with nix.linux-builder.config = lib.mkForce { } first (the stock builder is in cache.nixos.org), as darwinConfigurations.MB-0075-bootstrap in flake.nix does.
Free disk space
Local Nix store
du -sh /nix/store
sudo nix-collect-garbage --delete-older-than 14d # system generations (nix-darwin)
nix-collect-garbage --delete-older-than 14d # user generations (Home Manager)
nix store optimise # hard-link identical files
rm -rf ~/.cache/nix # flake/tarball fetch cache
-dinstead of--delete-older-thankeeps only the current generation; no rollback afterwards.nix store gc --dry-runlists what would be deleted.- GC frees less than expected: stale
resultsymlinks fromnix buildkeep paths alive. Find them withnix-store --gc --print-roots | grep -v '^/proc', delete them, collect again.
Linux builder VM
nixos.qcow2 holds only the VM's own /nix/store. Deleting it loses cached build outputs; the next start creates an empty disk and builds work as before, slower at first. Keep keys/ (SSH key the Mac's nix-daemon uses to connect). Also needed after changing diskSize, which otherwise keeps the old disk size.
sudo du -sh /var/lib/linux-builder/*
sudo launchctl bootout system/org.nixos.linux-builder # stop; KeepAlive restarts a killed VM
sudo rm /var/lib/linux-builder/nixos.qcow2
sudo launchctl bootstrap system /Library/LaunchDaemons/org.nixos.linux-builder.plist
Run only bootout to stop the VM without deleting the disk; it comes back on bootstrap or the next darwin-rebuild switch. nix.linux-builder.ephemeral = true deletes the disk on every start.
Personal vs. work
dotfiles.email (Home Manager) with an @gdata.de address sets dotfiles.isWork:
| Personal | Work | |
|---|---|---|
| git email, signing | gmail, gpg key | gdata, SSH key via Bitwarden's agent |
| git ignores | + .kata.toml .junie/ .zed/ |
|
| oh-my-zsh | bazel git kubectl brew |
git kubectl brew |
| herdr sessionizer | agents tab |
claude tab |
| Zed, pi | modules/common/{zed,pi}/settings.json |
plus work.json merged on top (null deletes a key) |
Not managed (secrets, app state)
| File | Contents |
|---|---|
~/.bazelrc.local |
Bazel --remote_header API keys, imported by the managed ~/.bazelrc |
~/.zshrc.local |
JFROG_TOKEN (MB-0075), sourced by zsh |
~/.gitconfig |
gitlab.gdata.de OAuth client ID (MB-0075); read after ~/.config/git/config, also where git config --global writes |
~/.config/zed/settings.json |
AgentGateway token (context_servers.agentgateway.headers.Authorization), kept by the merge |
~/.pi/agent/extensions/herdr-agent-state.ts, ~/.claude/hooks/herdr-agent-state.sh |
herdr integration install |
Pi as remote builder for a new Mac
The Mac's nix-daemon connects as nix-ssh (nix.sshServe in hosts/rpi5-executor) with its own key; not /etc/nix/builder_ed25519, which the linux-builder overwrites.
sudo ssh-keygen -t ed25519 -N '' -C "nix-daemon@$(scutil --get LocalHostName)" -f /etc/nix/rpi5-executor_ed25519
sudo cat /etc/nix/rpi5-executor_ed25519.pub # add to nix.sshServe.keys, deploy the Pi
Then copy the nix.buildMachines entry from hosts/mac-studio/default.nix into the new host.
Host key verification failed: Pi reinstalled; updatepublicHostKey(ssh baez@rpi5-executor.local cat /etc/ssh/ssh_host_ed25519_key.pub | cut -d' ' -f1,2 | base64).Permission denied (publickey): key not deployed on the Pi, or not readable by root.No space left on device: the Pi builds in a tmpfs/tmp; large Rust builds can fill it.