About
Quick note about the needed bits to get remote building for Nix into a working state on OSX.
Details
The following environment variables are set to hook everything together, so that Nix knows where to build stuff:
export NIX_BUILD_HOOK=~/.nix-profile/libexec/nix/build-remote.pl export NIX_REMOTE_SYSTEMS=~/etc/nix/remote-systems.conf export NIX_CURRENT_LOAD=~/tmp/nix-load
To trigger a Linux build, the following command can be used if the derivation allows for an input argument called pkgs:
# in general nix-build --option system x86_64-linux # special needs nix-build --arg pkgs '(import <nixpkgs> { system="x86_64-linux"; })'
Which I ended up putting into the following utility function:
function nix_build_linux() { nix-build \ --arg pkgs '(import <nixpkgs> { system="x86_64-linux"; })' \ $@ } export -f nix_build_linux
So often it then boils down into the following:
nix_build_linux release.nix -A build
Note
Initially I used nix-build-linux as the function name. It did turn out that this does work in bash, but it does fail in sh. So I did adapt the name to use underscores instead.
Pointers
Pointers to the code:
- nix-build-linux https://github.com/johbo/johpkgs/commit/aca27fd96656ad9b0495d2a68bcf894796ece21b
- Environment for remote building https://github.com/johbo/johpkgs/commit/ba8b57503dd32e40cb831fe2265de1bfdd6122ee
- A later fix - https://github.com/johbo/johpkgs/commit/bfc82419d0e895a32dd42f3297efcbc050e65445