fixup! nixos/mihomo: use substitute rather than readFile

https://github.com/NixOS/nixpkgs/issues/237216
This commit is contained in:
Guanran Wang 2024-06-16 11:30:38 +08:00
parent 1a904288a8
commit 0be980e763
Signed by: nyancat
GPG key ID: 91F97D9ED12639CF
2 changed files with 23 additions and 16 deletions

View file

@ -49,19 +49,13 @@ proxy-providers:
# Free servers that I dont really care about # Free servers that I dont really care about
ermaozi: ermaozi:
<<: *fetch <<: *fetch
url: > url: "@ermaozi@"
*convert
https://cdn.jsdelivr.net/gh/ermaozi/get_subscribe@main/subscribe/v2ray.txt
jsnzkpg: jsnzkpg:
<<: *fetch <<: *fetch
url: > url: "@jsnzkpg@"
*convert
https://cdn.jsdelivr.net/gh/Jsnzkpg/Jsnzkpg@Jsnzkpg/Jsnzkpg
pawdroid: pawdroid:
<<: *fetch <<: *fetch
url: > url: "@pawdroid"
*convert
https://cdn.jsdelivr.net/gh/Pawdroid/Free-servers@main/sub
proxy-groups: proxy-groups:
- { - {

View file

@ -34,17 +34,30 @@
}; };
# why not substituteAll? see https://github.com/NixOS/nixpkgs/issues/237216 # why not substituteAll? see https://github.com/NixOS/nixpkgs/issues/237216
sops.templates."clash.yaml".file = pkgs.substitute { sops.templates."clash.yaml".file = let
src = ./config.yaml; convert = url: "https://sub.maoxiongnet.com/sub?target=clash&list=true&url=${url}";
replacements = let substituteV2 = {src, ...} @ args: let
inherit' = list: lib.flatten (map (attr: ["--subst-var-by" attr config.sops.placeholder.${attr}]) list); args' = builtins.removeAttrs args ["src"];
in in
inherit' [ pkgs.substitute {
inherit src;
substitutions = lib.flatten (lib.mapAttrsToList (n: v: ["--subst-var-by" n v]) args');
};
in
substituteV2 {
src = ./config.yaml;
inherit
(config.sops.placeholder)
"clash/secret" "clash/secret"
"clash/proxies/lightsail" "clash/proxies/lightsail"
"clash/proxy-providers/efcloud" "clash/proxy-providers/efcloud"
"clash/proxy-providers/flyairport" "clash/proxy-providers/flyairport"
"clash/proxy-providers/spcloud" "clash/proxy-providers/spcloud"
]; ;
};
# Free servers that I dont really care about
pawdroid = convert "https://cdn.jsdelivr.net/gh/Pawdroid/Free-servers@main/sub";
ermaozi = convert "https://cdn.jsdelivr.net/gh/ermaozi/get_subscribe@main/subscribe/v2ray.txt";
jsnzkpg = convert "https://cdn.jsdelivr.net/gh/Jsnzkpg/Jsnzkpg@Jsnzkpg/Jsnzkpg";
};
} }