[Nix-dev] Setting proxy environmental variables

Edward Tjörnhammar ed at cflags.cc
Thu Nov 27 13:02:27 CET 2014


On Thu, Nov 27, 2014 at 11:43:47AM +0100, masterdeZign wrote:
>    DearA Edward and Wout,
>    thank you for your replies.
>    Edward, I more or less understand what your script tries to
>    doA https://github.com/edwtjo/nixin/blob/master/nixin#L103-L124. But can
>    you advise which values forA NIXPKGS_REPO are suitable? I am using a 14.04
>    virtualbox image for now and it does not have git installed.
>    Wout, I have already set the http_proxy and https_proxy environmental
>    variables (written in the very first message). Unfortunately, it is not
>    enough, that's why this question thread.
>    To summarize, steps taken:
>    1) export http_proxy=some-proxy.com:3128 --- OK
>    2) export https_proxy=some-proxy.com:3128 --- OK
>    3) exportA NIX_REMOTE="" A --- OK
>    4) export NIXPKGS_REPO= A --- ???

This is only relevant for the script, forget about this step. You're using nix-channel for build expression updates, not a nixpkgs git repo.

>    5) rebuilding nixos --- ??? (fails because no proxy found)

You should only need to do a

    4) nix-build -A system "<nixos>" --option use-binary-caches false
    5) nixos-rebuild switch --option use-binary-caches false

>    Thank you!
>    2014-11-24 17:14 GMT+01:00 Edward TjAP:rnhammar <ed at cflags.cc>:
>
>      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:
>
>      A  *
>      https://lastlog.de/wiki/index.php/Nixos_configuration.nix#nixos_with_proxy
>      A  A  A  - You also need to unset binary-caches since those fetches
>      A  A  A  A  didn't honour the proxyvars when I needed an interim proxy.
>      A  * https://github.com/edwtjo/nixin/blob/master/nixin#L103-L124
>      A  A  A  - My own hack. Example of disabled binary-caches when setting
>      or
>      A  A  A  A  unsetting a system proxy. Also note that I don't recommend
>      A  A  A  A  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, ... }:
>      >
>      > {
>      >A  A imports = [ <nixos/modules/installer/virtualbox-demo.nix>
>      >A  A  A  A  A  A  A  A  A  A
>      A <nixpkgs/nixos/modules/services/misc/nix-daemon.nix>
>      >A  A  A  A  A  A  A  A  ];
>      >
>      >A  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
>      > a**http://cache.nixos.org/nix-cache-infoa** after 5 seconds...
>      > download-from-binary-cache.pl: could not download
>      > a**http://cache.nixos.org/nix-cache-infoa** (Curl error 7)
>      > these derivations will be built:
>      >A  A /nix/store/17s184bdsmnqa0vpwxmyj58i3a2n8flz-dbus-conf.drv
>      >A  A /nix/store/2jwpim2m9f4yhi1ds0rqqcl6h623v0b5-stdenv.drv
>      >A  A /nix/store/3xbm6viqjdpznhxxxqpsirlfjz0b64lw-bzip2.drv
>      > ...
>      >A  A /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
>      >A  A % TotalA  A  % Received % XferdA  Average SpeedA  A TimeA  A
>      TimeA  A  A TimeA  Current
>      >A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  DloadA  UploadA
>      A TotalA  A SpentA  A  LeftA  Speed
>      >A  A 0A  A  A 0A  A  0A  A  A 0A  A  0A  A  A 0A  A  A  0A  A  A  0
>      --:--:--A  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

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/20141127/a4f1a861/attachment.bin 


More information about the nix-dev mailing list