Personal Nix configuration for macOS (nix-darwin) and NixOS machines.
| Host | Type | Description |
|---|---|---|
| lambda | nix-darwin (aarch64) | macOS workstation |
| htpc | NixOS (x86_64) | Home theater PC running Kodi + Jellyfin |
Secrets are managed with agenix and stored in a private repository. Each machine decrypts secrets using its SSH host key (NixOS) or personal SSH key (macOS).
Install Nix via Determinate Systems:
curl -fsSL https://install.determinate.systems/nix | sh -s -- installClone the repo:
git clone https://github.com/zerw0/nix-config.git ~/git/nix-configClone the private secrets repo:
git clone git@git.zerw.xyz:hdjenkov/nix-private.git ~/git/nix-privateApply the configuration:
sudo darwin-rebuild switch --flake ~/git/nix-config#lambda --override-input secrets ~/git/nix-privateBoot from the installer ISO, then from your workstation copy your SSH key to the target:
export NIXOS_HOST=192.168.x.x
ssh-copy-id -i ~/.ssh/personal hdjenkov@$NIXOS_HOSTSSH in with agent forwarding:
ssh -A hdjenkov@$NIXOS_HOSTEnable flakes:
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.confPartition and format using disko:
nix --experimental-features "nix-command flakes" run github:nix-community/disko \
-- -m destroy,format,mount \
/path/to/nix-config/machines/nixos/htpc/disk-config.nixInstall git and clone the repo:
nix-env -f '<nixpkgs>' -iA git
mkdir -p /mnt/home/hdjenkov/git
git clone https://github.com/zerw0/nix-config.git /mnt/home/hdjenkov/git/nix-configInstall:
nixos-install --root /mnt --no-root-passwd \
--flake git+file:///mnt/home/hdjenkov/git/nix-config#htpcReboot, then SSH in with agent forwarding and add the host to the secrets repo:
ssh -A hdjenkov@$NIXOS_HOST
cat /etc/ssh/ssh_host_ed25519_key.pubAdd the host key to secrets.nix in the private repo, re-encrypt, and push:
cd ~/git/nix-private
agenix -r
git add -A && git commit -m "add htpc host key" && git pushPull and deploy:
git clone https://github.com/zerw0/nix-config.git ~/git/nix-config
git clone git@git.zerw.xyz:hdjenkov/nix-private.git ~/git/nix-private # SSH agent forwarded
cd ~/git/nix-config && git pull
sudo --preserve-env=SSH_AUTH_SOCK nixos-rebuild switch --flake ~/git/nix-config#htpc --override-input secrets ~/git/nix-privatelambda:
cd ~/git/nix-config && git pull
sudo darwin-rebuild switch --flake ~/git/nix-config#lambda --override-input secrets ~/git/nix-privatehtpc (SSH in with -A, then):
cd ~/git/nix-config && git pull
sudo nixos-rebuild switch --flake ~/git/nix-config#htpcAfter the first successful deploy, htpc preserves
SSH_AUTH_SOCKthrough sudo automatically, so it can fetch the secrets repo directly without--override-input.