Skip to content

fetchurl: builder.sh: handle urls as a Bash array#471851

Merged
MattSturgeon merged 10 commits intoNixOS:masterfrom
ShamrockLee:fetchurl-structuredAttrs-urls-fix
Dec 21, 2025
Merged

fetchurl: builder.sh: handle urls as a Bash array#471851
MattSturgeon merged 10 commits intoNixOS:masterfrom
ShamrockLee:fetchurl-structuredAttrs-urls-fix

Conversation

@ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Dec 18, 2025

Clean up leftover for PR #464475.

Revert and re-implement Continue the work of PR #470643 to address a Bash variable reassignment quirk:

$ foo=(a b)
$ declare -p foo
declare -a foo=([0]="a" [1]="b")
$ foo="${foo[*]}"
$ declare -p foo
declare -a foo=([0]="a b" [1]="b")
$ declare foo="${foo[*]}"
$ declare -p foo
declare -a foo=([0]="a b b" [1]="b")

PR #470643 probably does make the mirror fetching. Even if it doesn't clean up the "mirror://" pseudo-URL, it does add the resolved URLs which curl will use to download the file. We revert and re-implement in the same PR to avoid re-introducing the breakage PR #470643 has fixed.

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.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 6.topic: fetch Fetchers (e.g. fetchgit, fetchsvn, ...) labels Dec 18, 2025
Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

Initial read through the diff, without cloning or testing.

@ShamrockLee ShamrockLee force-pushed the fetchurl-structuredAttrs-urls-fix branch from 5c2f3f6 to 13af71d Compare December 18, 2025 09:01
@ShamrockLee
Copy link
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 471851
Commit: 13af71d89e2bf4ba541c9f980d6a6143701e80af (subsequent changes)
Merge: 8790994175e222cade2ec90ce94cd109cc92786f

Logs: https://github.com/ShamrockLee/nixpkgs-review-gha/actions/runs/20331707980


x86_64-linux

✅ 67 packages built:
  • tests.fetchDebianPatch.libPackage
  • tests.fetchDebianPatch.simple
  • tests.fetchFirefoxAddon.simple (tests.fetchFirefoxAddon.overridden-source)
  • tests.fetchFromBitbucket.withEncodedWhitespace
  • tests.fetchFromBitbucket.withEncodedWhitespaceGit
  • tests.fetchFromBitbucket.withoutWhitespace
  • tests.fetchFromGitHub.dumb-http-signed-tag
  • tests.fetchFromGitHub.fetchTags
  • tests.fetchFromGitHub.leave-git
  • tests.fetchFromGitHub.rootDir
  • tests.fetchFromGitHub.simple
  • tests.fetchFromGitHub.sparseCheckout
  • tests.fetchFromGitHub.sparseCheckoutNonConeMode
  • tests.fetchFromGitHub.submodule-deep
  • tests.fetchFromGitHub.submodule-leave-git
  • tests.fetchFromGitHub.submodule-leave-git-deep
  • tests.fetchFromGitHub.submodule-simple
  • tests.fetchNextcloudApp.simple-sha256
  • tests.fetchNextcloudApp.simple-sha512
  • tests.fetchPypiLegacy.fetchSimple
  • tests.fetchgit.collect-rev
  • tests.fetchgit.describe-tag
  • tests.fetchgit.dumb-http-signed-tag
  • tests.fetchgit.fetchTags
  • tests.fetchgit.leave-git
  • tests.fetchgit.prefetch-git-no-add-path
  • tests.fetchgit.rootDir
  • tests.fetchgit.simple
  • tests.fetchgit.simple-tag
  • tests.fetchgit.sparseCheckout
  • tests.fetchgit.sparseCheckoutNonConeMode
  • tests.fetchgit.submodule-deep
  • tests.fetchgit.submodule-leave-git
  • tests.fetchgit.submodule-leave-git-deep
  • tests.fetchgit.submodule-revision-count
  • tests.fetchgit.submodule-simple
  • tests.fetchgit.withGitConfig
  • tests.fetchpatch.decode
  • tests.fetchpatch.fileWithApostrophe
  • tests.fetchpatch.fileWithSpace
  • tests.fetchpatch.full
  • tests.fetchpatch.hunks
  • tests.fetchpatch.relative
  • tests.fetchpatch.simple
  • tests.fetchpatch2.decode
  • tests.fetchpatch2.fileWithApostrophe
  • tests.fetchpatch2.fileWithSpace
  • tests.fetchpatch2.full
  • tests.fetchpatch2.hunks
  • tests.fetchpatch2.relative
  • tests.fetchpatch2.simple
  • tests.fetchurl.flag-appending-curlOpts
  • tests.fetchurl.flag-appending-curlOptsList
  • tests.fetchurl.flag-appending-netrcPhase-curlOpts
  • tests.fetchurl.flag-appending-netrcPhase-curlOptsList
  • tests.fetchurl.hashedMirrors
  • tests.fetchurl.header
  • tests.fetchurl.no-skipPostFetch
  • tests.fetchurl.urls-mirrors
  • tests.fetchurl.urls-simple
  • tests.fetchzip.hiddenDir
  • tests.fetchzip.postFetch
  • tests.fetchzip.simple
  • tests.haskell.cabalSdist.assumptionLocalHasDirectReference
  • tests.haskell.cabalSdist.localHasNoDirectReference
  • tests.testers.runCommand.bork
  • tests.testers.runCommand.dns-resolution

aarch64-linux

✅ 67 packages built:
  • tests.fetchDebianPatch.libPackage
  • tests.fetchDebianPatch.simple
  • tests.fetchFirefoxAddon.simple (tests.fetchFirefoxAddon.overridden-source)
  • tests.fetchFromBitbucket.withEncodedWhitespace
  • tests.fetchFromBitbucket.withEncodedWhitespaceGit
  • tests.fetchFromBitbucket.withoutWhitespace
  • tests.fetchFromGitHub.dumb-http-signed-tag
  • tests.fetchFromGitHub.fetchTags
  • tests.fetchFromGitHub.leave-git
  • tests.fetchFromGitHub.rootDir
  • tests.fetchFromGitHub.simple
  • tests.fetchFromGitHub.sparseCheckout
  • tests.fetchFromGitHub.sparseCheckoutNonConeMode
  • tests.fetchFromGitHub.submodule-deep
  • tests.fetchFromGitHub.submodule-leave-git
  • tests.fetchFromGitHub.submodule-leave-git-deep
  • tests.fetchFromGitHub.submodule-simple
  • tests.fetchNextcloudApp.simple-sha256
  • tests.fetchNextcloudApp.simple-sha512
  • tests.fetchPypiLegacy.fetchSimple
  • tests.fetchgit.collect-rev
  • tests.fetchgit.describe-tag
  • tests.fetchgit.dumb-http-signed-tag
  • tests.fetchgit.fetchTags
  • tests.fetchgit.leave-git
  • tests.fetchgit.prefetch-git-no-add-path
  • tests.fetchgit.rootDir
  • tests.fetchgit.simple
  • tests.fetchgit.simple-tag
  • tests.fetchgit.sparseCheckout
  • tests.fetchgit.sparseCheckoutNonConeMode
  • tests.fetchgit.submodule-deep
  • tests.fetchgit.submodule-leave-git
  • tests.fetchgit.submodule-leave-git-deep
  • tests.fetchgit.submodule-revision-count
  • tests.fetchgit.submodule-simple
  • tests.fetchgit.withGitConfig
  • tests.fetchpatch.decode
  • tests.fetchpatch.fileWithApostrophe
  • tests.fetchpatch.fileWithSpace
  • tests.fetchpatch.full
  • tests.fetchpatch.hunks
  • tests.fetchpatch.relative
  • tests.fetchpatch.simple
  • tests.fetchpatch2.decode
  • tests.fetchpatch2.fileWithApostrophe
  • tests.fetchpatch2.fileWithSpace
  • tests.fetchpatch2.full
  • tests.fetchpatch2.hunks
  • tests.fetchpatch2.relative
  • tests.fetchpatch2.simple
  • tests.fetchurl.flag-appending-curlOpts
  • tests.fetchurl.flag-appending-curlOptsList
  • tests.fetchurl.flag-appending-netrcPhase-curlOpts
  • tests.fetchurl.flag-appending-netrcPhase-curlOptsList
  • tests.fetchurl.hashedMirrors
  • tests.fetchurl.header
  • tests.fetchurl.no-skipPostFetch
  • tests.fetchurl.urls-mirrors
  • tests.fetchurl.urls-simple
  • tests.fetchzip.hiddenDir
  • tests.fetchzip.postFetch
  • tests.fetchzip.simple
  • tests.haskell.cabalSdist.assumptionLocalHasDirectReference
  • tests.haskell.cabalSdist.localHasNoDirectReference
  • tests.testers.runCommand.bork
  • tests.testers.runCommand.dns-resolution

x86_64-darwin (sandbox = relaxed)

❌ 4 packages failed to build:
  • tests.fetchFromGitHub.rootDir
  • tests.fetchFromGitHub.sparseCheckout
  • tests.fetchgit.simple
  • tests.testers.runCommand.bork
✅ 64 packages built:
  • tests.fetchDebianPatch.libPackage
  • tests.fetchDebianPatch.simple
  • tests.fetchFirefoxAddon.simple (tests.fetchFirefoxAddon.overridden-source)
  • tests.fetchFromBitbucket.withEncodedWhitespace
  • tests.fetchFromBitbucket.withEncodedWhitespaceGit
  • tests.fetchFromBitbucket.withoutWhitespace
  • tests.fetchFromGitHub.dumb-http-signed-tag
  • tests.fetchFromGitHub.fetchTags
  • tests.fetchFromGitHub.leave-git
  • tests.fetchFromGitHub.simple
  • tests.fetchFromGitHub.sparseCheckoutNonConeMode
  • tests.fetchFromGitHub.submodule-deep
  • tests.fetchFromGitHub.submodule-leave-git
  • tests.fetchFromGitHub.submodule-leave-git-deep
  • tests.fetchFromGitHub.submodule-simple
  • tests.fetchNextcloudApp.simple-sha256
  • tests.fetchNextcloudApp.simple-sha512
  • tests.fetchPypiLegacy.fetchSimple
  • tests.fetchgit.collect-rev
  • tests.fetchgit.describe-tag
  • tests.fetchgit.dumb-http-signed-tag
  • tests.fetchgit.fetchTags
  • tests.fetchgit.leave-git
  • tests.fetchgit.prefetch-git-no-add-path
  • tests.fetchgit.rootDir
  • tests.fetchgit.simple-tag
  • tests.fetchgit.sparseCheckout
  • tests.fetchgit.sparseCheckoutNonConeMode
  • tests.fetchgit.submodule-deep
  • tests.fetchgit.submodule-leave-git
  • tests.fetchgit.submodule-leave-git-deep
  • tests.fetchgit.submodule-revision-count
  • tests.fetchgit.submodule-simple
  • tests.fetchgit.withGitConfig
  • tests.fetchpatch.decode
  • tests.fetchpatch.fileWithApostrophe
  • tests.fetchpatch.fileWithSpace
  • tests.fetchpatch.full
  • tests.fetchpatch.hunks
  • tests.fetchpatch.relative
  • tests.fetchpatch.simple
  • tests.fetchpatch2.decode
  • tests.fetchpatch2.fileWithApostrophe
  • tests.fetchpatch2.fileWithSpace
  • tests.fetchpatch2.full
  • tests.fetchpatch2.hunks
  • tests.fetchpatch2.relative
  • tests.fetchpatch2.simple
  • tests.fetchurl.flag-appending-curlOpts
  • tests.fetchurl.flag-appending-curlOptsList
  • tests.fetchurl.flag-appending-netrcPhase-curlOpts
  • tests.fetchurl.flag-appending-netrcPhase-curlOptsList
  • tests.fetchurl.hashedMirrors
  • tests.fetchurl.header
  • tests.fetchurl.no-skipPostFetch
  • tests.fetchurl.urls-mirrors
  • tests.fetchurl.urls-simple
  • tests.fetchzip.hiddenDir
  • tests.fetchzip.postFetch
  • tests.fetchzip.simple
  • tests.haskell.cabalSdist.assumptionLocalHasDirectReference
  • tests.haskell.cabalSdist.localHasNoDirectReference
  • tests.testers.runCommand.dns-resolution
  • tests.testers.runCommand.nonDefault-hash

Error logs: `x86_64-darwin`
tests.fetchFromGitHub.rootDir
Receiving objects:  78% (48/61)
Receiving objects:  80% (49/61)
Receiving objects:  81% (50/61)
Receiving objects:  83% (51/61)
Receiving objects:  85% (52/61)
Receiving objects:  86% (53/61)
Receiving objects:  88% (54/61)
Receiving objects:  90% (55/61)
Receiving objects:  91% (56/61)
Receiving objects:  93% (57/61)
Receiving objects:  95% (58/61)
Receiving objects:  96% (59/61)
Receiving objects:  98% (60/61)
Receiving objects: 100% (61/61)
Receiving objects: 100% (61/61), 23.94 KiB | 1.99 MiB/s, done.
From https://github.com/NixOS/nix
 * branch            9d9dbe6ed05854e03811c361a3380e09183f4f4a -> FETCH_HEAD
fatal: unable to access 'https://github.com/NixOS/nix.git/': Failed to connect to github.com port 443 after 19526 ms: Could not connect to server
fatal: could not fetch 004549fd2776d164c9f44bad6ea5217cffe98ac0 from promisor remote
Unable to checkout 9d9dbe6ed05854e03811c361a3380e09183f4f4a from https://github.com/NixOS/nix.git.
tests.fetchFromGitHub.sparseCheckout
Receiving objects:  78% (48/61)
Receiving objects:  80% (49/61)
Receiving objects:  81% (50/61)
Receiving objects:  83% (51/61)
Receiving objects:  85% (52/61)
Receiving objects:  86% (53/61)
Receiving objects:  88% (54/61)
Receiving objects:  90% (55/61)
Receiving objects:  91% (56/61)
Receiving objects:  93% (57/61)
Receiving objects:  95% (58/61)
Receiving objects:  96% (59/61)
Receiving objects:  98% (60/61)
Receiving objects: 100% (61/61)
Receiving objects: 100% (61/61), 23.94 KiB | 2.39 MiB/s, done.
From https://github.com/NixOS/nix
 * branch            9d9dbe6ed05854e03811c361a3380e09183f4f4a -> FETCH_HEAD
fatal: unable to access 'https://github.com/NixOS/nix.git/': Failed to connect to github.com port 443 after 75006 ms: Could not connect to server
fatal: could not fetch 2d1117f4bda6833507bdeadb2391886f98c34c6f from promisor remote
Unable to checkout 9d9dbe6ed05854e03811c361a3380e09183f4f4a from https://github.com/NixOS/nix.git.
tests.fetchgit.simple
structuredAttrs is enabled
exporting https://github.com/NixOS/nix (rev 9d9dbe6ed05854e03811c361a3380e09183f4f4a) into /nix/store/q0qy8aj5h4wqwaz8n07z7dvfl8bya2ra-simple-nix-source-salted-bgpbysybz8l1
Initialized empty Git repository in /nix/store/q0qy8aj5h4wqwaz8n07z7dvfl8bya2ra-simple-nix-source-salted-bgpbysybz8l1/.git/
fatal: invalid refspec '+refs/tags/2.3.15^{}'
fatal: unable to access 'https://github.com/NixOS/nix/': Failed to connect to github.com port 443 after 19511 ms: Could not connect to server
ERROR: `git fetch' failed.
This might be due to the dumb transfer protocol not supporting shallow fetch or no-tag cloning. Trying with `--tags' and without `--depth=1'...
fatal: unable to access 'https://github.com/NixOS/nix/': Failed to connect to github.com port 443 after 19548 ms: Could not connect to server
Unable to checkout 9d9dbe6ed05854e03811c361a3380e09183f4f4a from https://github.com/NixOS/nix.
tests.testers.runCommand.bork
                else:
                    # POSIX _communicate already populated the output so
                    # far into the TimeoutExpired exception.
                    process.wait()
                raise
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
>               raise CalledProcessError(retcode, process.args,
                                         output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command '['/nix/store/84s01mzl74vh69aphpl3rf07pp49pkz0-python3-3.13.9/bin/python3.13', '-m', 'bork', 'download', 'gh:duckinator/emanate', 'v7.0.0']' returned non-zero exit status 1.

/nix/store/84s01mzl74vh69aphpl3rf07pp49pkz0-python3-3.13.9/lib/python3.13/subprocess.py:577: CalledProcessError
=========================== short test summary info ============================
FAILED bork/tests/test_cmd_download.py::test_download - subprocess.CalledProcessError: Command '['/nix/store/84s01mzl74vh69aphpl3rf...
ERROR bork/tests/test_repos.py::test_repo[ppb-mutant] - subprocess.CalledProcessError: Command '['git', 'clone', '--depth', '1', 'h...
============= 1 failed, 2 passed, 5 deselected, 1 error in 55.89s ==============


aarch64-darwin (sandbox = relaxed)

✅ 68 packages built:
  • tests.fetchDebianPatch.libPackage
  • tests.fetchDebianPatch.simple
  • tests.fetchFirefoxAddon.simple (tests.fetchFirefoxAddon.overridden-source)
  • tests.fetchFromBitbucket.withEncodedWhitespace
  • tests.fetchFromBitbucket.withEncodedWhitespaceGit
  • tests.fetchFromBitbucket.withoutWhitespace
  • tests.fetchFromGitHub.dumb-http-signed-tag
  • tests.fetchFromGitHub.fetchTags
  • tests.fetchFromGitHub.leave-git
  • tests.fetchFromGitHub.rootDir
  • tests.fetchFromGitHub.simple
  • tests.fetchFromGitHub.sparseCheckout
  • tests.fetchFromGitHub.sparseCheckoutNonConeMode
  • tests.fetchFromGitHub.submodule-deep
  • tests.fetchFromGitHub.submodule-leave-git
  • tests.fetchFromGitHub.submodule-leave-git-deep
  • tests.fetchFromGitHub.submodule-simple
  • tests.fetchNextcloudApp.simple-sha256
  • tests.fetchNextcloudApp.simple-sha512
  • tests.fetchPypiLegacy.fetchSimple
  • tests.fetchgit.collect-rev
  • tests.fetchgit.describe-tag
  • tests.fetchgit.dumb-http-signed-tag
  • tests.fetchgit.fetchTags
  • tests.fetchgit.leave-git
  • tests.fetchgit.prefetch-git-no-add-path
  • tests.fetchgit.rootDir
  • tests.fetchgit.simple
  • tests.fetchgit.simple-tag
  • tests.fetchgit.sparseCheckout
  • tests.fetchgit.sparseCheckoutNonConeMode
  • tests.fetchgit.submodule-deep
  • tests.fetchgit.submodule-leave-git
  • tests.fetchgit.submodule-leave-git-deep
  • tests.fetchgit.submodule-revision-count
  • tests.fetchgit.submodule-simple
  • tests.fetchgit.withGitConfig
  • tests.fetchpatch.decode
  • tests.fetchpatch.fileWithApostrophe
  • tests.fetchpatch.fileWithSpace
  • tests.fetchpatch.full
  • tests.fetchpatch.hunks
  • tests.fetchpatch.relative
  • tests.fetchpatch.simple
  • tests.fetchpatch2.decode
  • tests.fetchpatch2.fileWithApostrophe
  • tests.fetchpatch2.fileWithSpace
  • tests.fetchpatch2.full
  • tests.fetchpatch2.hunks
  • tests.fetchpatch2.relative
  • tests.fetchpatch2.simple
  • tests.fetchurl.flag-appending-curlOpts
  • tests.fetchurl.flag-appending-curlOptsList
  • tests.fetchurl.flag-appending-netrcPhase-curlOpts
  • tests.fetchurl.flag-appending-netrcPhase-curlOptsList
  • tests.fetchurl.hashedMirrors
  • tests.fetchurl.header
  • tests.fetchurl.no-skipPostFetch
  • tests.fetchurl.urls-mirrors
  • tests.fetchurl.urls-simple
  • tests.fetchzip.hiddenDir
  • tests.fetchzip.postFetch
  • tests.fetchzip.simple
  • tests.haskell.cabalSdist.assumptionLocalHasDirectReference
  • tests.haskell.cabalSdist.localHasNoDirectReference
  • tests.testers.runCommand.bork
  • tests.testers.runCommand.dns-resolution
  • tests.testers.runCommand.nonDefault-hash

@ShamrockLee ShamrockLee marked this pull request as ready for review December 18, 2025 09:26
@nixpkgs-ci nixpkgs-ci bot requested a review from philiptaron December 18, 2025 09:33
Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

LGTM. The test failures seem to be darwin-specific network issues? I wonder if sandbox = off would resolve them?

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Dec 18, 2025
@MattSturgeon MattSturgeon force-pushed the fetchurl-structuredAttrs-urls-fix branch from ca58959 to 65a6b72 Compare December 18, 2025 12:23
@ShamrockLee
Copy link
Contributor Author

The test failures seem to be darwin-specific network issues? I wonder if sandbox = off would resolve them?

I guess it is transient. GitHub seems to suffer from connection instability again. Quite some of my PRs suffer from CI check failures due to failed connection.

@MattSturgeon
Copy link
Contributor

I'll do x86_64-darwin builds with and without sandbox, to satisfy my curiosity:

But either way, I think we should merge this promptly as it's a correctness fix for a core part of nixpkgs. If any issues are pointed out post-merge they can be dealt with in follow-up PRs.

@ShamrockLee
Copy link
Contributor Author

My nixpkgs-review-gha job failed. It probably has nothing to do with sandboxing but some bad internet weather.

https://github.com/ShamrockLee/nixpkgs-review-gha/actions/runs/20336998231/job/58426014912

@ShamrockLee
Copy link
Contributor Author

ShamrockLee commented Dec 18, 2025

But either way, I think we should merge this promptly as it's a correctness fix for a core part of nixpkgs. If any issues are pointed out post-merge they can be dealt with in follow-up PRs.

I agree.

Wait a minute. I found a syntax error in the seldom-checked showURL feature.

@MattSturgeon
Copy link
Contributor

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 471851
Commit: 65a6b72802a240b549d9444715446fef505b8a8d (subsequent changes)
Merge: f2656102259f5b6c63f1baad529d0f94c3c9ed35

Logs: https://github.com/MattSturgeon/nixpkgs-review-gha/actions/runs/20337053410


x86_64-darwin (sandbox = relaxed)

✅ 68 packages built:
  • tests.fetchDebianPatch.libPackage
  • tests.fetchDebianPatch.simple
  • tests.fetchFirefoxAddon.simple (tests.fetchFirefoxAddon.overridden-source)
  • tests.fetchFromBitbucket.withEncodedWhitespace
  • tests.fetchFromBitbucket.withEncodedWhitespaceGit
  • tests.fetchFromBitbucket.withoutWhitespace
  • tests.fetchFromGitHub.dumb-http-signed-tag
  • tests.fetchFromGitHub.fetchTags
  • tests.fetchFromGitHub.leave-git
  • tests.fetchFromGitHub.rootDir
  • tests.fetchFromGitHub.simple
  • tests.fetchFromGitHub.sparseCheckout
  • tests.fetchFromGitHub.sparseCheckoutNonConeMode
  • tests.fetchFromGitHub.submodule-deep
  • tests.fetchFromGitHub.submodule-leave-git
  • tests.fetchFromGitHub.submodule-leave-git-deep
  • tests.fetchFromGitHub.submodule-simple
  • tests.fetchNextcloudApp.simple-sha256
  • tests.fetchNextcloudApp.simple-sha512
  • tests.fetchPypiLegacy.fetchSimple
  • tests.fetchgit.collect-rev
  • tests.fetchgit.describe-tag
  • tests.fetchgit.dumb-http-signed-tag
  • tests.fetchgit.fetchTags
  • tests.fetchgit.leave-git
  • tests.fetchgit.prefetch-git-no-add-path
  • tests.fetchgit.rootDir
  • tests.fetchgit.simple
  • tests.fetchgit.simple-tag
  • tests.fetchgit.sparseCheckout
  • tests.fetchgit.sparseCheckoutNonConeMode
  • tests.fetchgit.submodule-deep
  • tests.fetchgit.submodule-leave-git
  • tests.fetchgit.submodule-leave-git-deep
  • tests.fetchgit.submodule-revision-count
  • tests.fetchgit.submodule-simple
  • tests.fetchgit.withGitConfig
  • tests.fetchpatch.decode
  • tests.fetchpatch.fileWithApostrophe
  • tests.fetchpatch.fileWithSpace
  • tests.fetchpatch.full
  • tests.fetchpatch.hunks
  • tests.fetchpatch.relative
  • tests.fetchpatch.simple
  • tests.fetchpatch2.decode
  • tests.fetchpatch2.fileWithApostrophe
  • tests.fetchpatch2.fileWithSpace
  • tests.fetchpatch2.full
  • tests.fetchpatch2.hunks
  • tests.fetchpatch2.relative
  • tests.fetchpatch2.simple
  • tests.fetchurl.flag-appending-curlOpts
  • tests.fetchurl.flag-appending-curlOptsList
  • tests.fetchurl.flag-appending-netrcPhase-curlOpts
  • tests.fetchurl.flag-appending-netrcPhase-curlOptsList
  • tests.fetchurl.hashedMirrors
  • tests.fetchurl.header
  • tests.fetchurl.no-skipPostFetch
  • tests.fetchurl.urls-mirrors
  • tests.fetchurl.urls-simple
  • tests.fetchzip.hiddenDir
  • tests.fetchzip.postFetch
  • tests.fetchzip.simple
  • tests.haskell.cabalSdist.assumptionLocalHasDirectReference
  • tests.haskell.cabalSdist.localHasNoDirectReference
  • tests.testers.runCommand.bork
  • tests.testers.runCommand.dns-resolution
  • tests.testers.runCommand.nonDefault-hash

@ShamrockLee ShamrockLee force-pushed the fetchurl-structuredAttrs-urls-fix branch from 65a6b72 to a3ea395 Compare December 18, 2025 14:03
@ShamrockLee
Copy link
Contributor Author

@SuperSandro2000, are you available for a final look?

@MattSturgeon MattSturgeon force-pushed the fetchurl-structuredAttrs-urls-fix branch from 2a8dade to 20e0811 Compare December 18, 2025 14:32
Comment on lines +150 to +152
urls="$urls2"
urls=("${urlsResolved[@]}")

unset urlsResolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just do unset urls instead of all the "redefine the same name" thing. Let's use urlsResolved further down.

Copy link
Contributor Author

@ShamrockLee ShamrockLee Dec 19, 2025

Choose a reason for hiding this comment

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

This would further change how postFetch would access the URL list. Should we add a release note entry about this fix?

I haven't found any fetchurl's postFetch referencing "$urls", but a close example is fetchelpa referencing $url, the URL of the successful download.

postFetch = ''
if [[ $url == *.lz ]]; then
${lzip}/bin/lzip -c -d $out > uncompressed
mv uncompressed $out
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We never state that the $urls will always be handled the same way in fetchurl.builder across Nixpkgs revision, and developers of downstream projects should be able to handle this.

Applied.

@wolfgangwalther
Copy link
Contributor

Diff LGTM except the nit above; didn't test.

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Dec 18, 2025
Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

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

LGTM

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 3+ This PR was reviewed and approved by three or more persons. and removed 12.approvals: 2 This PR was reviewed and approved by two persons. labels Dec 18, 2025
@ShamrockLee
Copy link
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 471851
Commit: 65a6b72802a240b549d9444715446fef505b8a8d (subsequent changes)
Merge: f2656102259f5b6c63f1baad529d0f94c3c9ed35

Logs: https://github.com/ShamrockLee/nixpkgs-review-gha/actions/runs/20336998231


x86_64-darwin (sandbox = relaxed)

✅ 68 packages built:
  • tests.fetchDebianPatch.libPackage
  • tests.fetchDebianPatch.simple
  • tests.fetchFirefoxAddon.simple (tests.fetchFirefoxAddon.overridden-source)
  • tests.fetchFromBitbucket.withEncodedWhitespace
  • tests.fetchFromBitbucket.withEncodedWhitespaceGit
  • tests.fetchFromBitbucket.withoutWhitespace
  • tests.fetchFromGitHub.dumb-http-signed-tag
  • tests.fetchFromGitHub.fetchTags
  • tests.fetchFromGitHub.leave-git
  • tests.fetchFromGitHub.rootDir
  • tests.fetchFromGitHub.simple
  • tests.fetchFromGitHub.sparseCheckout
  • tests.fetchFromGitHub.sparseCheckoutNonConeMode
  • tests.fetchFromGitHub.submodule-deep
  • tests.fetchFromGitHub.submodule-leave-git
  • tests.fetchFromGitHub.submodule-leave-git-deep
  • tests.fetchFromGitHub.submodule-simple
  • tests.fetchNextcloudApp.simple-sha256
  • tests.fetchNextcloudApp.simple-sha512
  • tests.fetchPypiLegacy.fetchSimple
  • tests.fetchgit.collect-rev
  • tests.fetchgit.describe-tag
  • tests.fetchgit.dumb-http-signed-tag
  • tests.fetchgit.fetchTags
  • tests.fetchgit.leave-git
  • tests.fetchgit.prefetch-git-no-add-path
  • tests.fetchgit.rootDir
  • tests.fetchgit.simple
  • tests.fetchgit.simple-tag
  • tests.fetchgit.sparseCheckout
  • tests.fetchgit.sparseCheckoutNonConeMode
  • tests.fetchgit.submodule-deep
  • tests.fetchgit.submodule-leave-git
  • tests.fetchgit.submodule-leave-git-deep
  • tests.fetchgit.submodule-revision-count
  • tests.fetchgit.submodule-simple
  • tests.fetchgit.withGitConfig
  • tests.fetchpatch.decode
  • tests.fetchpatch.fileWithApostrophe
  • tests.fetchpatch.fileWithSpace
  • tests.fetchpatch.full
  • tests.fetchpatch.hunks
  • tests.fetchpatch.relative
  • tests.fetchpatch.simple
  • tests.fetchpatch2.decode
  • tests.fetchpatch2.fileWithApostrophe
  • tests.fetchpatch2.fileWithSpace
  • tests.fetchpatch2.full
  • tests.fetchpatch2.hunks
  • tests.fetchpatch2.relative
  • tests.fetchpatch2.simple
  • tests.fetchurl.flag-appending-curlOpts
  • tests.fetchurl.flag-appending-curlOptsList
  • tests.fetchurl.flag-appending-netrcPhase-curlOpts
  • tests.fetchurl.flag-appending-netrcPhase-curlOptsList
  • tests.fetchurl.hashedMirrors
  • tests.fetchurl.header
  • tests.fetchurl.no-skipPostFetch
  • tests.fetchurl.urls-mirrors
  • tests.fetchurl.urls-simple
  • tests.fetchzip.hiddenDir
  • tests.fetchzip.postFetch
  • tests.fetchzip.simple
  • tests.haskell.cabalSdist.assumptionLocalHasDirectReference
  • tests.haskell.cabalSdist.localHasNoDirectReference
  • tests.testers.runCommand.bork
  • tests.testers.runCommand.dns-resolution
  • tests.testers.runCommand.nonDefault-hash

@ShamrockLee ShamrockLee force-pushed the fetchurl-structuredAttrs-urls-fix branch from 20e0811 to cfdd4a3 Compare December 19, 2025 13:40
@nixpkgs-ci nixpkgs-ci bot added the 6.topic: testing Tooling for automated testing of packages and modules label Dec 19, 2025
ShamrockLee and others added 6 commits December 19, 2025 22:44
Clean up leftover for commit cd13136
("fetchurl: use __structuredAttrs = true and pass curlOptsList directly")

Continue the work of commit 23236b3
("fetchurl: fix handling of fallback URLs"),
addressing a Bash array re-assignment quirk:
when assigning a Bash array variable as if it were a plain variable,
the value goes to the first element,
and the rest of the array stays the same.

```console
$ foo=(a b)
$ declare -p foo
declare -a foo=([0]="a" [1]="b")
$ foo="c d"
$ declare -p foo
declare -a foo=([0]="c d" [1]="b")
```

Don't rewrite the `${urls[@]}` with resolved URLs,
but hold them with `${resolvedUrls[@]}` instead.

Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
Co-authored-by: Wolfgang Walther <walther@technowledgy.de>
@ShamrockLee ShamrockLee force-pushed the fetchurl-structuredAttrs-urls-fix branch from 3a1ee2a to 0b27145 Compare December 19, 2025 14:44
@ShamrockLee
Copy link
Contributor Author

ShamrockLee commented Dec 19, 2025

I just pushed the following changes:

  • Rename the previously-intermediate variable to resolvedUrls to match the naming convention of other variables.
  • Use resolvedUrls in later fetching instead assigning its value back to urls.
    urls now stays unchanged as specified in the derivation.
  • Improve testers.invalidateFetcherByDrvHash to take fixed-point arguments, to handle pname, and to use <pkg>.overrideAttrs when the fetcher ignores name-arguments.
  • Add test case for showURLs.

Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

Still LGTM. Let's get this merged.

@MattSturgeon MattSturgeon added this pull request to the merge queue Dec 21, 2025
Merged via the queue into NixOS:master with commit 553fe89 Dec 21, 2025
30 of 32 checks passed
theCapypara added a commit to theCapypara/nixpkgs that referenced this pull request Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: fetch Fetchers (e.g. fetchgit, fetchsvn, ...) 6.topic: testing Tooling for automated testing of packages and modules 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 12.approvals: 3+ This PR was reviewed and approved by three or more persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants