diff --git a/services/baremetal-builder/assignments.nix b/services/baremetal-builder/assignments.nix new file mode 100644 index 0000000..8a064d1 --- /dev/null +++ b/services/baremetal-builder/assignments.nix @@ -0,0 +1,21 @@ +# This file contains information on which builder(s) are providing how many +# job slots and providing which nix features +let + genBuilders = { offset ? 0, count, f }: builtins.genList (x: rec { name = "builder-${toString (offset + x)}"; value = f name; }) count; +in builtins.listToAttrs ( + # The first 8 builders are general purpose + genBuilders { count = 8; f = name: { + cores = 8; + max-jobs = 8; + supported-features = [ "kvm" "nixos-test" ]; + required-features = [ ]; + }; } + ++ + # The last 2 builders are exclusively for big-parallel + genBuilders { offset = 8; count = 2; f = name: { + cores = 20; + max-jobs = 1; + supported-features = [ "kvm" "nixos-test" "big-parallel" ]; + required-features = [ "big-parallel" ]; + }; } +) diff --git a/services/baremetal-builder/default.nix b/services/baremetal-builder/default.nix index 00e36cf..3fc32ca 100644 --- a/services/baremetal-builder/default.nix +++ b/services/baremetal-builder/default.nix @@ -40,8 +40,10 @@ in "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGMnOLLX0vGTZbSJrUmF9ZFXt/NIId/MUrEpXmL2vxod" ]; }; - nix.settings.trusted-users = [ "builder" "buildbot" ]; - + nix.settings = { + trusted-users = [ "builder" "buildbot" ]; + inherit ((import ./assignments.nix).${config.networking.hostName}) max-jobs cores; + }; nixpkgs.hostPlatform = "x86_64-linux"; hardware.cpu.intel.updateMicrocode = true; diff --git a/services/hydra/default.nix b/services/hydra/default.nix index b2f5a3c..608fb2c 100644 --- a/services/hydra/default.nix +++ b/services/hydra/default.nix @@ -13,15 +13,36 @@ let # XXX: to support Nix's dumb public host key syntax (base64'd), this outputs # a string with shell-style command interpolations: $(...). - mkBaremetalBuilder = { parallelBuilds, publicHostKey, host, speedFactor ? 1, user ? "builder", supportedSystems ? [ "i686-linux" "x86_64-linux" ], supportedFeatures ? [ "big-parallel" "kvm" "nixos-test" ] }: - "ssh://${user}@${host}?remote-store=/mnt ${lib.concatStringsSep "," supportedSystems} ${config.age.secrets.hydra-ssh-key-priv.path} ${toString parallelBuilds} ${toString speedFactor} ${lib.concatStringsSep "," supportedFeatures} - $(echo -n '${publicHostKey}' | base64 -w0)"; + mkBaremetalBuilder = { + parallelBuilds, + publicHostKey, + host, + speedFactor ? 1, + user ? "builder", + supportedSystems ? [ "i686-linux" "x86_64-linux" ], + supportedFeatures ? [ "big-parallel" "kvm" "nixos-test" ], + requiredFeatures ? [ ] + }: + let + supportedFeatures_ = if (supportedFeatures != []) then lib.concatStringsSep "," supportedFeatures else "-"; + requiredFeatures_ = if (requiredFeatures != []) then lib.concatStringsSep "," requiredFeatures else "-"; + in + "ssh://${user}@${host}?remote-store=/mnt ${lib.concatStringsSep "," supportedSystems} ${config.age.secrets.hydra-ssh-key-priv.path} ${toString parallelBuilds} ${toString speedFactor} ${supportedFeatures_} ${requiredFeatures_} $(echo -n '${publicHostKey}' | base64 -w0)"; # TODO: # - generalize to new architectures # - generalize to new features baremetalBuilders = lib.concatStringsSep "\n" - (map (n: mkBaremetalBuilder { - parallelBuilds = 8; # TODO: do not hardcode this, use the node's builder configuration. + (map (n: let + assignments = (import ../baremetal-builder/assignments.nix).${n} or { + inherit (nodes.${n}.config.nix.settings) max-jobs; + supported-features = [ "big-parallel" "kvm" "nixos-test" ]; + required-features = []; + }; + in mkBaremetalBuilder { + parallelBuilds = assignments.max-jobs; + supportedFeatures = assignments.supported-features; + requiredFeatures = assignments.required-features; publicHostKey = ssh-keys.machines.${n}; host = nodes.${n}.config.networking.fqdn; }) cfg.builders);