Distributed build: Difference between revisions
imported>Fadenb Created page with "Sometimes you want to use a faster machine for building a nix derivation you want to use on a slower one. If both of them run NixOS you can follow this little HOWTO to make it..." |
imported>Fadenb m Syntax highlighting |
||
Line 18: | Line 18: | ||
First you have to prepare the remote-systems.conf file on the slower machine, for example in /etc/nixos/remote-systems.conf, with contents similar to: | First you have to prepare the remote-systems.conf file on the slower machine, for example in /etc/nixos/remote-systems.conf, with contents similar to: | ||
<pre> | |||
root@builder.example.com i686-linux /etc/nixos/id_rsa 4 | |||
</pre> | |||
Where: | Where: | ||
Line 32: | Line 33: | ||
As a convenience, we'll make a little script. Put this into /etc/nixos/remote-build-env: | As a convenience, we'll make a little script. Put this into /etc/nixos/remote-build-env: | ||
<syntaxhighlight lang="bash"> | |||
mkdir /tmp/build-remote-load/ | |||
chmod a+rwX /tmp/build-remote-load/ | |||
# First find our build hook script | |||
STORE_PATH_FOR_NIX=$(ls -l `which nix-env` | awk '{ sub( /bin\/nix-env/, "", $NF ); print $NF }') | |||
BUILD_REMOTE=`find "${STORE_PATH_FOR_NIX}" -name build-remote.pl` | |||
# now set up environment for nix-worker | |||
export NIX_BUILD_HOOK="${BUILD_REMOTE}" | |||
export NIX_REMOTE_SYSTEMS="/etc/nixos/remote-systems.conf" | |||
export NIX_CURRENT_LOAD="/tmp/build-remote-load" | |||
</syntaxhighlight> | |||
== Running the build == | == Running the build == | ||
This is the part that you'll have to do every time you want to build something remotely. | This is the part that you'll have to do every time you want to build something remotely. | ||
First, as root: | First, as root: | ||
<syntaxhighlight lang="bash"> | |||
stop nix-daemon | |||
. /etc/nixos/remote-build-env | |||
nix-worker --daemon & | |||
</syntaxhighlight> | |||
Then, as a user you want to do the build as: | Then, as a user you want to do the build as: | ||
<syntaxhighlight lang="bash"> | |||
. /etc/nixos/remote-build-env | |||
</syntaxhighlight> | |||
after that you can run nix-env normally, and the work should be distributed among machines in your remote-systems.conf | after that you can run nix-env normally, and the work should be distributed among machines in your remote-systems.conf | ||
== using remote builds on NixOS == | == using remote builds on NixOS == | ||
See configuration options nix.distributedBuilds, nix.manualNixMachines, etc to set this up in your /etc/configuration.nix file | See configuration options nix.distributedBuilds, nix.manualNixMachines, etc to set this up in your /etc/configuration.nix file |