- Nix 100%
mac #
layout #
hosts/darwin/— shared nix-darwin config for all macshosts/<host>/— per-mac overrides (mac,macmini)home/darwin.nix— shared home-manager config (zsh + oh-my-zsh, packages)
To add a mac: create hosts/<name>/default.nix and add <name> = mkDarwin "<name>"; in flake.nix.
After bootstrap: sudo darwin-rebuild switch --flake .#<host>
bootstrap #
- install nix
curl -fsSL https://install.determinate.systems/nix | sh -s -- install
- first run
sudo nix --extra-experimental-features 'nix-command flakes' run nix-darwin -- switch --flake .#<host> (mac or macmini)
sudo mv /etc/bashrc /etc/bashrc.before-nix-darwin
sudo mv /etc/zshrc /etc/zshrc.before-nix-darwin
sudo darwin-rebuild switch --flake .#<host>(macormacmini)
nixos #
sudo nixos-rebuild switch --flake .#nixos
rpi (Raspberry Pi 4) #
Headless Pi 4 (2GB): SSH, Tailscale, zsh + oh-my-zsh.
hosts/rpi/— system config. Also builds the SD image, so image and live system match.home/rpi.nix— home-manager (shell, git, neovim). CLI only, no GUI apps.
build the image (on the mac) #
The mac builds aarch64-linux in a Linux VM (nix.linux-builder in hosts/mac). Enable it once:
sudo darwin-rebuild switch --flake .#mac
Then build. Kernel/firmware come from the binary cache, nothing compiles:
nix build .#packages.aarch64-linux.rpi-sd-image
Output: result/sd-image/nixos-image-sd-card-*.img.zst (~1.5 GB, zstd-compressed).
flash the SD card (on the mac) #
Erases the whole card.
- find the card:
diskutil list physical. The MacBook's slot shows as "Built In SDXC Reader" (diskutil info /dev/diskN), marked internal but removable. Never usedisk0(the mac's SSD). Below, replacediskNwith the card. sudo -v(enter password before the pipe starts)diskutil unmountDisk /dev/diskNnix run nixpkgs#zstd -- -dc result/sd-image/*.img.zst | sudo dd of=/dev/rdiskN bs=4m status=progress(rdiskN= raw device, much faster thandiskN)diskutil eject /dev/diskN
"Permission denied" / "Read-only file system" → slide the card's lock switch to unlocked.
first boot #
- insert card, plug in ethernet, power on. First boot grows the root partition to fill the card; give it a minute or two.
ssh naikaayush@rpi.local(mDNS). Doesn't resolve → use the IP from the router.sudo tailscale up, open the login link. After that:ssh naikaayush@rpi.- wifi (optional):
sudo nmcli device wifi connect <SSID> --ask
wake on lan #
From the Pi: wakeonlan <mac-address>. Target must be on wired ethernet.
updates (on the pi) #
Push to tangled first, then on the Pi, once:
git clone https://tangled.org/naikaayush.com/nix-config ~/nix-config
sudo nixos-rebuild switch --flake ~/nix-config#rpi
After that, update pulls and rebuilds (alias in home/rpi.nix).