From a5812ff83c0d5e8b5af40cf188929a5a393d77c6 Mon Sep 17 00:00:00 2001 From: Ethan Turkeltaub Date: Wed, 22 Nov 2023 18:05:13 -0500 Subject: [PATCH 1/6] Add `nix.linux-builder.systems` option to set corresponding `nix.buildMachines.*.systems` option --- modules/nix/linux-builder.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/nix/linux-builder.nix b/modules/nix/linux-builder.nix index da8d791..b5ba019 100644 --- a/modules/nix/linux-builder.nix +++ b/modules/nix/linux-builder.nix @@ -57,6 +57,22 @@ in ''; }; + systems = mkOption { + type = types.listOf types.str; + default = [ ]; + example = literalExpression '' + [ + "x86_64-linux" + "aarch64-linux" + ] + ''; + description = '' + This option specifies system types the build machine can execute derivations on. + + This sets the corresponding `nix.buildMachines.*.systems` option. + ''; + }; + maxJobs = mkOption { type = types.ints.positive; default = 1; @@ -122,7 +138,7 @@ in sshKey = "/etc/nix/builder_ed25519"; system = "${stdenv.hostPlatform.uname.processor}-linux"; publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo="; - inherit (cfg) maxJobs supportedFeatures; + inherit (cfg) maxJobs supportedFeatures systems; }]; nix.settings.builders-use-substitutes = true; From 6a3a683d4351e68d746a5aea6953395cedf921bf Mon Sep 17 00:00:00 2001 From: Ethan Turkeltaub Date: Wed, 22 Nov 2023 18:13:01 -0500 Subject: [PATCH 2/6] Use `nix.buildMachines.*.systems` instead of `nix.buildMachines.*.system` --- modules/nix/linux-builder.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/nix/linux-builder.nix b/modules/nix/linux-builder.nix index b5ba019..d09a1cd 100644 --- a/modules/nix/linux-builder.nix +++ b/modules/nix/linux-builder.nix @@ -136,9 +136,9 @@ in hostName = "linux-builder"; sshUser = "builder"; sshKey = "/etc/nix/builder_ed25519"; - system = "${stdenv.hostPlatform.uname.processor}-linux"; + systems = [ "${stdenv.hostPlatform.uname.processor}-linux" ] ++ cfg.systems; publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo="; - inherit (cfg) maxJobs supportedFeatures systems; + inherit (cfg) maxJobs supportedFeatures; }]; nix.settings.builders-use-substitutes = true; From 72dd60bfc98c128149d84213b17d1b8a68863055 Mon Sep 17 00:00:00 2001 From: Ethan Turkeltaub Date: Wed, 22 Nov 2023 20:40:03 -0500 Subject: [PATCH 3/6] Add default system to `systems` option --- modules/nix/linux-builder.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/nix/linux-builder.nix b/modules/nix/linux-builder.nix index d09a1cd..2fdcb4a 100644 --- a/modules/nix/linux-builder.nix +++ b/modules/nix/linux-builder.nix @@ -59,14 +59,14 @@ in systems = mkOption { type = types.listOf types.str; - default = [ ]; + default = [ "${stdenv.hostPlatform.uname.processor}-linux" ]; example = literalExpression '' [ "x86_64-linux" "aarch64-linux" ] ''; - description = '' + description = lib.mdDoc '' This option specifies system types the build machine can execute derivations on. This sets the corresponding `nix.buildMachines.*.systems` option. @@ -136,9 +136,8 @@ in hostName = "linux-builder"; sshUser = "builder"; sshKey = "/etc/nix/builder_ed25519"; - systems = [ "${stdenv.hostPlatform.uname.processor}-linux" ] ++ cfg.systems; publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo="; - inherit (cfg) maxJobs supportedFeatures; + inherit (cfg) maxJobs supportedFeatures systems; }]; nix.settings.builders-use-substitutes = true; From 94558e7e8b3acb1ac8fe2b65042b49b488fe0678 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sun, 18 Feb 2024 13:25:01 +0100 Subject: [PATCH 4/6] linux-builder: Pass through more options to nix.buildMachines This commit passes more options to nix.buildMachines. Namely the mandatoryFeatures and speedFactor settings have been missing. --- modules/nix/linux-builder.nix | 38 ++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/modules/nix/linux-builder.nix b/modules/nix/linux-builder.nix index d487800..b71ae56 100644 --- a/modules/nix/linux-builder.nix +++ b/modules/nix/linux-builder.nix @@ -65,17 +65,49 @@ in default = 1; example = 4; description = lib.mdDoc '' - This option specifies the maximum number of jobs to run on the Linux builder at once. + The number of concurrent jobs the Linux builder 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. This sets the corresponding `nix.buildMachines.*.maxJobs` option. ''; }; + speedFactor = mkOption { + type = types.ints.positive; + default = 1; + description = lib.mdDoc '' + The relative speed of the Linux builder. This is an arbitrary integer + that indicates the speed of this builder, relative to other + builders. Higher is faster. + + This sets the corresponding `nix.buildMachines.*.speedFactor` option. + ''; + }; + + mandatoryFeatures = mkOption { + type = types.listOf types.str; + default = []; + example = [ "big-parallel" ]; + description = lib.mdDoc '' + A list of features mandatory for the Linux builder. The builder will + be ignored for derivations that don't require all features in + this list. All mandatory features are automatically included in + {var}`supportedFeatures`. + + This sets the corresponding `nix.buildMachines.*.mandatoryFeatures` option. + ''; + }; + supportedFeatures = mkOption { type = types.listOf types.str; default = [ "kvm" "benchmark" "big-parallel" ]; + example = [ "kvm" "big-parallel" ]; description = lib.mdDoc '' - This option specifies the list of features supported by the Linux builder. + A list of features supported by the Linux builder. The builder will + be ignored for derivations that require features not in this + list. This sets the corresponding `nix.buildMachines.*.supportedFeatures` option. ''; @@ -141,7 +173,7 @@ in sshKey = "/etc/nix/builder_ed25519"; system = "${stdenv.hostPlatform.uname.processor}-linux"; publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo="; - inherit (cfg) maxJobs supportedFeatures; + inherit (cfg) maxJobs speedFactor mandatoryFeatures supportedFeatures; }]; nix.settings.builders-use-substitutes = true; From 61c5879b5a326874f6be7c8c9a4c377b693098f4 Mon Sep 17 00:00:00 2001 From: Logan Barnett Date: Tue, 20 Feb 2024 13:10:24 -0800 Subject: [PATCH 5/6] linux-builder: default pass through protocol to nix.buildMachines This commit adds a protocol option for the `linux-builder` and defaults it to `ssh-ng`. I have observed it needing this with the following: ``` sh $ nix store ping --store ssh://linux-builder Store URL: ssh://linux-builder $ nix store ping --store ssh-ng://linux-builder Store URL: ssh-ng://linux-builder Version: 2.18.1 Trusted: 0 ``` This seems to make the difference on whether or not Nix picks up `linux-builder` as an available builder. --- modules/nix/linux-builder.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/nix/linux-builder.nix b/modules/nix/linux-builder.nix index d487800..f13caef 100644 --- a/modules/nix/linux-builder.nix +++ b/modules/nix/linux-builder.nix @@ -71,6 +71,20 @@ in ''; }; + protocol = mkOption { + type = types.str; + default = "ssh-ng"; + example = "ssh"; + description = lib.mdDoc '' + The protocol used for communicating with the build machine. Use + `ssh-ng` if your remote builder and your local Nix version support that + improved protocol. + + Use `null` when trying to change the special localhost builder without a + protocol which is for example used by hydra. + ''; + }; + supportedFeatures = mkOption { type = types.listOf types.str; default = [ "kvm" "benchmark" "big-parallel" ]; @@ -141,7 +155,7 @@ in sshKey = "/etc/nix/builder_ed25519"; system = "${stdenv.hostPlatform.uname.processor}-linux"; publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo="; - inherit (cfg) maxJobs supportedFeatures; + inherit (cfg) maxJobs protocol supportedFeatures; }]; nix.settings.builders-use-substitutes = true; From 27e6a022f25b94010fdb8e5fbbb79608dc589397 Mon Sep 17 00:00:00 2001 From: Logan Barnett Date: Wed, 21 Feb 2024 10:34:16 -0800 Subject: [PATCH 6/6] apply feedback, fix merge goof --- modules/nix/linux-builder.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/nix/linux-builder.nix b/modules/nix/linux-builder.nix index edd6e0e..ecaf686 100644 --- a/modules/nix/linux-builder.nix +++ b/modules/nix/linux-builder.nix @@ -63,7 +63,8 @@ in mandatoryFeatures = mkOption { type = types.listOf types.str; default = []; - example = [ "big-parallel" ]; + defaultText = literalExpression ''[]''; + example = literalExpression ''[ "big-parallel" ]''; description = lib.mdDoc '' A list of features mandatory for the Linux builder. The builder will be ignored for derivations that don't require all features in @@ -71,7 +72,8 @@ in {var}`supportedFeatures`. This sets the corresponding `nix.buildMachines.*.mandatoryFeatures` option. - ''; + ''; + }; maxJobs = mkOption { type = types.ints.positive; @@ -90,7 +92,8 @@ in protocol = mkOption { type = types.str; default = "ssh-ng"; - example = "ssh"; + defaultText = literalExpression ''"ssh-ng"''; + example = literalExpression ''"ssh"''; description = lib.mdDoc '' The protocol used for communicating with the build machine. Use `ssh-ng` if your remote builder and your local Nix version support that @@ -104,6 +107,7 @@ in speedFactor = mkOption { type = types.ints.positive; default = 1; + defaultText = literalExpression ''1''; description = lib.mdDoc '' The relative speed of the Linux builder. This is an arbitrary integer that indicates the speed of this builder, relative to other @@ -116,7 +120,8 @@ in supportedFeatures = mkOption { type = types.listOf types.str; default = [ "kvm" "benchmark" "big-parallel" ]; - example = [ "kvm" "big-parallel" ]; + defaultText = literalExpression ''[ "kvm" "benchmark" "big-parallel" ]''; + example = literalExpression ''[ "kvm" "big-parallel" ]''; description = lib.mdDoc '' A list of features supported by the Linux builder. The builder will be ignored for derivations that require features not in this @@ -129,6 +134,7 @@ in systems = mkOption { type = types.listOf types.str; default = [ "${stdenv.hostPlatform.uname.processor}-linux" ]; + defaultText = literalExpression ''[ "''${stdenv.hostPlatform.uname.processor}-linux" ]''; example = literalExpression '' [ "x86_64-linux"