|
|
|
@ -1,14 +1,28 @@
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
{ nodes, config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
cfg = config.bagel.services.hydra;
|
|
|
|
|
ssh-keys = import ../../common/ssh-keys.nix;
|
|
|
|
|
|
|
|
|
|
narCacheDir = "/var/cache/hydra/nar-cache";
|
|
|
|
|
port = 3000;
|
|
|
|
|
|
|
|
|
|
mkCacheSettings = settings: builtins.concatStringsSep "&" (
|
|
|
|
|
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}";
|
|
|
|
|
|
|
|
|
|
# TODO:
|
|
|
|
|
# - generalize to new architectures
|
|
|
|
|
# - generalize to new features
|
|
|
|
|
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};
|
|
|
|
|
host = nodes.${n}.config.networking.fqdn;
|
|
|
|
|
}) cfg.builders);
|
|
|
|
|
in {
|
|
|
|
|
options.bagel.services.hydra = with lib; {
|
|
|
|
|
enable = mkEnableOption "Hydra coordinator";
|
|
|
|
@ -17,9 +31,19 @@ in {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "DBI connection string for the Hydra postgres database";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
builders = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
description = "List of builders to configure for Hydra";
|
|
|
|
|
example = [ "builder-0" "builder-1" ];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
|
# TODO: we should assert or warn that the builders
|
|
|
|
|
# does indeed have our public SSH key and are *builders*
|
|
|
|
|
# as a simple evaluation preflight check.
|
|
|
|
|
|
|
|
|
|
age.secrets.hydra-s3-credentials.file = ../../secrets/hydra-s3-credentials.age;
|
|
|
|
|
|
|
|
|
|
age.secrets.hydra-ssh-key-priv.owner = "hydra-queue-runner";
|
|
|
|
@ -54,7 +78,8 @@ in {
|
|
|
|
|
buildMachinesFiles = [
|
|
|
|
|
(pkgs.writeText "hydra-builders.conf" ''
|
|
|
|
|
ssh://bagel-builder@epyc.infra.newtype.fr i686-linux,x86_64-linux ${config.age.secrets.hydra-ssh-key-priv.path} 8 1 big-parallel,kvm,nixos-test - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSU9YVDlJbml0MU1oS3Q0cmpCQU5McTB0MGJQd3cvV1FaOTZ1QjRBRURybWwgcm9vdEBuaXhvcwo=
|
|
|
|
|
'')
|
|
|
|
|
${baremetalBuilders}
|
|
|
|
|
'')
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
|