* 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:
parent
bd6fbce0f3
commit
70a10c1720
@ -2,14 +2,19 @@
|
|||||||
|
|
||||||
with pkgs.lib;
|
with pkgs.lib;
|
||||||
|
|
||||||
###### interface
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
inherit (config.environment) nix;
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
environment = {
|
environment.nix = mkOption {
|
||||||
|
|
||||||
nix = mkOption {
|
|
||||||
default = pkgs.nixUnstable;
|
default = pkgs.nixUnstable;
|
||||||
example = pkgs.nixCustomFun /root/nix.tar.gz;
|
example = pkgs.nixCustomFun /root/nix.tar.gz;
|
||||||
merge = mergeOneOption;
|
merge = mergeOneOption;
|
||||||
@ -18,8 +23,6 @@ let
|
|||||||
";
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
nix = {
|
nix = {
|
||||||
|
|
||||||
maxJobs = mkOption {
|
maxJobs = mkOption {
|
||||||
@ -119,61 +122,23 @@ let
|
|||||||
example = "http://127.0.0.1:3128";
|
example = "http://127.0.0.1:3128";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Environment variables for running Nix.
|
# Environment variables for running Nix. !!! Misnomer - it's
|
||||||
# !!! Fix description.
|
# actually a shell script.
|
||||||
envVars = mkOption {
|
envVars = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
default = "";
|
default = "";
|
||||||
description = "
|
|
||||||
Define the environment variables used by nix to
|
|
||||||
";
|
|
||||||
|
|
||||||
merge = pkgs.lib.mergeStringOption;
|
merge = pkgs.lib.mergeStringOption;
|
||||||
|
description = "
|
||||||
# other option should be used to define the content instead of using
|
Environment variables used by Nix.
|
||||||
# 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;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
let
|
config = {
|
||||||
inherit (config.environment) nix;
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
require = [
|
|
||||||
options
|
|
||||||
];
|
|
||||||
|
|
||||||
environment.etc =
|
environment.etc =
|
||||||
[ { # Nix configuration.
|
[ { # Nix configuration.
|
||||||
@ -214,7 +179,11 @@ in
|
|||||||
# by build-remote.pl.
|
# by build-remote.pl.
|
||||||
source = pkgs.writeText "nix.machines"
|
source = pkgs.writeText "nix.machines"
|
||||||
(pkgs.lib.concatStrings (map (machine:
|
(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));
|
) config.nix.buildMachines));
|
||||||
target = "nix.machines";
|
target = "nix.machines";
|
||||||
};
|
};
|
||||||
@ -250,4 +219,29 @@ in
|
|||||||
export NIX_REMOTE=
|
export NIX_REMOTE=
|
||||||
fi
|
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}
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user