Merge pull request #83104 from Valodim/distbuild-module

nixos/nix-daemon: Organize buildMachine options with a submodule
This commit is contained in:
John Ericson 2020-07-05 11:23:39 -04:00 committed by GitHub
commit c09dd3be0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 115 additions and 48 deletions

View File

@ -682,6 +682,12 @@ systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/www" ];
behaviour and keep the same VM state between different test runs. behaviour and keep the same VM state between different test runs.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
The <link linkend="opt-nix.buildMachine">nix.buildMachine</link> option is now type-checked.
There are no functional changes, however this may require updating some configurations to use correct types for all attributes.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</section> </section>
</section> </section>

View File

@ -193,50 +193,111 @@ in
}; };
buildMachines = mkOption { buildMachines = mkOption {
type = types.listOf types.attrs; type = types.listOf (types.submodule ({
default = []; options = {
example = literalExample '' hostName = mkOption {
[ { hostName = "voila.labs.cs.uu.nl"; type = types.str;
sshUser = "nix"; example = "nixbuilder.example.org";
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;
speedFactor = 2;
supportedFeatures = [ "kvm" ];
mandatoryFeatures = [ "perf" ];
}
]
'';
description = '' description = ''
This option lists the machines to be used if distributed The hostname of the build machine.
builds are enabled (see '';
<option>nix.distributedBuilds</option>). Nix will perform };
derivations on those machines via SSH by copying the inputs system = mkOption {
to the Nix store on the remote machine, starting the build, type = types.nullOr types.str;
then copying the output back to the local Nix store. Each default = null;
element of the list should be an attribute set containing example = "x86_64-linux";
the machine's host name (<varname>hostname</varname>), the description = ''
user name to be used for the SSH connection The system type the build machine can execute derivations on.
(<varname>sshUser</varname>), the Nix system type Either this attribute or <varname>systems</varname> must be
(<varname>system</varname>, e.g., present, where <varname>system</varname> takes precedence if
<literal>"i686-linux"</literal>), the maximum number of both are set.
jobs to be run in parallel on that machine '';
(<varname>maxJobs</varname>), the path to the SSH private };
key to be used to connect (<varname>sshKey</varname>), a systems = mkOption {
list of supported features of the machine type = types.listOf types.str;
(<varname>supportedFeatures</varname>) and a list of default = [];
mandatory features of the machine example = [ "x86_64-linux" "aarch64-linux" ];
(<varname>mandatoryFeatures</varname>). The SSH private key description = ''
should not have a passphrase, and the corresponding public The system types the build machine can execute derivations on.
key should be added to Either this attribute or <varname>system</varname> must be
<filename>~<replaceable>sshUser</replaceable>/authorized_keys</filename> present, where <varname>system</varname> takes precedence if
on the remote machine. both are set.
'';
};
sshUser = mkOption {
type = types.nullOr types.str;
default = null;
example = "builder";
description = ''
The username to log in as on the remote host. This user must be
able to log in and run nix commands non-interactively. It must
also be privileged to build derivations, so must be included in
<option>nix.trustedUsers</option>.
'';
};
sshKey = mkOption {
type = types.nullOr types.str;
default = null;
example = "/root/.ssh/id_buildhost_builduser";
description = ''
The path to the SSH private key with which to authenticate on
the build machine. The private key must not have a passphrase.
If null, the building user (root on NixOS machines) must have an
appropriate ssh configuration to log in non-interactively.
Note that for security reasons, this path must point to a file
in the local filesystem, *not* to the nix store.
'';
};
maxJobs = mkOption {
type = types.int;
default = 1;
description = ''
The number of concurrent jobs the build machine supports. The
build machine will enforce its own limits, but this allows hydra
to schedule better since there is no work-stealing between build
machines.
'';
};
speedFactor = mkOption {
type = types.int;
default = 1;
description = ''
The relative speed of this builder. This is an arbitrary integer
that indicates the speed of this builder, relative to other
builders. Higher is faster.
'';
};
mandatoryFeatures = mkOption {
type = types.listOf types.str;
default = [];
example = [ "big-parallel" ];
description = ''
A list of features mandatory for this builder. The builder will
be ignored for derivations that don't require all features in
this list. All mandatory features are automatically included in
<varname>supportedFeatures</varname>.
'';
};
supportedFeatures = mkOption {
type = types.listOf types.str;
default = [];
example = [ "kvm" "big-parallel" ];
description = ''
A list of features supported by this builder. The builder will
be ignored for derivations that require features not in this
list.
'';
};
};
}));
default = [];
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.
''; '';
}; };
@ -461,14 +522,14 @@ in
{ enable = cfg.buildMachines != []; { enable = cfg.buildMachines != [];
text = text =
concatMapStrings (machine: concatMapStrings (machine:
"${if machine ? sshUser then "${machine.sshUser}@" else ""}${machine.hostName} " "${if machine.sshUser != null then "${machine.sshUser}@" else ""}${machine.hostName} "
+ machine.system or (concatStringsSep "," machine.systems) + (if machine.system != null then machine.system else concatStringsSep "," machine.systems)
+ " ${machine.sshKey or "-"} ${toString machine.maxJobs or 1} " + " ${if machine.sshKey != null then machine.sshKey else "-"} ${toString machine.maxJobs} "
+ toString (machine.speedFactor or 1) + toString (machine.speedFactor)
+ " " + " "
+ concatStringsSep "," (machine.mandatoryFeatures or [] ++ machine.supportedFeatures or []) + concatStringsSep "," (machine.mandatoryFeatures ++ machine.supportedFeatures)
+ " " + " "
+ concatStringsSep "," machine.mandatoryFeatures or [] + concatStringsSep "," machine.mandatoryFeatures
+ "\n" + "\n"
) cfg.buildMachines; ) cfg.buildMachines;
}; };