How to use nix behind corporate proxy on Mac?

When my MacBook is behind corporate proxy, it cannot connect to binary cache.
Some commands work after setting HTTPS_PROXY environment variable, but others don’t.
While niv update worked just by temporarily setting this environment variable, downloading and installing packages from nixpkgs didn’t work.

warning: unable to download 'https://cache.nixos.org/2iwpcmn9n1qaylfsb5ic0fjzwl19qcc7.narinfo': Couldn't connect to server (7); retrying in 289 ms

I enabled daemon mode when installing nix. Should I give proxy host/user/password to the daemon as well? I don’t know how to do so.

These links might help you.

https://nixos.org/manual/nix/stable/#sec-installer-proxy-settings

2 Likes