332 Commits

Author SHA1 Message Date
Eman Resu
28e6e36fa0 build-support/fetchurl: remove warnIf usage
warnIf sends our warning message through a function call, even if the
warning condition doesn't trigger. This requires a lot of thunk
allocation that can be easily avoided.
2026-05-28 00:19:37 -04:00
Eman Resu
a350fc4a03 fetchurl: use concatMap rather than filtering and mapping 2026-05-11 16:11:01 -04:00
Ming-Chuan
23dc2d1a97 fetchurl/mirrors: remove funet.fi from KDE mirror list
It serves incorrect krita 5.2.14 source archive
2026-02-22 04:38:33 +08:00
Yueh-Shun Li
0b271455ec tests.fetchurl: add showURLs-urls-mirrors 2025-12-19 22:44:22 +08:00
Yueh-Shun Li
d8ac71ce95 tests.fetchurl: add urls-mirrors 2025-12-19 22:44:21 +08:00
Yueh-Shun Li
fc180191de fetchurl: builder.sh: handle urls as a Bash array
Clean up leftover for commit cd13136f03
("fetchurl: use __structuredAttrs = true and pass curlOptsList directly")

Continue the work of commit 23236b331d
("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>
2025-12-19 22:44:12 +08:00
Matt Sturgeon
1e5ca4eadb fetchurl: add doc-comment for fetchurl.resolveUrl 2025-12-18 21:00:38 +08:00
Yueh-Shun Li
ca050c53b2 fetchurl: provide fetchurl.resolveUrl 2025-12-18 17:01:40 +08:00
Yueh-Shun Li
7c4673bbb8 tests.fetchurl: add urls-simple 2025-12-18 17:01:39 +08:00
Yueh-Shun Li
270ee9e19b fetchurl: mirrorList: simplify expression
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
2025-12-18 17:01:31 +08:00
Yueh-Shun Li
d0f0e55689 tests.fetchurl: add test flag-appending-netrcPhase-curlOptsList 2025-12-18 06:12:03 +08:00
Yueh-Shun Li
dd7414ba7f tests.fetchurl: add flag-appending tests 2025-12-18 06:10:43 +08:00
Yueh-Shun Li
04419e1b96 fetchurl: builder.sh: simplify curlOpts/curlOptsList appending 2025-12-18 02:53:23 +08:00
Yueh-Shun Li
b9f1e058ae fetchurl: builder.sh: convert curlOpts to string if array encountered
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
2025-12-18 02:52:48 +08:00
Yueh-Shun Li
915b484681 fetchurl: move netrcPhase invokation into build.sh
Don't rely on the `postPhase` in `$stdenv/setup.sh` provided by
`stdenv/generic/make-derivation.nix`'s realBuilder hack.
2025-12-17 20:43:01 +08:00
Yueh-Shun Li
5cbd4c3667 Revert "fetchurl, fetchgitlab: fix curlOpts extension" (#470831) 2025-12-15 18:22:29 +00:00
Yueh-Shun Li
58366ffe0c Revert "fetchurl, fetchgitlab: fix curlOpts extension" 2025-12-15 01:03:34 +08:00
Sergei Trofimovich
23236b331d fetchurl: fix handling of fallback URLs
Without the change fallback to `urls = []` does not
work as `$urls` evaluates on ony first entry. Use
`${urls[@]}` instead.

Example derivation that is fixed in `master` is
`xterm.src`:

Before:

    $ nix build --no-link -f. xterm.src --rebuild -L
    xterm> structuredAttrs is enabled
    ...
    xterm> trying ftp://ftp.invisible-island.net/xterm/xterm-403.tgz
    ...
    xterm> curl: (67) Access denied: 550
    xterm> error: cannot download xterm-403.tgz from any mirror

After:

    $ nix build --no-link -f. xterm.src --rebuild -L
    xterm> structuredAttrs is enabled
    ...
    xterm> trying ftp://ftp.invisible-island.net/xterm/xterm-403.tgz
    ...
    xterm> curl: (67) Access denied: 550
    ...
    xterm> trying https://invisible-mirror.net/archives/xterm/xterm-403.tgz
    xterm>   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    xterm>                                  Dload  Upload   Total   Spent    Left  Speed
    xterm> 100  1577k 100  1577k   0     0 703670     0   0:00:02  0:00:02 --:--:-- 703866
2025-12-14 07:22:20 +00:00
Matt Sturgeon
55172e9583 fetchurl, fetchgitlab: fix curlOpts extension (#470550) 2025-12-13 22:16:44 +00:00
Nicolas Benes
3db11767a9 fetchurl, fetchgitlab: fix curlOpts extension
PR #464475 enables __structuredAttrs and makes curlOpts a bash array.
Consequently, it must be extended as such to be effective.

See also https://github.com/NixOS/nixpkgs/pull/464475#issuecomment-3649765507
2025-12-13 22:47:01 +01:00
Yueh-Shun Li
303ef6a5c9 fetchurl: pass SSL_CERT_FILE as environment variable via env 2025-12-14 01:30:39 +08:00
Yueh-Shun Li
689380e029 fetchurl, fetchgit: use __structuredAttrs = true and pass curlOptsList and sparseCheckout as lists (#464475) 2025-12-11 18:25:29 +00:00
Yueh-Shun Li
ae800ea500 fetchurl: reference outputHash from finalAttrs.hash 2025-12-10 01:02:47 +08:00
Yueh-Shun Li
cf99863262 fetchurl: reference lib.fakeHash for empty hash algorithm 2025-12-10 01:02:47 +08:00
Yueh-Shun Li
cd13136f03 fetchurl: use __structuredAttrs = true and pass curlOptsList directly 2025-12-09 12:34:45 +08:00
Yueh-Shun Li
4535777468 fetchurl: sort inherited variables 2025-12-09 12:34:45 +08:00
Philip Taron
49af83567b fetchurl: make pname and version overridable via <pkg>.overrideAttrs (#458183) 2025-11-05 16:23:24 +00:00
Yueh-Shun Li
7e212bfdd5 fetchurl: fix pname and version overriding 2025-11-04 15:11:29 +08:00
Yueh-Shun Li
4ab091862a fetchurl: take derivationArgs 2025-11-03 21:31:02 +08:00
Yueh-Shun Li
1ec0227cc0 fetchurl: don't treat empty-string name special 2025-10-28 06:43:13 +08:00
Yueh-Shun Li
aeddd850c6 fetchurl, fetchzip, fetchgit: format Nix expression after lib.extendMkDerivation 2025-10-28 06:41:42 +08:00
Yueh-Shun Li
bf3e7097f3 fetchurl: restructure with lib.extendMkDerivation (not formatted) 2025-10-28 06:38:45 +08:00
Yueh-Shun Li
089fab12e3 fetchurl: move curlOpts warnings down to its value 2025-10-28 06:38:45 +08:00
Silvan Mosberger
56f680d915 fetchurl: Allow hashed mirror overriding with config.hashedMirrors
Allows having alternate hashed mirrors as fallbacks. Useful in case the
default hashed mirror is not accessible or doesn't have everything
needed.

Co-authored-by: Johan Herland <johan.herland@tweag.io>
Co-authored-by: Yuriy Taraday <yuriy.taraday@tweag.io>
Co-authored-by: Alexander Bantyev <balsoft@balsoft.ru>
2025-10-06 14:15:10 +02:00
Alexander Bantyev
27a36aeb9c fetchurl: fix hashedMirrors with downloadToTemp
fetchurl supports postFetch, which must not run when fetching from
hashedMirrors, because they provide pre-built derivation outputs.

fetchurl also supports downloadToTemp, which modifies behavior relating
to postFetch.

Before this commit, a call like

    fetchurl {
      url = "...";
      downloadToTemp = true;
      postFetch = ''
        mv "$downloadedFile" "$out"
      '';
    }

would work in normal scenarios, but fail when fetching from
hashedMirrors, due to how internally downloadToTemp was not tied to
postFetch as closely as it should've been. This resulted in an error
like

    builder [...] failed to produce output path

This commit fixes this, making hashedMirror fetching work even for
derivations that have downloadToTemp enabled.

Co-Authored-By: Silvan Mosberger <silvan.mosberger@tweag.io>
2025-09-29 23:46:44 +02:00
Rebecca Turner
3d4fb2c3e6 fetchurl: Add missing arg to toPretty invocation
Thanks to @emilazy for the report:
https://github.com/NixOS/nixpkgs/pull/393136#issuecomment-3268711663

Fixes this crash:

```
… from call site
  at /Users/emily/Developer/nixpkgs/pkgs/build-support/fetchurl/default.nix:194:70:
   193|     else
   194|       throw "fetchurl requires a hash for fixed-output derivation: ${lib.generators.toPretty urls_}";
      |                                                                      ^
   195|

… while evaluating the value passed for the lambda argument
  at /Users/emily/Developer/nixpkgs/lib/generators.nix:524:5:
   523|   toPretty =
   524|     {
      |     ^
   525|       allowPrettyValues ? false,

error: expected a set but found a list: [ "https://cmake.org/files/v4.1/cmake-4.1.1.tar.gz" ]
```

It'll still crash, but with a nicer error message!
2025-09-09 10:06:26 -07:00
nixpkgs-ci[bot]
f17dc1e31b Merge staging-next into staging 2025-08-05 18:07:00 +00:00
Sergei Trofimovich
425c7e46a0 fetchurl: fix resolvedUrl eval on URLs without mirror:// prefix
Without the change `resolvedUrl` fails on non-mirror:// packages as:

    $ nix eval --impure --expr 'with import ./. {}; AMB-plugins.src.resolvedUrl'
    error:
       ...
       error: expected a list but found null: null

After ther change the eval works as expected:

    $ nix eval --impure --expr 'with import ./. {}; AMB-plugins.src.resolvedUrl'
    "http://kokkinizita.linuxaudio.org/linuxaudio/downloads/AMB-plugins-0.8.1.tar.bz2"
2025-08-05 09:31:42 +01:00
nixpkgs-ci[bot]
52a71c4fb2 Merge staging-next into staging 2025-08-05 00:19:45 +00:00
Sandro Jäckel
aa9a2250c8 fetchurl: add passthru resolvedUrl
This can be used to resolve mirror:// style URLs to a full URL any http
tool understands.
2025-08-04 20:02:49 +02:00
Wolfgang Walther
90604d95bc Merge branch 'staging-next' into staging 2025-07-24 14:33:09 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Silvan Mosberger
28e72a42c7 gnupg: Remove broken mirrors
None of these two mirrors have any of the sources these mirrors are used
for, checked with `nix-build <pkg>.src --check` while only those two are
not commented.
2025-07-22 19:51:09 +02:00
famfo
7b40ca82b0 fetchurl: remove broken/outdated GNOME mirrors
- ftp.belnet.be is outdated
- ftp.acc.umu.se returns a 403
- fr2.rpmfind.net is outdated
- ftp.nara.wide.ad.jp is outdated
- ftp.cse.buffalo.edu is unresponsive
2025-07-14 15:24:45 +02:00
Johan Herland
abda866f17 fetchurl: Add hook for rewriting/filtering URLs
This allows on-the-fly rewriting of URLs before they are passed from
fetchurl (or fetchurlBoot) to curl.

The intended use is to allow inserting company-internal mirrors, or
working around company firewalls and similar network restrictions,
without having to extensively patch across all of nixpkgs. Instead,
users can pass a function in their nixpkgs that performs the necessary
URL rewrites.

Co-authored-by: Alexander Bantyev <balsoft@balsoft.ru>
2025-06-04 10:29:08 +00:00
Winter
40d5f4e0a0 fetchurl: don't prefer hashed mirrors by default
Right now, when building any FOD that uses `fetchurl` (which is the
majority of ours), `tarballs.nixos.org` will always be contacted
before the actual URL. Given that `tarballs.nixos.org` mainly hosts
the bootstrap tools, which already explicitly set it as the host to pull
from, it doesn't make much sense to force every other `fetchurl`
invocation to first reach out to `tarballs.nixos.org`.
2025-05-08 03:23:14 -04:00
Jan Malakhovski
f585b6c33a fetchurl: update samba mirrors' URLs 2025-04-02 18:12:01 +00:00
Jan Malakhovski
48ecbdfa9a fetchurl: improve GNU Savannah mirrors 2025-04-02 18:12:00 +00:00
Rebecca Turner
33044b9bd8 fetchurl: Improve error messages
I recently saw this error message, which required I use the `--debugger`
to locate:

```
error:
       … while evaluating an expression to select 'drvPath' on it
         at «internal»:1:552:
       … while calling the 'derivationStrict' builtin
         at «internal»:1:208:
       (stack trace truncated; use '--show-trace' to show the full trace)

       error: multiple hashes passed to fetchurl
```

This patch improves the error message, and other error messages from
`fetchurl`:

```
error:
       … while evaluating an expression to select 'drvPath' on it
         at «internal»:1:552:
       … while calling the 'derivationStrict' builtin
         at «internal»:1:208:
       (stack trace truncated; use '--show-trace' to show the full trace)

       error: multiple hashes passed to fetchurl: [
         "https://github.com/reorg/pg_repack/archive/refs/tags/ver_1.5.0.tar.gz"
       ]
```
2025-03-25 10:11:28 -07:00
Philip Taron
e43d648ac1 fetchurl: improve error handling flags to curl to retry harder (#358042) 2025-01-27 05:23:23 -08:00