[Nix-dev] Setting proxy environmental variables
Edward Tjörnhammar
ed at cflags.cc
Mon Nov 24 17:14:23 CET 2014
On Thu, Nov 20, 2014 at 03:07:19PM +0100, masterdeZign wrote:
> Hello!
>
> I am new to NixOs, but the question which interests me seems not to be
> discussed yet.
> My workstation has access to Internet via proxy. I have exported
> environmental variables http_proxy and https_proxy, however running
> nix-env -i wget fails accessing cache.nixos.org and subsequently,
> tarballs.nixos.org. I suspect it's due to the fact the build users do
> not share the environmental variables with my current user.
Exactly. NIX_REMOTE is set to daemon and you need to unset it so that
the nix*-utils inherits those vars:
export NIX_REMOTE=""
export http_proxy=$1
meaning that root gets a HTTP proxy to communicate through and that
she shan't make RPC calls to the nix-worker but build herself.
This interim proxy subject can be found at:
* https://lastlog.de/wiki/index.php/Nixos_configuration.nix#nixos_with_proxy
- You also need to unset binary-caches since those fetches
didn't honour the proxyvars when I needed an interim proxy.
* https://github.com/edwtjo/nixin/blob/master/nixin#L103-L124
- My own hack. Example of disabled binary-caches when setting or
unsetting a system proxy. Also note that I don't recommend
using that script, it is just an example usage.
>
> Looking around the manual, I have found nix.proxy configuration
> string. I have ended up with a /etc/nixos/configuration.nix like that:
nix.proxy will set the http_proxy upon the next activation, which happens
after a nixos-rebuild switch. You need to use an interim proxy to actually
do that, as described above. You also don't want to update the build
expressions, nix-channel or git fetch, in order to keep the system
switch rebuild small.
>
> { config, pkgs, ... }:
>
> {
> imports = [ <nixos/modules/installer/virtualbox-demo.nix>
> <nixpkgs/nixos/modules/services/misc/nix-daemon.nix>
> ];
>
> nix.proxy = "proxy-host.com:3128";
>
> }
>
> However nixos-rebuild switch fails in the same way as nix-env -i:
>
> building Nix...
> building the system configuration...
> download-from-binary-cache.pl: still waiting for
> ‘http://cache.nixos.org/nix-cache-info’ after 5 seconds...
> download-from-binary-cache.pl: could not download
> ‘http://cache.nixos.org/nix-cache-info’ (Curl error 7)
> these derivations will be built:
> /nix/store/17s184bdsmnqa0vpwxmyj58i3a2n8flz-dbus-conf.drv
> /nix/store/2jwpim2m9f4yhi1ds0rqqcl6h623v0b5-stdenv.drv
> /nix/store/3xbm6viqjdpznhxxxqpsirlfjz0b64lw-bzip2.drv
> ...
> /nix/store/zw9nnsyygzz72j5b3j5zw4bknzkcbcdf-docbook-5.0.zip.drv
> building path(s) `/nix/store/4fxls0b5l7c3kdd8idbzr6cp823iip37-bzip2'
> downloading http://tarballs.nixos.org/stdenv-linux/i686/r24519/bzip2
> into /nix/store/4fxls0b5l7c3kdd8idbzr6cp823iip37-bzip2
> % Total % Received % Xferd Average Speed Time Time Time Current
> Dload Upload Total Spent Left Speed
> 0 0 0 0 0 0 0 0 --:--:-- 0:02:07 --:--:--
>
>
>
> Thank you in advance.
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20141124/494c6bd7/attachment.bin
More information about the nix-dev
mailing list