diff --git a/devices/cluster/modules/caddy.nix b/devices/cluster/modules/caddy.nix index 24cda059..507e0f41 100644 --- a/devices/cluster/modules/caddy.nix +++ b/devices/cluster/modules/caddy.nix @@ -86,6 +86,7 @@ in { "Immich" = mkPublicReverseProxy "photos" "${nosIP}:2283" {}; "Binary Cache" = mkPublicReverseProxy "cache" "${serviviIP}:5000" {}; + "Apt Binary Cache" = mkPublicReverseProxy "cache-apt" "${homieIP}:5000" {}; # Private "nelim.org" = { diff --git a/devices/homie/modules/binary-cache.nix b/devices/homie/modules/binary-cache.nix new file mode 100644 index 00000000..eb6bc6b4 --- /dev/null +++ b/devices/homie/modules/binary-cache.nix @@ -0,0 +1,34 @@ +{ + config, + pkgs, + ... +}: let + inherit (builtins) attrValues; + inherit (config.sops) secrets; + + nixFastBuild = pkgs.writeShellApplication { + name = "nixFastBuild"; + + runtimeInputs = attrValues { + inherit + (pkgs) + gnugrep + nix-fast-build + nix-output-monitor + ; + }; + + text = '' + cd "$FLAKE/results" || return + + nix-fast-build -f ..#nixFastChecks.${pkgs.system}.aptDevices "$@" + ''; + }; +in { + services.nix-serve = { + enable = true; + secretKeyFile = secrets.apt-binary-cache-key.path; + }; + + environment.systemPackages = [pkgs.nix-fast-build nixFastBuild]; +} diff --git a/devices/homie/modules/default.nix b/devices/homie/modules/default.nix index d8fa2972..f01b1d7a 100644 --- a/devices/homie/modules/default.nix +++ b/devices/homie/modules/default.nix @@ -1,5 +1,6 @@ {...}: { imports = [ + ./binary-cache.nix ./home-assistant ./music ]; diff --git a/devices/servivi/modules/binary-cache.nix b/devices/servivi/modules/binary-cache.nix index 924679f3..267d7a61 100644 --- a/devices/servivi/modules/binary-cache.nix +++ b/devices/servivi/modules/binary-cache.nix @@ -4,7 +4,6 @@ pkgs, ... }: let - # FIXME: add binary cache at apartment inherit (builtins) attrValues; inherit (config.sops) secrets; diff --git a/flake.lock b/flake.lock index 2a162e2b..1bf3b55e 100644 Binary files a/flake.lock and b/flake.lock differ diff --git a/nixosModules/base/substituters/default.nix b/nixosModules/base/substituters/default.nix index fbc50c95..1e389611 100644 --- a/nixosModules/base/substituters/default.nix +++ b/nixosModules/base/substituters/default.nix @@ -4,7 +4,7 @@ pkgs, ... }: let - inherit (lib) foldl isList mergeAttrsWithFunc mkIf optionals unique; + inherit (lib) elem foldl isList mergeAttrsWithFunc mkIf optionals unique; cfg = config.roles.base; @@ -42,8 +42,11 @@ in (mkSubstituterConf "https://viperml.cachix.org" "viperml.cachix.org-1:qZhKBMTfmcLL+OG6fj/hzsMEedgKvZVFRRAhq7j8Vh8=") (mkSubstituterConf "https://cuda-maintainers.cachix.org" "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=") ] - ++ optionals (!config.services.nix-serve.enable) [ + ++ optionals (config.networking.hostName != "servivi") [ (mkSubstituterConf "https://cache.nelim.org" "cache.nelim.org:JmFqkUdH11EA9EZOFAGVHuRYp7EbsdJDHvTQzG2pPyY=") + ] + ++ optionals (elem config.networking.hostName ["bbsteamie" "binto" "wim"]) [ + (mkSubstituterConf "https://cache-apt.nelim.org" "cache-apt.nelim.org:NLAsWxa2Qbm4b+hHimjCpZfm48a4oN4O/GPZY9qpjNw=") ]); }; }