From 47fdb5cf6e7a10ce92423b61fac1c598bf1fa504 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Wed, 13 Dec 2023 19:18:00 +0800 Subject: [PATCH] darwin: clash-meta-client: refactor --- .../profiles/opt-in/clash-meta-client.nix | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/users/guanranwang/darwin/profiles/opt-in/clash-meta-client.nix b/users/guanranwang/darwin/profiles/opt-in/clash-meta-client.nix index c42b66d..ae1f866 100644 --- a/users/guanranwang/darwin/profiles/opt-in/clash-meta-client.nix +++ b/users/guanranwang/darwin/profiles/opt-in/clash-meta-client.nix @@ -1,25 +1,28 @@ { inputs, pkgs, + lib, ... -}: { - environment.variables = { +}: let + env = { "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"; }; +in { + # TODO: not run as root - launchd.daemons."nix-daemon".environment = { - "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"; - }; + # Proxy environment variables + environment.variables = env; + launchd.daemons."nix-daemon".environment = env; + # launchd service launchd.daemons."clash-meta" = { - command = "${pkgs.clash-meta}/bin/clash-meta -d /etc/clash-meta"; + command = "${lib.getExe pkgs.clash-meta} -d /etc/clash-meta"; + serviceConfig.RunAtLoad = true; }; + # Web interface environment.etc."clash-meta/metacubexd".source = inputs.self.packages.${pkgs.system}.metacubexd; }