diff --git a/darwin/networking/default.nix b/darwin/networking/default.nix index 0bbacfc..c856686 100644 --- a/darwin/networking/default.nix +++ b/darwin/networking/default.nix @@ -3,5 +3,6 @@ { imports = [ ./dns.nix + ./proxy.nix ]; } \ No newline at end of file diff --git a/darwin/networking/proxy.nix b/darwin/networking/proxy.nix new file mode 100644 index 0000000..1495b6f --- /dev/null +++ b/darwin/networking/proxy.nix @@ -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 = { + "http_proxy" = "http://127.0.0.1:7890"; + "https_proxy" = "http://127.0.0.1:7890"; + "ftp_proxy" = "http://127.0.0.1:7890"; + "rsync_proxy" = "http://127.0.0.1:7890"; + }; + + environment.etc."clash-meta/metacubexd".source = ../../users/guanranwang/home-manager/common/dotfiles/config/clash/metacubexd; +} \ No newline at end of file diff --git a/darwin/packages/homebrew.nix b/darwin/packages/homebrew.nix index 3d062cf..f841549 100644 --- a/darwin/packages/homebrew.nix +++ b/darwin/packages/homebrew.nix @@ -15,7 +15,7 @@ "alt-tab" "altserver" "balenaetcher" - "clashx" + #"clashx" "opencore-patcher" #"element" diff --git a/flake.nix b/flake.nix index fc489bd..51c0b5c 100755 --- a/flake.nix +++ b/flake.nix @@ -48,7 +48,7 @@ specialArgs = { inherit inputs; }; modules = [ ./darwin # Entrypoint - ./machines/darwin/imac-2017.nix # Hardware-specific configurations + ./machines/darwin/imac-2017 # Hardware-specific configurations # Machine-specific configurations (does such stuff even exist on nix-darwin) ./users/guanranwang/darwin.nix # User-specific configurations ./flakes/darwin/home-manager.nix # Flakes diff --git a/users/guanranwang/home-manager/darwin/home.nix b/users/guanranwang/home-manager/darwin/home.nix index df81d36..7b55718 100644 --- a/users/guanranwang/home-manager/darwin/home.nix +++ b/users/guanranwang/home-manager/darwin/home.nix @@ -5,9 +5,9 @@ username = "guanranwang"; homeDirectory = "/Users/guanranwang"; - # Workaround for spotlight indexing - # https://github.com/nix-community/home-manager/issues/1341#issuecomment-1705731962_ activation = { + # Workaround for spotlight indexing + # https://github.com/nix-community/home-manager/issues/1341#issuecomment-1705731962_ 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 = { - "http_proxy" = "http://127.0.0.1:7890"; - "https_proxy" = "http://127.0.0.1:7890"; - "ftp_proxy" = "http://127.0.0.1:7890"; - "rsync_proxy" = "http://127.0.0.1:7890"; - }; }; # macOS don't have fontconfig