Distributed build: Difference between revisions

Jopejoe1 (talk | contribs)
Use modular settings option instead of multi-line string option
Axka (talk | contribs)
m Minor wording changes
 
(6 intermediate revisions by 5 users not shown)
Line 40: Line 40:
{{Tip|The best test to check that the SSH access works for Nix is to run on your local machine:
{{Tip|The best test to check that the SSH access works for Nix is to run on your local machine:


nix store ping --store ssh://<REMOTE-BUILDER>
<code>nix store info --store ssh://<REMOTE-BUILDER></code>


Where <REMOTE-BUILDER> is the remote builder's IP address, host address or whatever name you configure in ~/.ssh/config or /root/.ssh/config, including the user@ prefix.}}
Where <code><REMOTE-BUILDER></code> is the remote builder's IP address, host address or whatever name you configure in ~/.ssh/config or /root/.ssh/config, including the user@ prefix.}}


An alternative check is:
An alternative check is:
Line 112: Line 112:
You may also want to make nix on '''the remote machine''' trust that new user by adding it to {{ic|nix.settings.trusted-users}} if it's using NixOS, or by manually adding <code><nowiki>trusted-users = nixremote</nowiki></code> to {{ic|/etc/nix/nix.conf}}.
You may also want to make nix on '''the remote machine''' trust that new user by adding it to {{ic|nix.settings.trusted-users}} if it's using NixOS, or by manually adding <code><nowiki>trusted-users = nixremote</nowiki></code> to {{ic|/etc/nix/nix.conf}}.


== '''Modify the local machine's Nix config to know about the remote machine'''. ==
== Modify the local machine's Nix config to know about the remote machine. ==
The Nix package manager '''on your local machine''' '''needs to know that the remote builder exists''' and what its ''supported features'' are. See [https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-system-features official supportedFeatures documentation].  
The Nix package manager '''on your local machine''' '''needs to know that the remote builder exists''' and what its ''supported features'' are. See [https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-system-features official supportedFeatures documentation].  


Line 145: Line 145:
     # default is 1 but may keep the builder idle in between builds
     # default is 1 but may keep the builder idle in between builds
     maxJobs = 3;
     maxJobs = 3;
     # how fast is the builder compared to your local machine
     # how fast is the builder compared to other remote builders
     speedFactor = 2;
     speedFactor = 2;
     supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
     supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
Line 244: Line 244:
* How do I know why my builds aren't being distributed?
* How do I know why my builds aren't being distributed?
** Run <code>nix build -vvvvvvvvv 2>&1 | less</code> and search for <code>decline</code>.
** Run <code>nix build -vvvvvvvvv 2>&1 | less</code> and search for <code>decline</code>.
* I can <code>nix store ping</code> but the build doesn't distribute.
* I can <code>nix store info</code> but the build doesn't distribute.
** If on NixOS, Check that <code>nix store ping</code> command works when run as root.
** If on NixOS, Check that <code>nix store info</code> works when run as root.
** If you configured builders on the command line (with <code>--builders</code>), make sure your account is in <code>nix.trustedUsers</code> in <code>/etc/nixos/configuration.nix</code>. Only <code>/etc/nix/nix.conf</code> is taken into account otherwise.
** If you configured builders on the command line with the <code>--builders</code> flag, make sure your account is in <code>nix.trustedUsers</code> in <code>/etc/nixos/configuration.nix</code>. Otherwise only <code>/etc/nix/nix.conf</code> is taken into account.
* I can ping the store as root, but I'm getting "broken pipe" errors when trying to distribute.
* I can <code>nix store info</code> as root, but I'm getting "broken pipe" errors when trying to distribute.
** You may have hit bug {{Issue|46038}}. Add <code>nix.distributedBuilds = true;</code> to <code>configuration.nix</code> and <code>nixos-rebuild switch</code>.
** You may have hit bug {{Issue|46038}}. Add <code>nix.distributedBuilds = true;</code> to <code>configuration.nix</code> and <code>nixos-rebuild switch</code>.
== Tips and tricks ==
=== One-time remote build ===
For a quick, one-time remote build without needing to change any system settings, see [[Nixos-rebuild#Deploying_on_other_machines]].


== See also ==
== See also ==
* [https://github.com/NixOS/nix/blob/master/tests/remote-builds.nix#L46-L58 The NixOS Remote Builds Test Case]
* [https://github.com/NixOS/nix/blob/a6e6da3b0c579fc540acb00748fe3fd1858b9d99/tests/nixos/remote-builds.nix#L11-L21 The NixOS Remote Builds Test Case]
* [https://nixos.org/nix-dev/2015-September/018255.html Mail to nixos-dev about setting up remote builds by Russell O'Connor]
* [https://nixos.org/nix-dev/2015-September/018255.html Mail to nixos-dev about setting up remote builds by Russell O'Connor]
* [https://gist.github.com/danbst/09c3f6cd235ae11ccd03215d4542f7e7 A step-by-step guide on remote Firefox building through bastion host]
* [https://gist.github.com/danbst/09c3f6cd235ae11ccd03215d4542f7e7 A step-by-step guide on remote Firefox building through bastion host]