From a203683694dab21acb2072818c9ba2ff509f9c86 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sun, 26 Jan 2020 12:39:16 +0100 Subject: [PATCH] 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. --- lib/default.nix | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 906c8a33..f465791d 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -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 ];