darwin: clash-meta daemon with launchd

This commit is contained in:
Guanran Wang 2023-10-09 14:52:33 +08:00
parent 1f84c9ece5
commit 3fd1a9cb5a
Signed by: nyancat
SSH key fingerprint: SHA256:8oWGKciPALWut/6WA27oFKofX+6Wtc0gQnsefXLQx/8
4 changed files with 38 additions and 10 deletions

View file

@ -3,5 +3,6 @@
{
imports = [
./dns.nix
./proxy.nix
];
}

View file

@ -0,0 +1,27 @@
{ pkgs, ... }:
# README!!:
# I HAVE NO IDEA HOW LAUNCHD DAEMON WORKS
# USE AT YOUR OWN RISK
# it just works™
#
# Remember to manually copy `config.yaml` to `/etc/clash-meta`
# I have no idea how to get sops-nix working on darwin...
#
{
#environment.systemPackages = with pkgs; [ clash-meta ];
# do i even need to add it to environment.systemPackages...
launchd.daemons."clash-meta" = {
command = "${pkgs.clash-meta}/bin/clash-meta -d /etc/clash-meta";
};
environment.variables = {
"https_proxy" = "http://127.0.0.1:7890";
"http_proxy" = "http://127.0.0.1:7890";
"socks_proxy" = "socks5://127.0.0.1:7890";
"all_proxy" = "socks5://127.0.0.1:7890";
};
environment.etc."clash-meta/metacubexd".source = ../../users/guanranwang/home-manager/common/dotfiles/config/clash/metacubexd;
}

View file

@ -15,7 +15,7 @@
"alt-tab"
"altserver"
"balenaetcher"
"clashx"
#"clashx"
"opencore-patcher"
#"element"

View file

@ -5,9 +5,9 @@
username = "guanranwang";
homeDirectory = "/Users/guanranwang";
activation = {
# Workaround for spotlight indexing
# https://github.com/nix-community/home-manager/issues/1341#issuecomment-1705731962_
activation = {
trampolineApps = let
apps = pkgs.buildEnv {
name = "home-manager-applications";
@ -26,6 +26,13 @@
done
)
'';
setSystemProxy = let networksetup = /usr/sbin/networksetup;
in lib.hm.dag.entryAfter ["writeBoundary"] ''
${networksetup} -setwebproxystate "Wi-fi" on
${networksetup} -setwebproxy "Wi-fi" 127.0.0.1 7890
${networksetup} -setwebproxystate "Ethernet" on
${networksetup} -setwebproxy "Ethernet" 127.0.0.1 7890
'';
};
packages = with pkgs; [
@ -63,13 +70,6 @@
nixd
nil
];
sessionVariables = {
"https_proxy" = "http://127.0.0.1:7890";
"http_proxy" = "http://127.0.0.1:7890";
"socks_proxy" = "socks5://127.0.0.1:7890";
"all_proxy" = "socks5://127.0.0.1:7890";
};
};
# macOS don't have fontconfig