fetchurl: Add hook for rewriting/filtering URLs#410186
fetchurl: Add hook for rewriting/filtering URLs#410186philiptaron merged 1 commit intoNixOS:masterfrom
Conversation
cf0413c to
2802c3c
Compare
There was a problem hiding this comment.
I'm amenable to this feature.
I do wonder if it's not going to be thorough enough for the stated usecase. Will you actually need to reach into the derivation and mutate (say) the environment variables also? I suspect you will, in order to set environment variables needed by proxies and the like.
If that's the case, you're going to be looking for a heavier hammer than this. We have those hammers! We can make that work!
2802c3c to
7e5cde7
Compare
This allows on-the-fly rewriting of URLs before they are passed from fetchurl (or fetchurlBoot) to curl. The intended use is to allow inserting company-internal mirrors, or working around company firewalls and similar network restrictions, without having to extensively patch across all of nixpkgs. Instead, users can pass a function in their nixpkgs that performs the necessary URL rewrites. Co-authored-by: Alexander Bantyev <[email protected]>
7e5cde7 to
abda866
Compare
|
@philiptaron writes:
For proxies and similar we should already be able to pass those in via
For now, we're simply looking to do bulk overrides of URLs onto company-internal mirrors, and to do so without causing world rebuilds, or otherwise hacking each individual derivation. What are the hammers you're referring to, and how would those help us here? |
|
The hammers I'm thinking of equate to an overlay replacing fetchurl. |
|
I move to merge unless objections arise in the next day or so. |
I'd like to note that that wouldn't work for |
|
Bisect says abda866 |
|
Proposed the fix as: |
|
Thanks, merged. Sorry for the breakage. |
This allows on-the-fly rewriting of URLs before they are passed from
fetchurl(orfetchurlBoot) tocurl.The intended use is to allow inserting company-internal mirrors, or working around company firewalls and similar network restrictions, without having to extensively patch across all of nixpkgs. Instead, users can pass a function in their nixpkgs config that performs the necessary URL rewrites.
We first tried solving this with a shell hook called from inside
fetchurl'sbuilder.sh, as that would apply rewrites after themirror://scheme has been resolved, however, this was not feasible to also apply tofetchurlBoot, hence we instead settled on a Nix function called before the builder is invoked. If we still want/need the rewrite to happen after resolvingmirror://URLs, then we probably need to move the mirroring logic out of thebuilder.shand rewrite it in nix.This is related in spirit to #409010, but does not directly depend on it.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.