Enterprise: Difference between revisions
m Add category networking |
Added dynamic generation of netrc files section |
||
Line 40: | Line 40: | ||
The proxy itself can be set via the environment variables <code>HTTP_PROXY</code> and <code>HTTPS_PROXY</code>. | The proxy itself can be set via the environment variables <code>HTTP_PROXY</code> and <code>HTTPS_PROXY</code>. | ||
== Dynamic generation of netrc files == | |||
Sometimes you have to deal with dynamically short-lived tokens that must be generated on the fly. The above options do not cover this, so the best way forward is to use `fetchurl`'s `netrcPhase` option: | |||
newPkgs = pkgs.extend ( | |||
final: prev: { | |||
fetchurl = | |||
args: | |||
(prev.fetchurl.override { | |||
inherit (pkgs) cacert; # required to avoid infrec | |||
}) | |||
( | |||
args | |||
// { | |||
netrcPhase = | |||
# do stuff here to get credentials | |||
BAR=\'\'$(dynamic-shell-script) | |||
cat > netrc <<EOF | |||
machine foobar | |||
login FOO | |||
password \'\'$BAR | |||
EOF | |||
'';'' | |||
} | |||
); | |||
} | |||
); | |||
now any fetch in newPkgs will dynamically generate tokens with `fetchurl`. | |||
[[Category:Networking]] | [[Category:Networking]] |