2018-01-16 20:07:27 +02:00
|
|
|
{ system ? "" # obsolete
|
2015-10-30 12:27:47 +02:00
|
|
|
, url
|
2020-11-18 06:20:50 +02:00
|
|
|
, hash ? "" # an SRI hash
|
2018-12-13 15:30:52 +02:00
|
|
|
|
|
|
|
# Legacy hash specification
|
2017-07-04 15:45:50 +03:00
|
|
|
, md5 ? "", sha1 ? "", sha256 ? "", sha512 ? ""
|
2017-02-16 15:06:47 +02:00
|
|
|
, outputHash ?
|
2018-12-13 15:30:52 +02:00
|
|
|
if hash != "" then hash else if sha512 != "" then sha512 else if sha1 != "" then sha1 else if md5 != "" then md5 else sha256
|
2017-02-16 15:06:47 +02:00
|
|
|
, outputHashAlgo ?
|
2018-12-13 15:30:52 +02:00
|
|
|
if hash != "" then "" else if sha512 != "" then "sha512" else if sha1 != "" then "sha1" else if md5 != "" then "md5" else "sha256"
|
|
|
|
|
2015-10-30 12:27:47 +02:00
|
|
|
, executable ? false
|
|
|
|
, unpack ? false
|
|
|
|
, name ? baseNameOf (toString url)
|
2022-09-16 11:51:14 +03:00
|
|
|
, impure ? false
|
2015-10-30 12:27:47 +02:00
|
|
|
}:
|
2012-07-08 17:19:17 +03:00
|
|
|
|
2022-09-16 10:47:54 +03:00
|
|
|
derivation ({
|
2015-07-20 05:30:16 +03:00
|
|
|
builder = "builtin:fetchurl";
|
2012-07-08 17:19:17 +03:00
|
|
|
|
|
|
|
# New-style output content requirements.
|
2015-10-30 12:27:47 +02:00
|
|
|
outputHashMode = if unpack || executable then "recursive" else "flat";
|
2015-03-24 12:15:45 +02:00
|
|
|
|
2018-01-16 20:07:27 +02:00
|
|
|
inherit name url executable unpack;
|
|
|
|
|
|
|
|
system = "builtin";
|
2012-07-08 18:11:02 +03:00
|
|
|
|
|
|
|
# No need to double the amount of network traffic
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
2014-07-16 08:11:24 +03:00
|
|
|
impureEnvVars = [
|
|
|
|
# We borrow these environment variables from the caller to allow
|
|
|
|
# easy proxy configuration. This is impure, but a fixed-output
|
|
|
|
# derivation like fetchurl is allowed to do so since its result is
|
|
|
|
# by definition pure.
|
|
|
|
"http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy"
|
2024-05-06 22:39:22 +03:00
|
|
|
"HTTP_PROXY" "HTTPS_PROXY" "FTP_PROXY" "ALL_PROXY" "NO_PROXY"
|
2014-07-16 08:11:24 +03:00
|
|
|
];
|
2016-09-22 16:48:14 +03:00
|
|
|
|
|
|
|
# To make "nix-prefetch-url" work.
|
|
|
|
urls = [ url ];
|
2022-09-16 11:52:20 +03:00
|
|
|
} // (if impure
|
|
|
|
then { __impure = true; }
|
2022-09-16 10:47:54 +03:00
|
|
|
else { inherit outputHashAlgo outputHash; }))
|