2023-12-25 07:23:54 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: {
|
2024-03-22 07:09:07 +00:00
|
|
|
services.mihomo = {
|
2023-12-25 07:23:54 +00:00
|
|
|
enable = true;
|
|
|
|
configFile = config.sops.templates."clash.yaml".path;
|
2024-02-27 07:38:36 +00:00
|
|
|
webui = config.nur.repos.guanran928.metacubexd;
|
2023-12-25 07:23:54 +00:00
|
|
|
};
|
|
|
|
|
2024-03-22 07:09:07 +00:00
|
|
|
systemd.services.mihomo.serviceConfig.ExecStartPre = [
|
|
|
|
"${pkgs.coreutils}/bin/ln -sf ${pkgs.v2ray-geoip}/share/v2ray/geoip.dat /var/lib/private/mihomo/GeoIP.dat"
|
|
|
|
"${pkgs.coreutils}/bin/ln -sf ${pkgs.v2ray-domain-list-community}/share/v2ray/geosite.dat /var/lib/private/mihomo/GeoSite.dat"
|
2024-01-26 19:46:06 +00:00
|
|
|
];
|
|
|
|
|
2023-12-31 12:23:24 +00:00
|
|
|
### System proxy settings
|
|
|
|
networking.proxy.default = "http://127.0.0.1:7890/";
|
2024-03-22 07:09:07 +00:00
|
|
|
environment.shellAliases = let
|
|
|
|
inherit (config.networking) proxy;
|
|
|
|
in {
|
|
|
|
"setproxy" = "export http_proxy=${proxy.httpProxy} https_proxy=${proxy.httpsProxy} all_proxy=${proxy.allProxy} ftp_proxy=${proxy.ftpProxy} rsync_proxy=${proxy.rsyncProxy}";
|
|
|
|
"unsetproxy" = "set -e http_proxy https_proxy all_proxy ftp_proxy rsync_proxy";
|
|
|
|
};
|
2023-12-31 12:23:24 +00:00
|
|
|
|
2023-12-25 07:23:54 +00:00
|
|
|
### sops-nix
|
2024-03-22 07:09:07 +00:00
|
|
|
sops.secrets = builtins.mapAttrs (_name: value: value // {restartUnits = ["mihomo.service"];}) {
|
2023-12-31 12:23:24 +00:00
|
|
|
"clash/secret" = {};
|
2024-04-22 20:40:41 +00:00
|
|
|
"clash/proxies/lightsail" = {};
|
2024-02-13 17:51:10 +00:00
|
|
|
"clash/proxy-providers/flyairport" = {};
|
2024-02-12 06:03:03 +00:00
|
|
|
"clash/proxy-providers/efcloud" = {};
|
2024-01-31 00:30:24 +00:00
|
|
|
"clash/proxy-providers/kogeki" = {};
|
2023-12-25 07:23:54 +00:00
|
|
|
"clash/proxy-providers/spcloud" = {};
|
|
|
|
};
|
|
|
|
|
2023-12-31 12:23:24 +00:00
|
|
|
sops.templates."clash.yaml".content = let
|
|
|
|
convert = url: "https://sub.maoxiongnet.com/sub?target=clash&list=true&url=${url}";
|
|
|
|
in
|
2023-12-26 06:42:06 +00:00
|
|
|
builtins.readFile ./config.yaml
|
|
|
|
+ ''
|
2023-12-31 12:23:24 +00:00
|
|
|
secret: "${config.sops.placeholder."clash/secret"}"
|
2024-04-22 20:40:41 +00:00
|
|
|
|
|
|
|
proxies:
|
|
|
|
${config.sops.placeholder."clash/proxies/lightsail"}
|
|
|
|
|
2023-12-26 06:42:06 +00:00
|
|
|
proxy-providers:
|
2024-02-13 17:51:10 +00:00
|
|
|
flyairport:
|
|
|
|
<<: *fetch
|
|
|
|
url: "${config.sops.placeholder."clash/proxy-providers/flyairport"}"
|
2024-02-12 13:51:51 +00:00
|
|
|
efcloud:
|
2024-02-12 06:03:03 +00:00
|
|
|
<<: *fetch
|
|
|
|
url: "${config.sops.placeholder."clash/proxy-providers/efcloud"}"
|
2024-01-31 00:30:24 +00:00
|
|
|
kogeki:
|
|
|
|
<<: *fetch
|
|
|
|
url: "${config.sops.placeholder."clash/proxy-providers/kogeki"}"
|
2023-12-26 06:42:06 +00:00
|
|
|
spcloud:
|
2023-12-31 12:23:24 +00:00
|
|
|
<<: *fetch
|
2023-12-26 06:42:06 +00:00
|
|
|
url: "${config.sops.placeholder."clash/proxy-providers/spcloud"}"
|
2023-12-25 07:23:54 +00:00
|
|
|
|
2023-12-31 12:23:24 +00:00
|
|
|
# Free servers that I dont really care about
|
|
|
|
pawdroid:
|
|
|
|
<<: *fetch
|
|
|
|
url: "${convert "https://cdn.jsdelivr.net/gh/Pawdroid/Free-servers@main/sub"}"
|
|
|
|
ermaozi:
|
|
|
|
<<: *fetch
|
|
|
|
url: "${convert "https://cdn.jsdelivr.net/gh/ermaozi/get_subscribe@main/subscribe/v2ray.txt"}"
|
|
|
|
#jsnzkpg:
|
|
|
|
# <<: *fetch
|
|
|
|
# url: "${convert "https://cdn.jsdelivr.net/gh/Jsnzkpg/Jsnzkpg@Jsnzkpg/Jsnzkpg"}"
|
|
|
|
'';
|
2023-12-25 07:23:54 +00:00
|
|
|
}
|