Files
nixpkgs/pkgs/build-support/fetchurl/default.nix
Stefan Frijters 0951abd8d2 fetchurl: rework mirrorFile, modernize bash code, add more tests
Write all mirror lists directly to file in a format that bash understands:
no need to parse them out of the `set` command. We prefix the variable names
with '_mirror_' to prevent accidental name clashes.

Also, these lists are now arrays on the bash side, so the builder is updated
to treat them as such. This includes hashedMirror (and NIX_HASHED_MIRRORS
is now also split into an array, if used).

Since mirrorListsFile is no longer a derivation, it is no longer affected by things
like strictDeps and __structuredAttrs.

Stringy curlOpts and NIX_CURL_FLAGS are now added to the curl flags array using concatTo.

Move the resolution of the URLs into a function so we can use more local variables
and clean up the code. The NIX_MIRRORS_${site} env variable, if it is set, overrides
the value that would come from _mirror_${site} from the mirrorsListFile otherwise.

Resolve Shellcheck issues except:
* SC1090: can't follow non-constant source
* SC2154: variable referenced but not assigned (anything that comes from
  the NIX_ATTRS_SH_FILE triggers it)
* SC2250: prefer braces around all variables (this is generally not the
  style in scripts in nixpkgs anyway).

Add some more tests - their relevance is noted in their comments.
Also add short descriptions for the other tests.

Rename a test that had a wrong (and duplicate) name and use finalAttrs instead of rec.
2026-09-13 15:59:02 +02:00

12 KiB