Install nix package behind proxy

I’ve trouble installing a package without a proxy:

user@nixos ~> nix-env -iA nixos.sshuttle
installing 'sshuttle-1.0.3'
warning: error: unable to download 'https://cache.nixos.org/dp03bn2l8zxbcrxdxcha6y4hinw7mdm3.narinfo': Timeout was reached (28); retrying in 314 ms
warning: error: unable to download 'https://cache.nixos.org/dp03bn2l8zxbcrxdxcha6y4hinw7mdm3.narinfo': Timeout was reached (28); retrying in 538 ms
warning: error: unable to download 'https://cache.nixos.org/dp03bn2l8zxbcrxdxcha6y4hinw7mdm3.narinfo': Timeout was reached (28); retrying in 1315 ms
warning: error: unable to download 'https://cache.nixos.org/dp03bn2l8zxbcrxdxcha6y4hinw7mdm3.narinfo': Timeout was reached (28); retrying in 2443 ms

How can instruct nix-env to use http_proxy?
I exported http_proxy, HTTP_PROXY, https_proxy, and HTTP_PROXY, but using these env variables, didn’t work!

Are you using single or multi-user installation?

If you are using multi-user/deamon, then you need to make the nix-deamon aware of the env vars.

Also: avoid nix-env

1 Like