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,
|
config,
|
||||||
|
osConfig,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
|
@ -52,15 +53,23 @@
|
||||||
done
|
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
|
setSystemProxy = let
|
||||||
|
inherit (osConfig.networking) knownNetworkServices;
|
||||||
networksetup = /usr/sbin/networksetup;
|
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
|
in
|
||||||
lib.hm.dag.entryAfter ["writeBoundary"] ''
|
lib.hm.dag.entryAfter ["writeBoundary"]
|
||||||
${networksetup} -setwebproxystate "Wi-fi" on
|
(lib.concatMapStrings (x: ''
|
||||||
${networksetup} -setwebproxy "Wi-fi" 127.0.0.1 7890
|
${networksetup} -setwebproxystate "${x}" on
|
||||||
${networksetup} -setwebproxystate "Ethernet" on
|
${networksetup} -setwebproxy "${x}" ${proxy}
|
||||||
${networksetup} -setwebproxy "Ethernet" 127.0.0.1 7890
|
'')
|
||||||
'';
|
knownNetworkServices);
|
||||||
};
|
};
|
||||||
|
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
|
|
Loading…
Reference in a new issue