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,18 +37,7 @@
"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
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 inherit
(config.sops.placeholder) (config.sops.placeholder)
"clash/secret" "clash/secret"