Hi there, I want to set a netrcPhase for all fetchers specifying credentialed access to resources. To do this, I have tried defining an overlay as follows:
final: prev:
let
newfetch = inputs: prev.fetchurl (inputs//{ netrcPhase = "...";});
in
{
fetchurl = newfetch;
}
Unfortunately this gives me an infinite recursion error. I think this is because fetchurl has a functor attribute but I am not sure. Any help is much appreciated!
EDIT: The netrc file needs to be generated on the fly using temporary credentials, which is why I want to do it this way.
Note the dependence on netrcPhase being set. fetchurl (without cacert) is required in order to build cacert, so you get infrec.
A functional workaround should be to override cacert to use the unmodified fetchurl. (Or maybe not… it doesn’t use it directly. It uses fetchFromGitHub, which uses fetchzip, which uses fetchurl.)
That’s rather surprising! I thought the lazy evaluation of nix was implemented partly to overcome exactly these problems. Is there any possible way to override the netrcPhase arg in fetchurl? Maybe I should put a PR in to promote these parameters to the top level where they can be overridden.
A simple, if somewhat wasteful, solution is to override fetchurl to use the cacert package from a separate nixpkgs instantiation. This evaluates without infrec in the repl for me: