darwin/desktop/setSystemProxy: refactor
This commit is contained in:
parent
0fb05c61c7
commit
c98e5a5c53
1 changed files with 15 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
config,
|
||||
osConfig,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
|
@ -52,15 +53,23 @@
|
|||
done
|
||||
)
|
||||
'';
|
||||
|
||||
# I should've putted it in /darwin/modules/networking/proxy.nix,
|
||||
# but I am too stupid to figure out how nix-darwin works...
|
||||
setSystemProxy = let
|
||||
inherit (osConfig.networking) knownNetworkServices;
|
||||
networksetup = /usr/sbin/networksetup;
|
||||
|
||||
# naive but works(tm)
|
||||
# "http://127.0.0.1:1234/" -> "127.0.0.1 1234"
|
||||
proxy = builtins.replaceStrings ["http://" ":" "/"] ["" " " ""] osConfig.networking.proxy.httpProxy;
|
||||
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
|
||||
'';
|
||||
lib.hm.dag.entryAfter ["writeBoundary"]
|
||||
(lib.concatMapStrings (x: ''
|
||||
${networksetup} -setwebproxystate "${x}" on
|
||||
${networksetup} -setwebproxy "${x}" ${proxy}
|
||||
'')
|
||||
knownNetworkServices);
|
||||
};
|
||||
|
||||
packages = with pkgs; [
|
||||
|
|
Loading…
Reference in a new issue