* Support for system-wide distributed / multi-platform builds.
Just set nix.distributedBuilds to true and nix.buildMachines to a list of machines that can perform Nix builds via SSH, and local builds will be forwarded appropriately. So now any user can say something like nix-build /etc/nixos/nixpkgs/ --arg system '"powerpc-linux"' -A libxml2 and the build for powerpc-linux will be forwarded to a machine of that type. svn path=/nixos/trunk/; revision=9696
This commit is contained in:
parent
14c2bb437d
commit
f6fd10cbd8
|
@ -1,4 +1,6 @@
|
|||
{config, pkgs, upstartJobs, systemPath, wrapperDir, defaultShell, extraEtc}:
|
||||
{ config, pkgs, upstartJobs, systemPath, wrapperDir
|
||||
, defaultShell, extraEtc, nixEnvVars
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
|
@ -106,6 +108,7 @@ import ../helpers/make-etc.nix {
|
|||
inherit (pkgs) systemKernel glibc;
|
||||
timeZone = config.time.timeZone;
|
||||
defaultLocale = config.i18n.defaultLocale;
|
||||
inherit nixEnvVars;
|
||||
};
|
||||
target = "profile";
|
||||
}
|
||||
|
@ -213,6 +216,16 @@ UseSTARTTLS=${if config.networking.defaultMailServer.useSTARTTLS then "YES" else
|
|||
]
|
||||
)
|
||||
|
||||
# List of machines for distributed Nix builds in the format expected
|
||||
# by build-remote.pl.
|
||||
++ optional config.nix.distributedBuilds {
|
||||
source = pkgs.writeText "nix.machines"
|
||||
(pkgs.lib.concatStrings (map (machine:
|
||||
"${machine.sshUser}@${machine.hostName} ${machine.system} ${machine.sshKey} ${toString machine.maxJobs}\n"
|
||||
) config.nix.buildMachines));
|
||||
target = "nix.machines";
|
||||
}
|
||||
|
||||
# Additional /etc files declared by Upstart jobs.
|
||||
++ extraEtc;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
export PATH=@wrapperDir@:/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin
|
||||
export MODULE_DIR=@systemKernel@/lib/modules
|
||||
export NIX_CONF_DIR=/nix/etc/nix
|
||||
export NIXPKGS_CONFIG=/nix/etc/config.nix
|
||||
export PAGER=less
|
||||
export TZ=@timeZone@
|
||||
|
@ -27,6 +26,10 @@ else
|
|||
fi
|
||||
|
||||
|
||||
# Set up the environment variables for running Nix.
|
||||
@nixEnvVars@
|
||||
|
||||
|
||||
# Set up the per-user profile.
|
||||
NIX_USER_PROFILE_DIR=/nix/var/nix/profiles/per-user/$USER
|
||||
mkdir -m 0755 -p $NIX_USER_PROFILE_DIR
|
||||
|
|
|
@ -67,6 +67,8 @@ mkdir -m 0755 -p /var/run/console # for pam_console
|
|||
touch /var/run/utmp # must exist
|
||||
chmod 644 /var/run/utmp
|
||||
|
||||
mkdir -m 0755 -p /var/run/nix/current-load # for distributed builds
|
||||
|
||||
mkdir -m 0755 -p /var/log
|
||||
|
||||
touch /var/log/wtmp # must exist
|
||||
|
|
|
@ -1283,6 +1283,52 @@
|
|||
";
|
||||
};
|
||||
|
||||
distributedBuilds = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to distribute builds to the machines listed in
|
||||
<option>nix.buildMachines</option>.
|
||||
";
|
||||
};
|
||||
|
||||
buildMachines = mkOption {
|
||||
example = [
|
||||
{ hostName = "voila.labs.cs.uu.nl";
|
||||
sshUser = "nix";
|
||||
sshKey = "/root/.ssh/id_buildfarm";
|
||||
system = "powerpc-darwin";
|
||||
maxJobs = 1;
|
||||
}
|
||||
{ hostName = "linux64.example.org";
|
||||
sshUser = "buildfarm";
|
||||
sshKey = "/root/.ssh/id_buildfarm";
|
||||
system = "x86_64-linux";
|
||||
maxJobs = 2;
|
||||
}
|
||||
];
|
||||
description = "
|
||||
This option lists the machines to be used if distributed
|
||||
builds are enabled (see
|
||||
<option>nix.distributedBuilds</option>). Nix will perform
|
||||
derivations on those machines via SSh by copying the inputs to
|
||||
the Nix store on the remote machine, starting the build, then
|
||||
copying the output back to the local Nix store. Each element
|
||||
of the list should be an attribute set containing the
|
||||
machine's host name (<varname>hostname</varname>), the user
|
||||
name to be used for the SSH connection
|
||||
(<varname>sshUser</varname>), the Nix system type
|
||||
(<varname>system</varname>, e.g.,
|
||||
<literal>\"i686-linux\"</literal>), the maximum number of jobs
|
||||
to be run in parallel on that machine
|
||||
(<varname>maxJobs</varname>), and the path to the SSH private
|
||||
key to be used to connect (<varname>sshKey</varname>). The
|
||||
SSH private key should not have a passphrase, and the
|
||||
corresponding public key should be added to
|
||||
<filename>~<replaceable>sshUser<replaceable>/authorized_keys</filename>
|
||||
on the remote machine.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -153,24 +153,35 @@ rec {
|
|||
};
|
||||
|
||||
|
||||
# Environment variables for running Nix.
|
||||
nixEnvVars =
|
||||
"export NIX_CONF_DIR=/nix/etc/nix\n" +
|
||||
(if config.nix.distributedBuilds then
|
||||
"export NIX_BUILD_HOOK=${nix}/libexec/nix/build-remote.pl\n" +
|
||||
"export NIX_REMOTE_SYSTEMS=/etc/nix.machines\n" +
|
||||
"export NIX_CURRENT_LOAD=/var/run/nix/current-load\n"
|
||||
else "");
|
||||
|
||||
|
||||
# The services (Upstart) configuration for the system.
|
||||
upstartJobs = import ../upstart-jobs/default.nix {
|
||||
inherit config pkgs nix modprobe nssModulesPath;
|
||||
inherit config pkgs nix modprobe nssModulesPath nixEnvVars;
|
||||
};
|
||||
|
||||
|
||||
# The static parts of /etc.
|
||||
etc = import ../etc/default.nix {
|
||||
inherit config pkgs upstartJobs systemPath wrapperDir defaultShell;
|
||||
inherit config pkgs upstartJobs systemPath wrapperDir
|
||||
defaultShell nixEnvVars;
|
||||
extraEtc = pkgs.lib.concatLists (map (job: job.extraEtc) upstartJobs.jobs);
|
||||
};
|
||||
|
||||
# Font aggregation
|
||||
fontDir = import ./fontdir.nix {
|
||||
inherit (pkgs) stdenv;
|
||||
inherit pkgs config;
|
||||
inherit (pkgs.xorg) mkfontdir mkfontscale fontalias;
|
||||
};
|
||||
fontDir = import ./fontdir.nix {
|
||||
inherit (pkgs) stdenv;
|
||||
inherit pkgs config;
|
||||
inherit (pkgs.xorg) mkfontdir mkfontscale fontalias;
|
||||
};
|
||||
|
||||
# The wrapper setuid programs (since we can't have setuid programs
|
||||
# in the Nix store).
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{config, pkgs, nix, modprobe, nssModulesPath}:
|
||||
{config, pkgs, nix, modprobe, nssModulesPath, nixEnvVars}:
|
||||
|
||||
let
|
||||
|
||||
|
@ -79,8 +79,7 @@ import ../upstart-jobs/gather.nix {
|
|||
|
||||
# Nix daemon - required for multi-user Nix.
|
||||
(import ../upstart-jobs/nix-daemon.nix {
|
||||
inherit nix;
|
||||
inherit (pkgs) openssl;
|
||||
inherit config pkgs nix nixEnvVars;
|
||||
})
|
||||
|
||||
# Cron daemon.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{nix, openssl}:
|
||||
{config, pkgs, nix, nixEnvVars}:
|
||||
|
||||
{
|
||||
name = "nix-daemon";
|
||||
|
@ -6,11 +6,11 @@
|
|||
job = "
|
||||
start on startup
|
||||
stop on shutdown
|
||||
env NIX_CONF_DIR=/nix/etc/nix
|
||||
respawn
|
||||
script
|
||||
export PATH=${openssl}/bin:$PATH
|
||||
exec ${nix}/bin/nix-worker --daemon > /dev/null 2>&1
|
||||
export PATH=${if config.nix.distributedBuilds then "${pkgs.openssh}/bin:" else ""}${pkgs.openssl}/bin:${nix}/bin:$PATH
|
||||
${nixEnvVars}
|
||||
exec ${nix}/bin/nix-worker --daemon > /dev/null 2>&1
|
||||
end script
|
||||
";
|
||||
|
||||
|
|
Loading…
Reference in New Issue