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 = {
enable = true;
configFile = pkgs.substituteAll {
src = ./Caddyfile;
configFile = pkgs.replaceVars ./Caddyfile {
robots = toString ../tyo0/robots.txt;
inherit (pkgs) mastodon;
};

View file

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

View file

@ -37,24 +37,13 @@
"clash/proxy-providers/spcloud" = {};
};
# why not substituteAll? see https://github.com/NixOS/nixpkgs/issues/237216
sops.templates."clash.yaml".file = let
substituteAll' = {src, ...} @ args: let
args' = lib.removeAttrs args ["src"];
in
pkgs.substitute {
inherit src;
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"
;
};
sops.templates."clash.yaml".file = pkgs.replaceVars ./config.yaml {
inherit
(config.sops.placeholder)
"clash/secret"
"clash/proxies/lightsail"
"clash/proxy-providers/efcloud"
"clash/proxy-providers/spcloud"
;
};
}