hydra: output machine host key as base64 in the generated machines.conf

This commit is contained in:
Pierre Bourdon 2024-07-10 02:16:45 +02:00
parent f214da9228
commit f2c2bc5ab6
Signed by untrusted user: delroth
GPG key ID: 6FB80DCD84DA0F1C

View file

@ -11,13 +11,15 @@ let
lib.mapAttrsToList (k: v: "${k}=${v}") settings
);
mkBaremetalBuilder = { nrCores, publicHostKey, host, speedFactor ? 1, user ? "builder", supportedSystems ? [ "i686-linux" "x86_64-linux" ], supportedFeatures ? [ "big-parallel" "kvm" "nixos-test" ] }:
"ssh://${user}@${host} ${lib.concatStringsSep "," supportedSystems} ${config.age.secrets.hydra-ssh-key-priv.path} ${toString nrCores} ${toString speedFactor} ${lib.concatStringsSep "," supportedFeatures} - ${publicHostKey}";
# XXX: to support Nix's dumb public host key syntax (base64'd), this outputs
# a string with shell-style command interpolations: $(...).
mkBaremetalBuilder = { nrCores, publicHostKey, host, speedFactor ? 1, user ? "builder", supportedSystems ? [ "i686-linux" "x86_64-linux" ], supportedFeatures ? [ "big-parallel" "kvm" "nixos-test" ] }:
"ssh://${user}@${host} ${lib.concatStringsSep "," supportedSystems} ${config.age.secrets.hydra-ssh-key-priv.path} ${toString nrCores} ${toString speedFactor} ${lib.concatStringsSep "," supportedFeatures} - $(echo -n '${publicHostKey}' | base64 -w0)";
# TODO:
# - generalize to new architectures
# - generalize to new features
baremetalBuilders = lib.concatStringsSep "\n"
baremetalBuilders = lib.concatStringsSep "\n"
(map (n: mkBaremetalBuilder {
nrCores = 40; # TODO: do not hardcode this, use the node's builder configuration.
publicHostKey = ssh-keys.machines.${n};
@ -76,7 +78,11 @@ in {
package = pkgs.hydra;
buildMachinesFiles = [
(pkgs.writeText "hydra-builders.conf" baremetalBuilders)
(pkgs.runCommandNoCC "hydra-builders.conf" {} ''
cat >$out <<EOF
${baremetalBuilders}
EOF
'')
];
extraConfig = ''