Skip to content

Instantly share code, notes, and snippets.

@3noch
Last active January 4, 2024 14:34
Show Gist options
  • Save 3noch/8d073f3a9feffa53e45a9f20514e8152 to your computer and use it in GitHub Desktop.
Save 3noch/8d073f3a9feffa53e45a9f20514e8152 to your computer and use it in GitHub Desktop.
How to set up distributed builds with nix

Reference: https://github.com/LnL7/nix-docker

# If on Darwin, I recommend keeping nix stuff contained
mkdir -p /nix/etc/nix
ln -s /nix/etc/nix /etc/nix  # sysconfdir; can be overridden with $NIX_CONF_DIR

cd /nix/etc/nix/
openssl genrsa -out signing-key.sec 2048
openssl rsa -in signing-key.sec -pubout > signing-key.pub
chmod 600 signing-key.sec

ssh nix-docker mkdir -p /etc/nix
scp signing-key.sec <other-machine>:signing-key.sec
scp signing-key.pub <other-machine>:signing-key.pub

ssh <other-machine>
chmod 600 signing-key.*
mv signing-key.* /etc/nix

Set up a file remote-systems.conf using this format: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/nix-daemon.nix#L343-L353

Then point $NIX_REMOTE_SYSTEMS to that file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment