* In the generation of machines.nix, support specifying a

speed factor and multiple system types.

svn path=/nixos/trunk/; revision=17231
This commit is contained in:
Eelco Dolstra 2009-09-17 16:22:26 +00:00
parent bd6fbce0f3
commit 70a10c1720

View File

@ -2,14 +2,19 @@
with pkgs.lib;
###### interface
let
inherit (config.environment) nix;
in
{
###### interface
options = {
environment = {
nix = mkOption {
environment.nix = mkOption {
default = pkgs.nixUnstable;
example = pkgs.nixCustomFun /root/nix.tar.gz;
merge = mergeOneOption;
@ -18,8 +23,6 @@ let
";
};
};
nix = {
maxJobs = mkOption {
@ -119,61 +122,23 @@ let
example = "http://127.0.0.1:3128";
};
# Environment variables for running Nix.
# !!! Fix description.
# Environment variables for running Nix. !!! Misnomer - it's
# actually a shell script.
envVars = mkOption {
internal = true;
default = "";
description = "
Define the environment variables used by nix to
";
merge = pkgs.lib.mergeStringOption;
# other option should be used to define the content instead of using
# the apply function.
apply = conf: ''
export NIX_CONF_DIR=/nix/etc/nix
# Enable the copy-from-other-stores substituter, which allows builds
# to be sped up by copying build results from remote Nix stores. To
# do this, mount the remote file system on a subdirectory of
# /var/run/nix/remote-stores.
export NIX_OTHER_STORES=/var/run/nix/remote-stores/*/nix
'' + # */
(if config.nix.distributedBuilds then
''
export NIX_BUILD_HOOK=${config.environment.nix}/libexec/nix/build-remote.pl
export NIX_REMOTE_SYSTEMS=/etc/nix.machines
export NIX_CURRENT_LOAD=/var/run/nix/current-load
''
else "")
+
(if config.nix.proxy != "" then
''
export http_proxy=${config.nix.proxy}
export https_proxy=${config.nix.proxy}
export ftp_proxy=${config.nix.proxy}
''
else "")
+ conf;
description = "
Environment variables used by Nix.
";
};
};
};
in
###### implementation
let
inherit (config.environment) nix;
in
{
require = [
options
];
config = {
environment.etc =
[ { # Nix configuration.
@ -214,7 +179,11 @@ in
# by build-remote.pl.
source = pkgs.writeText "nix.machines"
(pkgs.lib.concatStrings (map (machine:
"${machine.sshUser}@${machine.hostName} ${machine.system} ${machine.sshKey} ${toString machine.maxJobs}\n"
"${machine.sshUser}@${machine.hostName} "
+ (if machine ? system then machine.system else concatStringsSep "," machine.systems)
+ " ${machine.sshKey} ${toString machine.maxJobs} "
+ (if machine ? speedFactor then toString machine.speedFactor else "1" )
+ "\n"
) config.nix.buildMachines));
target = "nix.machines";
};
@ -250,4 +219,29 @@ in
export NIX_REMOTE=
fi
'';
nix.envVars =
''
export NIX_CONF_DIR=/nix/etc/nix
# Enable the copy-from-other-stores substituter, which allows builds
# to be sped up by copying build results from remote Nix stores. To
# do this, mount the remote file system on a subdirectory of
# /var/run/nix/remote-stores.
export NIX_OTHER_STORES=/var/run/nix/remote-stores/*/nix
''
+ optionalString config.nix.distributedBuilds ''
export NIX_BUILD_HOOK=${config.environment.nix}/libexec/nix/build-remote.pl
export NIX_REMOTE_SYSTEMS=/etc/nix.machines
export NIX_CURRENT_LOAD=/var/run/nix/current-load
''
# !!! These should not be defined here, but in some general proxy configuration module!
+ optionalString (config.nix.proxy != "") ''
export http_proxy=${config.nix.proxy}
export https_proxy=${config.nix.proxy}
export ftp_proxy=${config.nix.proxy}
'';
};
}