Skip to content

prefer-remote-fetch: Fix evaluation for all fetchers and export additional attributes#475142

Merged
philiptaron merged 1 commit intoNixOS:masterfrom
fooker:pr/prefer-remote-fetch
Jan 5, 2026
Merged

prefer-remote-fetch: Fix evaluation for all fetchers and export additional attributes#475142
philiptaron merged 1 commit intoNixOS:masterfrom
fooker:pr/prefer-remote-fetch

Conversation

@fooker
Copy link
Contributor

@fooker fooker commented Dec 29, 2025

This fixes valuation error with enabled prefer-remote-fetch overlay.

Fixes #467200.

Things done

  • Use extendMkDerivation to override default for preferLocalBuild on fetchers.

  • Expose additional attributes on fetchgit

  • Add some tests

  • Built on platform:

    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:

  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.

  • Tested basic functionality of all binary files, usually in ./result/bin/.

  • Nixpkgs Release Notes

    • Package update: when the change is major or breaking.
  • NixOS Release Notes

    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.


Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot requested a review from philiptaron December 29, 2025 20:16
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. labels Dec 29, 2025
@fooker fooker added the backport release-25.11 Backport PR automatically label Dec 29, 2025
@philiptaron
Copy link
Contributor

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 475142
Commit: 96ed29f4b73476643a3e4f4a7544c632e88cb61f


x86_64-linux

✅ 4 packages built:
  • tests.prefer-remote-fetch.fetchFromGitHub
  • tests.prefer-remote-fetch.fetchgit
  • tests.prefer-remote-fetch.fetchurl
  • tests.prefer-remote-fetch.fetchzip

Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the tests.

Comment on lines +36 to +38
fetchgit = (preferLocal super.fetchgit) // {
inherit (super.fetchgit) getRevWithTag;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fishy to me: I think it's adding the name into the __functor attrset. If it works for you, I think it's fine though.

@philiptaron philiptaron added this pull request to the merge queue Jan 5, 2026
@philiptaron
Copy link
Contributor

I think this obviates my PR #457313

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jan 5, 2026
Merged via the queue into NixOS:master with commit a1d2a41 Jan 5, 2026
34 of 36 checks passed
@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Jan 5, 2026

@github-actions github-actions bot added the 8.has: port to stable This PR already has a backport to the stable release. label Jan 5, 2026
@fooker fooker deleted the pr/prefer-remote-fetch branch January 5, 2026 17:03
fetchipfs = preferLocal super.fetchipfs;
fetchrepoproject = preferLocal super.fetchrepoproject;
fetchs3 = preferLocal super.fetchs3;
fetchsvn = preferLocal super.fetchsvn;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke fetchsvn for me:

       … while evaluating derivation 'spandsp-0.0.6'
         whose name attribute is located at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/make-derivation.nix:541:13

       … while evaluating attribute 'nativeBuildInputs' of derivation 'spandsp-0.0.6'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/make-derivation.nix:590:13:
          589|             depsBuildBuild = elemAt (elemAt dependencies 0) 0;
          590|             nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
             |             ^
          591|             depsBuildTarget = elemAt (elemAt dependencies 0) 2;

       … in the condition of the assert statement
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/customisation.nix:429:15:
          428|             outPath =
          429|               assert condition;
             |               ^
          430|               drv.${outputName}.outPath;

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/make-derivation.nix:835:18:
          834|       };
          835|       validity = checkMeta.assertValidity { inherit meta attrs; };
             |                  ^
          836|

       … while calling 'assertValidity'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:696:5:
          695|   assertValidity =
          696|     { meta, attrs }:
             |     ^
          697|     let

       … while evaluating a branch condition
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:701:5:
          700|     in
          701|     if isNull invalid then
             |     ^
          702|       if isNull warning then

       … while calling the 'isNull' builtin
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:701:8:
          700|     in
          701|     if isNull invalid then
             |        ^
          702|       if isNull warning then

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:698:17:
          697|     let
          698|       invalid = checkValidity attrs;
             |                 ^
          699|       warning = checkWarnings attrs;

       … while calling 'checkValidity'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:451:5:
          450|   checkValidity =
          451|     attrs:
             |     ^
          452|     # Check meta attribute types first, to make sure it is always called even when there are other issues

       … while evaluating a branch condition
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:454:5:
          453|     # Note that this is not a full type check and functions below still need to by careful about their inputs!
          454|     if metaInvalid (attrs.meta or { }) then
             |     ^
          455|       {

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:454:8:
          453|     # Note that this is not a full type check and functions below still need to by careful about their inputs!
          454|     if metaInvalid (attrs.meta or { }) then
             |        ^
          455|       {

       … while calling anonymous lambda
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:7:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |       ^
          429|     else

       … in the argument of the not operator
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:14:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |              ^
          429|     else

       … while calling the 'all' builtin
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:14:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |              ^
          429|     else

       … while calling anonymous lambda
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:19:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |                   ^
          429|     else

       … in the right operand of the AND (&&) operator
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:45:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |                                             ^
          429|     else

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:48:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |                                                ^
          429|     else

       … while calling 'verify'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:96:16:
           95|       name = "union<${concatStringsSep "," (map (t: t.name) types)}>";
           96|       verify = v: any (func: func v) funcs;
             |                ^
           97|     };

       … while calling the 'any' builtin
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:96:19:
           95|       name = "union<${concatStringsSep "," (map (t: t.name) types)}>";
           96|       verify = v: any (func: func v) funcs;
             |                   ^
           97|     };

       … while calling anonymous lambda
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:96:24:
           95|       name = "union<${concatStringsSep "," (map (t: t.name) types)}>";
           96|       verify = v: any (func: func v) funcs;
             |                        ^
           97|     };

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:96:30:
           95|       name = "union<${concatStringsSep "," (map (t: t.name) types)}>";
           96|       verify = v: any (func: func v) funcs;
             |                              ^
           97|     };

       … while calling anonymous lambda
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:84:43:
           83|         # listOf<any> can be optimised to just isList
           84|         if t == self.any then isList else v: isList v && all verify v;
             |                                           ^
           85|     };

       … in the left operand of the AND (&&) operator
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:84:55:
           83|         # listOf<any> can be optimised to just isList
           84|         if t == self.any then isList else v: isList v && all verify v;
             |                                                       ^
           85|     };

       … while calling the 'isList' builtin
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:84:46:
           83|         # listOf<any> can be optimised to just isList
           84|         if t == self.any then isList else v: isList v && all verify v;
             |                                              ^
           85|     };

       … while evaluating the attribute 'changelog'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/by-name/ne/netpbm/package.nix:132:5:
          131|   meta = {
          132|     changelog = "https://sourceforge.net/p/netpbm/code/${src.rev}/tree/advanced/doc/HISTORY";
             |     ^
          133|     homepage = "https://netpbm.sourceforge.net/";

       … while calling a functor (an attribute set with a '__functor' attribute)
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/by-name/ne/netpbm/package.nix:32:9:
           31|
           32|   src = fetchsvn {
             |         ^
           33|     url = "https://svn.code.sf.net/p/netpbm/code/advanced";

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/trivial.nix:1017:5:
         1016|     # TODO: Should we add call-time "type" checking like built in?
         1017|     __functor = self: f;
             |     ^
         1018|     __functionArgs = args;

       … while calling anonymous lambda
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/customisation.nix:880:9:
          879|       (
          880|         fpargs:
             |         ^
          881|         transformDrv (

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/customisation.nix:881:9:
          880|         fpargs:
          881|         transformDrv (
             |         ^
          882|           constructDrv (extendsWithExclusion excludeDrvArgNames extendDrvArgs (toFunction fpargs))

       … while calling 'id'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/trivial.nix:57:8:
           56|   */
           57|   id = x: x;
             |        ^
           58|

       … while calling a functor (an attribute set with a '__functor' attribute)
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/customisation.nix:882:11:
          881|         transformDrv (
          882|           constructDrv (extendsWithExclusion excludeDrvArgNames extendDrvArgs (toFunction fpargs))
             |           ^
          883|         )

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/trivial.nix:1017:5:
         1016|     # TODO: Should we add call-time "type" checking like built in?
         1017|     __functor = self: f;
             |     ^
         1018|     __functionArgs = args;

       … while evaluating the value passed for the lambda argument
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/build-support/fetchsvn/default.nix:43:1:
           42|
           43| {
             | ^
           44|   url,

       error: expected a set but found a function: «lambda extendsWithExclusion @ «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/customisation.nix:863:30»

I would guess because it did not, yet (?) get the same updates as other by @ShamrockLee

https://github.com/NixOS/nixpkgs/commits/master/pkgs/build-support/fetchsvn

Not sure if we should revert or change it to the newer ways to do things.

In the meantime I just applied this locally:

diff --git a/pkgs/build-support/prefer-remote-fetch/default.nix b/pkgs/build-support/prefer-remote-fetch/default.nix
index c39caf4d6b4d..593866ddee78 100644
--- a/pkgs/build-support/prefer-remote-fetch/default.nix
+++ b/pkgs/build-support/prefer-remote-fetch/default.nix
@@ -41,7 +41,7 @@
   fetchipfs = preferLocal super.fetchipfs;
   fetchrepoproject = preferLocal super.fetchrepoproject;
   fetchs3 = preferLocal super.fetchs3;
-  fetchsvn = preferLocal super.fetchsvn;
+  fetchsvn = args: super.fetchsvn ({ preferLocalBuild = false; } // args);
   fetchurl = preferLocal super.fetchurl;
   mkNugetSource = preferLocal super.mkNugetSource;
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. backport release-25.11 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prefer-remote-fetch does not expose attributes for fetchers

3 participants