Skip to content

prefer-remote-fetch: fix fetchurl eval#457086

Merged
Mic92 merged 1 commit intoNixOS:masterfrom
SuperSandro2000:prefer-remote-fetch-fetchurl
Oct 31, 2025
Merged

prefer-remote-fetch: fix fetchurl eval#457086
Mic92 merged 1 commit intoNixOS:masterfrom
SuperSandro2000:prefer-remote-fetch-fetchurl

Conversation

@SuperSandro2000
Copy link
Member

@SuperSandro2000 SuperSandro2000 commented Oct 30, 2025

Things done

  • 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.

Comment on lines 25 to 27
fetchurl = args: super.fetchurl (super.lib.extends
(super.lib.toExtension { preferLocalBuild = args.preferLocalBuild or false; })
(super.lib.toFunction args));
Copy link
Contributor

@ShamrockLee ShamrockLee Oct 30, 2025

Choose a reason for hiding this comment

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

Sorry, I forgot to consider that args might be a function when writing args.prefenLocalBuild or false.
It should be

Suggested change
fetchurl = args: super.fetchurl (super.lib.extends
(super.lib.toExtension { preferLocalBuild = args.preferLocalBuild or false; })
(super.lib.toFunction args));
fetchurl = fpArgs: super.fetchurl (super.lib.extends
(finalAttrs: args: { preferLocalBuild = args.preferLocalBuild or false; })
(super.lib.toFunction fpArgs));

Or,

Suggested change
fetchurl = args: super.fetchurl (super.lib.extends
(super.lib.toExtension { preferLocalBuild = args.preferLocalBuild or false; })
(super.lib.toFunction args));
fetchurl = lib.extendMkDerivation {
constructDrv = previous.fetchurl;
extendDrvArgs = finalAttrs: args: { preferLocalBuild = args.preferLocalBuild or false; };
}

The latter handles the __functionArgs automatically.

Copy link
Member Author

@SuperSandro2000 SuperSandro2000 Oct 30, 2025

Choose a reason for hiding this comment

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

The 2nd failed with:

error:
       … while calling the 'head' builtin
         at /home/sandro/src/nixpkgs/lib/attrsets.nix:1696:13:
         1695|           if length values == 1 || pred here (elemAt values 1) (head values) then
         1696|             head values
             |             ^
         1697|           else

       … while evaluating the attribute 'value'
         at /home/sandro/src/nixpkgs/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/p5jrkni7q6pa7ckfyqrrjysqh8i5nmdf-source/nixos/modules/system/activation/top-level.nix':

       … while evaluating the option `system.activationScripts':

       … while evaluating definitions from `/nix/store/6mis9m031ia3c7fmxh3gqrq4782dmppn-source/modules/ssh.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: function 'extendDrvArgs' called with unexpected argument 'prefetchLocalBuild'
       at /home/sandro/src/nixpkgs/pkgs/build-support/fetchurl/default.nix:72:5:
           71|     finalAttrs:
           72|     {
             |     ^
           73|       # URL to fetch.

Copy link
Contributor

Choose a reason for hiding this comment

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

The 2nd failed with:

That's due to a typo. It should be preferLocalBuild instead of prefetchLocalBuild.

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated. Sorry for the trouble.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Oct 30, 2025
@nix-owners nix-owners bot requested a review from philiptaron October 30, 2025 20:55
@SuperSandro2000 SuperSandro2000 force-pushed the prefer-remote-fetch-fetchurl branch 3 times, most recently from 555d2bf to dc24b58 Compare October 30, 2025 22:15
@SuperSandro2000 SuperSandro2000 force-pushed the prefer-remote-fetch-fetchurl branch from dc24b58 to bd107d4 Compare October 30, 2025 22:21
@Mic92 Mic92 added this pull request to the merge queue Oct 31, 2025
Merged via the queue into NixOS:master with commit ce4b3b9 Oct 31, 2025
28 of 30 checks passed
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.

Wow, this is convoluted.

Is there a test for these derivation mutators (a phrase I just made up) @SuperSandro2000 that I should run to make sure it's not broken?

@SuperSandro2000 SuperSandro2000 deleted the prefer-remote-fetch-fetchurl branch October 31, 2025 10:57
@SuperSandro2000
Copy link
Member Author

Probably not but it would probably be as easy as just evalling pkgs with it as an overlay

@Mic92
Copy link
Member

Mic92 commented Oct 31, 2025

Maybe it can be added to lib-tests?

SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Dec 9, 2025
andre4ik3 pushed a commit to andre4ik3/nixpkgs that referenced this pull request Dec 12, 2025
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Dec 13, 2025
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Dec 14, 2025
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Dec 16, 2025
andre4ik3 pushed a commit to andre4ik3/nixpkgs that referenced this pull request Dec 16, 2025
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Dec 18, 2025
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Dec 19, 2025
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Dec 20, 2025
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Dec 23, 2025
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Dec 25, 2025
andre4ik3 pushed a commit to andre4ik3/nixpkgs that referenced this pull request Dec 29, 2025
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Dec 31, 2025
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Jan 2, 2026
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Jan 2, 2026
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Jan 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants