flake/nixos/profiles/opt-in/mihomo/default.nix

50 lines
1.4 KiB
Nix
Raw Normal View History

{
lib,
pkgs,
config,
...
}: {
2024-03-22 07:09:07 +00:00
services.mihomo = {
enable = true;
configFile = config.sops.templates."clash.yaml".path;
webui = pkgs.metacubexd;
};
2024-08-14 09:06:01 +00:00
systemd.services.mihomo.preStart = ''
2024-08-10 16:28:50 +00:00
${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
'';
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
### sops-nix
2024-07-21 10:09:21 +00:00
sops.secrets = lib.mapAttrs (_name: value:
2024-07-09 23:12:02 +00:00
value
// {
restartUnits = ["mihomo.service"];
sopsFile = ./secrets.yaml;
}) {
2023-12-31 12:23:24 +00:00
"clash/secret" = {};
"clash/proxies/lightsail" = {};
2024-02-12 06:03:03 +00:00
"clash/proxy-providers/efcloud" = {};
"clash/proxy-providers/spcloud" = {};
};
2024-08-19 14:45:31 +00:00
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"
;
};
}