[Nix-dev] Setting proxy environmental variables

Edward Tjörnhammar ed at cflags.cc
Sat Nov 29 14:20:34 CET 2014


On Fri, Nov 28, 2014 at 07:05:37PM +0100, Edward Tjörnhammar wrote:
> On Fri, Nov 28, 2014 at 05:27:56PM +0100, masterdeZign wrote:
> > Dear all,
> >
> > thank you for the Proxies page on the nixos.org. However, I tried to
> > follow the steps, and here is what went wrong:
>
> Could you try setting:
>
>   export NIX_CURL_FLAGS="http_proxy=\"http://some-proxy.com:3128\""

This was wrong and should've been

    export NIX_CURL_FLAGS="-x $http_proxy"

Which was passed to curl but I didn't need to set it to switch over.

>
> Before the build, I remember that working at one point when setting
> http_proxy didn't work. I obviously don't use that anymore since my
> script work for me.
>
> I'm not on 14.04 but will try to build behind a proxy on 14.04 once I
> get some time.

Got some time and verified that the steps on the Proxies page work for
setting/unsetting a proxy on a kvm guest installed from the 14.04
2b0cacc media, which was installed by setting the http_proxy var and
running nixos-install as finalization.

>
> >
> > [root at nixos:~]# export https_proxy="some-proxy.com:3128"  # The same
> > result was for https://some-proxy.com:3128
> >
> > [root at nixos:~]# export http_proxy="some-proxy.com:3128"   # The same
> > result was for http://some-proxy.com:3128
> >
> > [root at nixos:~]# export NIX_REMOTE=""
> >
> > [root at nixos:~]# nix-build -A system "<nixpkgs/nixos>" --option
> > use-binary-caches false
> > these derivations will be built:
> >   /nix/store/17s184bdsmnqa0vpwxmyj58i3a2n8flz-dbus-conf.drv
> >   /nix/store/2jwpim2m9f4yhi1ds0rqqcl6h623v0b5-stdenv.drv
> >   /nix/store/3xbm6viqjdpznhxxxqpsirlfjz0b64lw-bzip2.drv
> >   /nix/store/48i73k96qy4wzlmgqrg089zq7925vkbf-unzip-6.0.drv
> >   /nix/store/4rpjapixwak8p84pbkfk8ypvvznaspc9-bootstrap-tools.drv
> >   /nix/store/4v8czj1mv30v1pzv2kz6s2aj0i27vp47-xz-5.0.5.drv
> >   /nix/store/620imla2a843rsjb64iixihy489pns10-nixos-14.04.572.2b0cacc.drv
> >   /nix/store/6agb57azm08aifsnfrbhdib9bxska1b5-zlib-1.2.8.drv
> >   /nix/store/6fypbf81nfq7vd415ggr1143hflkqf30-bootstrap-gcc-wrapper.drv
> >   /nix/store/6j00iqi0pc72fiwxci22349chg6c5k3k-zlib-1.2.8.tar.gz.drv
> >   /nix/store/6m91snbc0k1q027m0yywhbk0zda4awd4-bootstrap-glibc.drv
> >   /nix/store/706ykq2k6264b7v5m7jkkrq919jvfv7b-local-cmds.drv
> >   /nix/store/77x644yasxz6czb5da7qsix3ildlvgv1-mkdir.drv
> >   /nix/store/7wafmk6sfb9s2ahci0vy7pli7vifjj93-nixos-manpages.drv
> >   /nix/store/8d48yaqd9r1i5qx6rhdj57f8x7n7wphn-unzip60.tar.gz.drv
> >   /nix/store/8xy3vkarkwjsjjpg9mmlap2m579wm3bx-configuration.nix.drv
> >   /nix/store/9h6hf2y5rzlwdfa7jpp99dpc30wy4jy7-xz-5.0.5.tar.bz2.drv
> >   /nix/store/9kifiq1dp27xfwimk7avac1aaj3xwfan-stdenv-linux-boot.drv
> >   /nix/store/b9w5sfl2ymfpcknxnsjqg0skqshsshkp-system-path.drv
> >   /nix/store/c99n136y9dx4z285qfyx4aqf12k195vd-system-units.drv
> >   /nix/store/cspa2c9c0kby10mw3nq9idi8zz7ypp4d-unit.drv
> >   /nix/store/cylvmknh3p1jhxrnymv21nja59wbcrnc-gnumake-3.82.drv
> >   /nix/store/d0yipl9v6ns0zcw0p12xmvg4hk06yvhd-nixos-help.drv
> >   /nix/store/fa9y9ggnmh3v87lxd70z5fkarfyic47m-options-db.xml.drv
> >   /nix/store/g05fymn0lxdvsqnhi6v1m2ij75qndvcz-etc.drv
> >   /nix/store/g1qviwli7p010nmlz5v5zalw64m97av0-patchelf-0.8.tar.bz2.drv
> >   /nix/store/h287h1vivkryxylyvphas1gm9hiqay2w-unit.drv
> >   /nix/store/h8sn7dyxq64mbm2m26iqj6qrca2y6vyq-patchelf-0.8.drv
> >   /nix/store/hmskflrz24v3nv6040vamhfd96393cj1-set-environment.drv
> >   /nix/store/ix00ag1yjl92ij971z31d7005bj431ky-make-3.82.tar.bz2.drv
> >   /nix/store/kslwq77fn8qym4yahsnq80jswwmpfagy-stage-2-init.sh.drv
> >   /nix/store/lcwasq8y8acznl22j3b9qv0jm0hapmhm-etc-file.drv
> >   /nix/store/n0rx86w84d7ypxdm8dxg78vzjklrjmzr-bootstrap-tools.cpio.bz2.drv
> >   /nix/store/n6k4h4xzq661y9s22hkhnylh7p3a5qdh-docbook-xsl-ns-1.78.1.drv
> >   /nix/store/nfr35npdy61y1199a3aaqp4adnl5ydmn-nixos-14.04.572.2b0cacc.drv
> >   /nix/store/nrfqb6wcrv3b794qphw712ixa1yvb41j-gcc-wrapper-4.8.3.drv
> >   /nix/store/nzsk41hjg1pilqwyip3aawwfq7411axl-mirrors-list.drv
> >   /nix/store/p0p44vjxgigbkgmsny41v1jwbkn12q5h-docbook-xsl-ns-1.78.1.tar.bz2.drv
> >   /nix/store/pcfghxqsxgs1aymmafv11cv7sfgyq0c6-curl.bz2.drv
> >   /nix/store/pnfj7ap89ixvpv2ya92lwyrh6kyfldpf-binutils-2.23.1.drv
> >   /nix/store/qd8dmn1yfkfjh5znfcbvzvcgqfjiizc3-cpio.drv
> >   /nix/store/qqyyxjc8f3dpdar237irfqyryvfxqf1f-mirrors-list.drv
> >   /nix/store/rc7v654jii6vd1jr035k2hqlpfkawapq-stdenv-linux-boot.drv
> >   /nix/store/rksxaabzs75gmxl4fpdxc2ah9j46gyp2-bootstrap-gcc-wrapper.drv
> >   /nix/store/vfy9fbdm4jrr195daldvkj2962bgc1br-binutils-2.23.1.tar.bz2.drv
> >   /nix/store/vz8irn1xypr8d6klm8mal9mjgjgczs4a-sh.drv
> >   /nix/store/w0yk4b4aymnq21kc04ckmcsvqa3z5dy8-system-crontab.drv
> >   /nix/store/x8akf7qph415rnkzk12cxi2hiwdd6451-stdenv-linux-boot.drv
> >   /nix/store/xc9md7ymg7zrg3fawlhivlxdyis65l46-docbook5-5.0.drv
> >   /nix/store/xjaak96z1z4ncl2s7wby1f7iisjyia25-stdenv-linux-boot.drv
> >   /nix/store/xpqxb348f5bvpzjq3793n21ppvrsxrxz-nixos-manual.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:04:58
> > --:--:--     0curl: (7) Failed to connect to tarballs.nixos.org port

This output indicates that nix-build doesn't pick up the http_proxy
variable. If you would've misspelt the proxy host you would've seen
that hostname in the error instead. There might be something going on
but unfortunately I cannot reproduce it.

> > 80: Connection timed out
> > builder for `/nix/store/3xbm6viqjdpznhxxxqpsirlfjz0b64lw-bzip2.drv'
> > failed with exit code 7
> > cannot build derivation
> > `/nix/store/4rpjapixwak8p84pbkfk8ypvvznaspc9-bootstrap-tools.drv': 1
> > dependencies couldn't be built
> > cannot build derivation
> > `/nix/store/cylvmknh3p1jhxrnymv21nja59wbcrnc-gnumake-3.82.drv': 1
> > dependencies couldn't be built
> > cannot build derivation
> > `/nix/store/2jwpim2m9f4yhi1ds0rqqcl6h623v0b5-stdenv.drv': 1
> > dependencies couldn't be built
> > cannot build derivation
> > `/nix/store/620imla2a843rsjb64iixihy489pns10-nixos-14.04.572.2b0cacc.drv':
> > 1 dependencies couldn't be built
> > error: build of
> > `/nix/store/620imla2a843rsjb64iixihy489pns10-nixos-14.04.572.2b0cacc.drv'
> > failed
> >
> >
> >
> > 2014-11-27 23:05 GMT+01:00, Edward Tjörnhammar <ed at cflags.cc>:
> > > On Thu, Nov 27, 2014 at 09:57:29PM +0000, Wout Mertens wrote:
> > >>    On Thu Nov 27 2014 at 10:29:14 PM Edward TjAP:rnhammar <ed at cflags.cc>
> > >>    wrote:
> > >>
> > >>      On Thu, Nov 27, 2014 at 06:19:47PM +0000, Wout Mertens wrote:
> > >>      >A  A  Ok, try this:
> > >>      >
> > >>      >A  A  A  * configure nix.proxy like it should be in
> > >>      /etc/nixos/configuration.nix
> > >>      >A  A  A  * build the new nix.conf:A sudo nix-build '<nixpkgs/nixos>'
> > >> -A
> > >>      >A  A  A  A  config.environment.etc.\"nix/nix.conf\".source
> > >>      >A  A  A  * overwrite nix.conf: sudo mv result /etc/nix/nix.conf
> > >>      >A  A  A  * sudo nixos-rebuild => should work now with the proxy
> > >>      settings
> > >>
> > >>      Will that work? "man nix.conf|grep proxy;echo $?"
> > >>      (nix-1.8pre3903_b0c5c2a)
> > >>
> > >>    Argh, you're right, nix.proxy determines the environment variables for
> > >>    nix-daemon, there's no proxy setting in the nix configuration file :-(
> > >>    So while this will set build options that are defined in the nixos
> > >> config,
> > >>    it doesn't help with proxying.
> > >>    So it's back to not doing the build with nix-daemon, but as root with
> > >> the
> > >>    proper proxy variables set. Just sudo -s, set the variables and do a
> > >>    nixos-rebuild.
> > >>    Another option would be to set up iptables to send all http traffic
> > >>    through a transparent proxy but that's probably silly :-D.
> > >
> > > Hurr? the localhost privoxy would forward to the intended http_proxy
> > > via its config but that would still imply an activation right?
> > >
> > >>    Wout.
> > >
> >
> >
> > --
> > Best regards,
> > Bogdan Penkovskyi



> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
-------------- 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/20141129/f9707a4f/attachment.bin 


More information about the nix-dev mailing list