treewide: use replaceVars

This commit is contained in:
Guanran Wang 2024-08-19 22:45:31 +08:00
parent c1920e0036
commit 7ab4a7ba9e
Signed by: nyancat
GPG key ID: 91F97D9ED12639CF
3 changed files with 11 additions and 27 deletions

View file

@ -72,8 +72,7 @@
services.caddy = { services.caddy = {
enable = true; enable = true;
configFile = pkgs.substituteAll { configFile = pkgs.replaceVars ./Caddyfile {
src = ./Caddyfile;
robots = toString ../tyo0/robots.txt; robots = toString ../tyo0/robots.txt;
inherit (pkgs) mastodon; inherit (pkgs) mastodon;
}; };

View file

@ -67,9 +67,7 @@
services.caddy = { services.caddy = {
enable = true; enable = true;
configFile = pkgs.substituteAll { configFile = pkgs.replaceVars ./Caddyfile {
src = ./Caddyfile;
"element" = pkgs.element-web.override { "element" = pkgs.element-web.override {
element-web-unwrapped = pkgs.element-web-unwrapped.overrideAttrs (oldAttrs: { element-web-unwrapped = pkgs.element-web-unwrapped.overrideAttrs (oldAttrs: {
version = "1.11.74-rc.0"; version = "1.11.74-rc.0";
@ -93,8 +91,6 @@
homeserverList = ["ny4.dev"]; homeserverList = ["ny4.dev"];
}; };
}; };
"mastodon" = pkgs.mastodon;
}; };
}; };

View file

@ -37,24 +37,13 @@
"clash/proxy-providers/spcloud" = {}; "clash/proxy-providers/spcloud" = {};
}; };
# why not substituteAll? see https://github.com/NixOS/nixpkgs/issues/237216 sops.templates."clash.yaml".file = pkgs.replaceVars ./config.yaml {
sops.templates."clash.yaml".file = let inherit
substituteAll' = {src, ...} @ args: let (config.sops.placeholder)
args' = lib.removeAttrs args ["src"]; "clash/secret"
in "clash/proxies/lightsail"
pkgs.substitute { "clash/proxy-providers/efcloud"
inherit src; "clash/proxy-providers/spcloud"
substitutions = lib.flatten (lib.mapAttrsToList (n: v: ["--subst-var-by" n v]) args'); ;
}; };
in
substituteAll' {
src = ./config.yaml;
inherit
(config.sops.placeholder)
"clash/secret"
"clash/proxies/lightsail"
"clash/proxy-providers/efcloud"
"clash/proxy-providers/spcloud"
;
};
} }