mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-13 12:13:36 +01:00
chore: drop the unused darwin proxy set script (#306)
The script pointed the macOS nix-daemon at the homelab v2ray HTTP proxy (192.168.5.101:7890), but that proxy was never running. Remove it together with the just darwin-set-proxy recipe and the README step that referenced it.
This commit is contained in:
1 parent
242c607ce6
commit
ca00d26642
3 files changed
-66
No files matched your search
@@ -147,12 +147,6 @@ niri mode="switch" verbosity="normal":
|
||||
brew-upgrade:
|
||||
brew upgrade --cask --greedy
|
||||
|
||||
[macos]
|
||||
[group('desktop')]
|
||||
darwin-set-proxy:
|
||||
sudo python3 scripts/darwin_set_proxy.py
|
||||
sleep 1sec
|
||||
|
||||
[macos]
|
||||
[group('desktop')]
|
||||
darwin-rollback:
|
||||
|
||||
@@ -137,7 +137,6 @@ For macOS (nix-darwin):
|
||||
# 2. prepare the deployment environment with essential packages available
|
||||
nix-shell -p just nushell
|
||||
# 3. comment home-manager's code in lib/macosSystem.nix to speed up the first deployment.
|
||||
# 4. comment out the proxy settings in scripts/darwin_set_proxy.py if the proxy is not ready yet.
|
||||
|
||||
# Deploy the darwinConfiguration by hostname match (fern, frieren)
|
||||
just local
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
"""
|
||||
Set proxy for nix-daemon to speed up downloads
|
||||
You can safely ignore this file if you don't need a proxy.
|
||||
|
||||
https://github.com/NixOS/nix/issues/1472#issuecomment-1532955973
|
||||
"""
|
||||
|
||||
import os
|
||||
import plistlib
|
||||
import shlex
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
NIX_DAEMON_PLIST = Path("/Library/LaunchDaemons/org.nixos.nix-daemon.plist")
|
||||
NIX_DAEMON_NAME = "org.nixos.nix-daemon"
|
||||
# http proxy provided by my homelab's bypass router
|
||||
HTTP_PROXY = "http://192.168.5.101:7890"
|
||||
|
||||
PLIST = plistlib.loads(NIX_DAEMON_PLIST.read_bytes())
|
||||
|
||||
|
||||
def update_plist():
|
||||
os.chmod(NIX_DAEMON_PLIST, 0o644)
|
||||
NIX_DAEMON_PLIST.write_bytes(plistlib.dumps(PLIST))
|
||||
os.chmod(NIX_DAEMON_PLIST, 0o444)
|
||||
|
||||
|
||||
def reload_daemon():
|
||||
# reload the plist
|
||||
for cmd in (
|
||||
f"launchctl unload {NIX_DAEMON_PLIST}",
|
||||
f"launchctl load {NIX_DAEMON_PLIST}",
|
||||
):
|
||||
print(cmd)
|
||||
subprocess.run(shlex.split(cmd), capture_output=False)
|
||||
|
||||
|
||||
def set_proxy():
|
||||
# set http/https proxy
|
||||
# NOTE: curl only accept the lowercase of `http_proxy`!
|
||||
# NOTE: https://curl.se/libcurl/c/libcurl-env.html
|
||||
PLIST["EnvironmentVariables"]["http_proxy"] = HTTP_PROXY
|
||||
PLIST["EnvironmentVariables"]["https_proxy"] = HTTP_PROXY
|
||||
update_plist()
|
||||
reload_daemon()
|
||||
|
||||
|
||||
def unset_proxy():
|
||||
# remove http proxy
|
||||
PLIST["EnvironmentVariables"].pop("http_proxy", None)
|
||||
PLIST["EnvironmentVariables"].pop("https_proxy", None)
|
||||
update_plist()
|
||||
reload_daemon()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# set_proxy()
|
||||
unset_proxy()
|
||||
Reference in new issue
Block a user