feat: darwin

This commit is contained in:
Ryan Yin
2023-12-22 21:20:02 +08:00
parent ad86ed60dc
commit a9459e7606
3 changed files with 18 additions and 12 deletions

View File

@@ -23,9 +23,11 @@ let
HOMEBREW_BREW_GIT_REMOTE = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git";
HOMEBREW_CORE_GIT_REMOTE = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git";
HOMEBREW_PIP_INDEX_URL = "https://pypi.tuna.tsinghua.edu.cn/simple";
# local HTTP PROXY
HTTP_PROXY = "http://127.0.0.1:7890";
HTTPS_PROXY = "http://127.0.0.1:7890";
};
local_proxy_env = {
# HTTP_PROXY = "http://127.0.0.1:7890";
# HTTPS_PROXY = "http://127.0.0.1:7890";
};
in {
# Install packages from nix's official package repository.
@@ -53,8 +55,12 @@ in {
# Set environment variables for nix-darwin before run `brew bundle`.
system.activationScripts.homebrew.text = let
env_script = lib.attrsets.foldlAttrs (acc: name: value: acc + "\nexport ${name}=${value}") "" homebrew_mirror_env;
in
env_script =
lib.attrsets.foldlAttrs
(acc: name: value: acc + "\nexport ${name}=${value}")
""
(homebrew_mirror_env // local_proxy_env);
in
lib.mkBefore ''
echo >&2 '${env_script}'
${env_script}
@@ -158,7 +164,7 @@ in {
"sonic-pi" # music programming
# Development
"mitmproxy" # HTTP/HTTPS traffic inspector
"mitmproxy" # HTTP/HTTPS traffic inspector
"insomnia" # REST client
"wireshark" # network analyzer
"jdk-mission-control" # Java Mission Control

View File

@@ -14,11 +14,11 @@
"b9902f2020c636aeda956a74b5ae11882d53e206d1aa50b3abe591a8144fa710" # nix-installer on harmonica
];
environment.etc."bashrc".knownSha256Hashes = [
"204d2a960b3ab80e51748d3db0b63d940347ba71119ae6f14cccfec35da56cce" # nix-installer on harmonica
"53ab77cddb5c9aa2954efe42e9af0b8a2829f94dd31b6c33f8082ed194dcc0cb" # nix-installer on harmonica
"6ffdf5a198ffe73fbcd17def767f52093b42b29149d4a3e911b49ebcb9785101" # nix-installer on fern
];
environment.etc."zshenv".knownSha256Hashes = [
"383a89c1f79c3bcfd2ff39a2b73b5103d0303161b3be9eac88fce83e0789f0b7" # nix-installer on harmonica
"bb96fe80a72ea9cd3291f09e4dc13a64e7db3b401f5889e43edc1fe34ed02d2c" # nix-installer on harmonica
"0c544e42afe7836de9ba933d93f46043b12f58ae484ff8cfb02716353f1dba5f" # nix-installer on fern
];

View File

@@ -17,12 +17,12 @@ HTTP_PROXY = "http://127.0.0.1:7890"
pl = plistlib.loads(NIX_DAEMON_PLIST.read_bytes())
# set http proxy
pl["EnvironmentVariables"]["HTTP_PROXY"] = HTTP_PROXY
pl["EnvironmentVariables"]["HTTPS_PROXY"] = HTTP_PROXY
# pl["EnvironmentVariables"]["HTTP_PROXY"] = HTTP_PROXY
# pl["EnvironmentVariables"]["HTTPS_PROXY"] = HTTP_PROXY
# remove http proxy
# pl["EnvironmentVariables"].pop("HTTP_PROXY", None)
# pl["EnvironmentVariables"].pop("HTTPS_PROXY", None)
pl["EnvironmentVariables"].pop("HTTP_PROXY", None)
pl["EnvironmentVariables"].pop("HTTPS_PROXY", None)
os.chmod(NIX_DAEMON_PLIST, 0o644)
NIX_DAEMON_PLIST.write_bytes(plistlib.dumps(pl))