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 '': 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.