diff --git a/hosts/VEGAS/services/nix/binary-cache.nix b/cluster/services/attic/binary-cache.nix similarity index 62% rename from hosts/VEGAS/services/nix/binary-cache.nix rename to cluster/services/attic/binary-cache.nix index bfc572c..b4be382 100644 --- a/hosts/VEGAS/services/nix/binary-cache.nix +++ b/cluster/services/attic/binary-cache.nix @@ -8,18 +8,34 @@ let port = builtins.head (builtins.tail addrSplit); in { - services.nginx.upstreams.nar-serve.extraConfig = '' - random; - server ${config.links.nar-serve-self.tuple} fail_timeout=0; - server ${config.links.nar-serve-nixos-org.tuple} fail_timeout=0; - ''; + services.nginx.upstreams = { + nar-serve.extraConfig = '' + random; + server ${config.links.nar-serve-self.tuple} fail_timeout=0; + server ${config.links.nar-serve-nixos-org.tuple} fail_timeout=0; + ''; + nix-store.servers = { + "${config.links.atticServer.tuple}" = { + fail_timeout = 0; + }; + "${host}:${port}" = { + fail_timeout = 0; + backup = true; + }; + }; + }; services.nginx.appendHttpConfig = '' proxy_cache_path /var/cache/nginx/nixstore levels=1:2 keys_zone=nixstore:10m max_size=10g inactive=24h use_temp_path=off; ''; services.nginx.virtualHosts."cache.${tools.meta.domain}" = vhosts.basic // { locations = { "= /".return = "302 /404"; - "/".proxyPass = "http://${host}:${port}/nix-store$request_uri"; + "/" = { + proxyPass = "http://nix-store/nix-store$request_uri"; + extraConfig = '' + proxy_next_upstream error http_500 http_404; + ''; + }; "/nix/store" = { proxyPass = "http://nar-serve"; extraConfig = '' diff --git a/cluster/services/attic/default.nix b/cluster/services/attic/default.nix index 14dcbaf..204581d 100644 --- a/cluster/services/attic/default.nix +++ b/cluster/services/attic/default.nix @@ -4,7 +4,11 @@ server = [ "VEGAS" ]; }; nixos = { - server = ./server.nix; + server = [ + ./server.nix + ./binary-cache.nix + ./nar-serve.nix + ]; }; }; } diff --git a/hosts/VEGAS/services/nix/nar-serve.nix b/cluster/services/attic/nar-serve.nix similarity index 100% rename from hosts/VEGAS/services/nix/nar-serve.nix rename to cluster/services/attic/nar-serve.nix diff --git a/hosts/VEGAS/system.nix b/hosts/VEGAS/system.nix index 6d47d8a..1676881 100644 --- a/hosts/VEGAS/system.nix +++ b/hosts/VEGAS/system.nix @@ -24,8 +24,6 @@ ./services/jokes ./services/mail ./services/minecraft - ./services/nix/binary-cache.nix - ./services/nix/nar-serve.nix ./services/reflex ./services/sso ./services/vault