How to set GOPROXY during nixos-rebuild?

I have to access network using a proxy.
So I added a package called dae and its binary cache to my flake,it hang when downloading some go packages.
I’ve tried http_proxy https_proxy all_proxy,and

sudo mkdir /run/systemd/system/nix-daemon.service.d/
cat << EOF >/run/systemd/system/nix-daemon.service.d/override.conf  
[Service]
Environment="http_proxy=socks5h://localhost:7891"
Environment="https_proxy=socks5h://localhost:7891"
Environment="all_proxy=socks5h://localhost:7891"
Environment="GOPROXY=socks5h://localhost:7891"
EOF
sudo systemctl daemon-reload
sudo systemctl restart nix-daemon

but none of them work.
I have two questions here.
1.why the package has to be built even I have added its binary cache?
2.how to access network behind the proxy when go downloads stuff.

1 Like

You need to add the envs to impureEnvVars derivation attribute.

By default, those nixpkgs/pkgs/build-support/go/module.nix at 589c31662739027f6b802f138fd12f4493ad68de · NixOS/nixpkgs · GitHub are supported.

You can’t generally say that. Try diffing the drv files and before formatting them with pretty-derivation.