Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pkgs/by-name/ni/nix-prefetch/fix-extendMkDerivation-overlay.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- a/lib/overlay.nix 2025-12-12 14:17:10.585262065 -0500
+++ b/lib/overlay.nix 2025-12-12 14:17:31.567341843 -0500
@@ -35,9 +35,17 @@
];
};

- curlFetcher = fetcher: setFunctionArgs (args: fetcher (args // {
- curlOpts = (args.curlOpts or "") + " --no-insecure --cacert ${cacert}/etc/ssl/certs/ca-bundle.crt ";
- })) (functionArgs fetcher);
+ # Handle both attrset and function arguments for extendMkDerivation compatibility
+ curlFetcher = fetcher: setFunctionArgs (args:
+ let
+ modifyArgs = a: a // {
+ curlOpts = (a.curlOpts or "") + " --no-insecure --cacert ${cacert}/etc/ssl/certs/ca-bundle.crt ";
+ };
+ in
+ if isFunction args
+ then fetcher (final: modifyArgs (args final))
+ else fetcher (modifyArgs args)
+ ) (functionArgs fetcher);

unsafeFetcher = name: reason: throw "The fetcher ${name} is deemed unsafe: ${reason}.";

37 changes: 37 additions & 0 deletions pkgs/by-name/ni/nix-prefetch/fix-extendMkDerivation-prelude.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--- a/lib/prelude.nix
+++ b/lib/prelude.nix
@@ -108,9 +108,24 @@

primitiveFetchers = listFetchers builtinsOverlay true ++ [ "fetchurlBoot" ];

+ # Helper to merge args, handling both attrsets and functions (for extendMkDerivation)
+ mergeArgsWithRequired = requiredArgs: args:
+ if isFunction args
+ then final: requiredArgs // args final
+ else requiredArgs // args;
+
+ # Helper to safely intersect args with oldArgs, handling function args
+ safeIntersectArgs = args: oldArgs:
+ if isFunction args
+ then {} # When args is a function, we can't know the keys at evaluation time
+ else builtins.intersectAttrs args oldArgs;
+
markFetcher = { type, name, fetcher }:
let
- customFetcher = args: markFetcherDrv { inherit type name fetcher args; drv = fetcher (requiredFetcherArgs // args); };
+ customFetcher = args: markFetcherDrv {
+ inherit type name fetcher args;
+ drv = fetcher (mergeArgsWithRequired requiredFetcherArgs args);
+ };

# The required fetcher arguments are assumed to be of type string,
# because requiring a complex value, e.g. a derivation attrset, is very unlikely,
@@ -132,7 +147,7 @@
if !(elem origPassthru.__fetcher.name primitiveFetchers) then functionArgs origPassthru.__fetcher
else throw "Fetcher ${name} is build on top of the primitive fetcher ${origPassthru.__fetcher.name}, which is not supported."
else {};
- newArgs = oldArgs // functionArgs fetcher // mapAttrs (_: _: true) (builtins.intersectAttrs args oldArgs);
+ newArgs = oldArgs // functionArgs fetcher // mapAttrs (_: _: true) (safeIntersectArgs args oldArgs);
in {
passthru = origPassthru // {
__fetcher = setFunctionArgs fetcher newArgs // { inherit type name args; drv = drvOverriden; };
5 changes: 5 additions & 0 deletions pkgs/by-name/ni/nix-prefetch/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ stdenv.mkDerivation (finalAttrs: {
url = "https://github.com/msteen/nix-prefetch/commit/508237f48f7e2d8496ce54f38abbe57f44d0cbca.patch";
hash = "sha256-9SYPcRFZaVyNjMUVdXbef5eGvLp/kr379eU9lG5GgE0=";
})
# Fix compatibility with extendMkDerivation-based fetchers (fetchzip, fetchgit, etc.)
# The curlFetcher and markFetcher functions assumed fetcher arguments are always
# attribute sets, but extendMkDerivation can pass functions for the finalAttrs pattern.
./fix-extendMkDerivation-overlay.patch
./fix-extendMkDerivation-prelude.patch
];

postPatch = ''
Expand Down
Loading