aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2022-09-16 00:47:54 -0700
committerAdam Joseph <adam@westernsemico.com>2022-09-16 00:48:01 -0700
commitb3550d9179611692a4e27fbe4e5f493f4e8713e3 (patch)
tree8fceb58b5a90c4974279464e94901adc723fb1fc
parent88a45d6149c0e304f6eb2efcc2d7a4d0d569f8af (diff)
libexpr/fetchurl.nix: allow __impure fetch
This commit adds an optional `__impure` parameter to fetchurl.nix, which allows the caller to use `libfetcher`'s fetcher in an impure derivation. This allows nixpkgs' patch-normalizing fetcher (fetchpatch) to be rewritten to use nix's internal fetchurl, thereby eliminating the awkward "you can't use fetchpatch here" banners scattered all over the place. See also: https://github.com/NixOS/nixpkgs/pull/188587
-rw-r--r--src/libexpr/fetchurl.nix8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libexpr/fetchurl.nix b/src/libexpr/fetchurl.nix
index 02531103b..38815fcc4 100644
--- a/src/libexpr/fetchurl.nix
+++ b/src/libexpr/fetchurl.nix
@@ -12,13 +12,13 @@
, executable ? false
, unpack ? false
, name ? baseNameOf (toString url)
+, __impure ? false
}:
-derivation {
+derivation ({
builder = "builtin:fetchurl";
# New-style output content requirements.
- inherit outputHashAlgo outputHash;
outputHashMode = if unpack || executable then "recursive" else "flat";
inherit name url executable unpack;
@@ -38,4 +38,6 @@ derivation {
# To make "nix-prefetch-url" work.
urls = [ url ];
-}
+} // (if __impure
+ then { inherit __impure; }
+ else { inherit outputHashAlgo outputHash; }))