From f4c78791eaadee93771d4b092cbb26fad47a7a10 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Wed, 11 Dec 2024 12:29:24 -0500 Subject: [PATCH] feat: add binary cache at apartment --- devices/cluster/modules/caddy.nix | 1 + devices/homie/modules/binary-cache.nix | 34 +++++++++++++++++++++ devices/homie/modules/default.nix | 1 + devices/servivi/modules/binary-cache.nix | 1 - flake.lock | Bin 55624 -> 55624 bytes nixosModules/base/substituters/default.nix | 7 +++-- 6 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 devices/homie/modules/binary-cache.nix 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 2a162e2be455585fa01923e2e2832567f962aacf..1bf3b55e0ad10a585d7d4624197b5c30e56e5aa3 100644 GIT binary patch delta 128 zcmV-`0Du3;vIEGn1F&hg2QxV{H#IOglc66SD{p3bHb`wRV?so9Rc>T&M|f9ZQAulM zZE{vLWm0KFdSgyRL~B%0WMg75lMl={CpBg_W-(%6Wn?ioF=aMpGdVUlV=_1~VPiNk iV`eZoIbtv}F*i15lWoix0W^~_1{RaKxJt8+xVa!4-z%>G delta 129 zcmV-{0Dk|-vIEGn1F&hg2Qo7=G%z+blc66SD`8nOV?|;%Y-=-NIc73%c~VVba7;2{ zY)xorM_F@NMs;UvV`gM`QA9CWlMl=`C}uG^HDoq0H#agfFf}=1W;0`9GB7YWFf=ta jGd4D2W@KbEWi?@8IFoJ67y&brF$NZsxwuNRkGQ!Y{IV-6 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=") ]); }; }