Proxy only work with root access

$ export https_proxy=socks5://xxx:port
$ nix build .  # proxy does not work

root# export https_proxy=socks5://xxx:port
root# nix build .  # work

proxy setting for normal user does not work, nix build . does not download success, but if I setting proxy with root acount, and build with root account, the proxy will work.
Does anyone meet this issue?

When building as root, you bypass the daemon. To set the proxy for user builds, you should set it for the daemon (it its systemd file probably).

1 Like

so is there any example to set the daemon’s proxy?

nix-daemon is a regular systemd service so you can use this option to set environment variables for it: NixOS Search - Loading...

 systemd.services.nix-daemon.environment.https_proxy = "socks5://foo";
1 Like