Remove hydra cache, add enableBinaryCache to hq module

The Hydra is dead, NixOS machines cannot rely on services hosted from the
Proxmox. Add a enableBinaryCache option to the hq module to enable caching
from Server7.
This commit is contained in:
Emery Hemingway 2020-01-26 12:39:16 +01:00
parent 76145d112d
commit a203683694
1 changed files with 32 additions and 9 deletions

View File

@ -91,6 +91,14 @@ in {
statistics = { enable = mkEnableOption "statistics collection"; };
enableBinaryCache = mkOption {
type = bool;
default = cfg.isInHq;
defaultText = literalExample "config.c3d2.isInHq";
description = "Whether to enable the local Nix binary cache";
};
};
};
@ -101,15 +109,21 @@ in {
mkIfIsInHq = lib.mkIf cfg.isInHq;
in {
assertions = [{
assertion = let
check = hostName: hostName == config.networking.hostName;
checkRegistry = list: builtins.any check list;
in cfg.isInHq -> checkRegistry hostRegistry.hqLocal;
message = "${config.networking.hostName} is not registered in ${
toString ../host-registry.nix
}";
}];
assertions = [
{
assertion = let
check = hostName: hostName == config.networking.hostName;
checkRegistry = list: builtins.any check list;
in cfg.isInHq -> checkRegistry hostRegistry.hqLocal;
message = "${config.networking.hostName} is not registered in ${
toString ../host-registry.nix
}";
}
{
assertion = cfg.hq.enableBinaryCache -> cfg.mapHqHosts;
message = "mapHqHosts must be enabled for enableBinaryCache";
}
];
networking.defaultGateway = mkIfIsInHq "172.22.99.4";
@ -224,6 +238,15 @@ in {
# Only builds > 19.09
};
nix = lib.mkIf
(cfg.hq.enableBinaryCache && config.networking.hostName != "server7") {
binaryCaches =
[ "http://server7.hq:${toString config.services.nix-serve.port}" ];
binaryCachePublicKeys = [
"cache.server7.hq.c3d2.de:x8JLRG26zRZ8ysYZLEkPxuAYuK1VSJi/aMAEIs2Lv+U="
];
};
};
meta.maintainers = with lib.maintainers; [ ehmry ];