2018-01-16 18:07:27 +00:00
|
|
|
{ system ? "" # obsolete
|
2015-10-30 10:27:47 +00:00
|
|
|
, url
|
2020-11-18 04:20:50 +00:00
|
|
|
, hash ? "" # an SRI hash
|
2018-12-13 13:30:52 +00:00
|
|
|
|
|
|
|
# Legacy hash specification
|
2017-07-04 12:45:50 +00:00
|
|
|
, md5 ? "", sha1 ? "", sha256 ? "", sha512 ? ""
|
2017-02-16 13:06:47 +00:00
|
|
|
, outputHash ?
|
2018-12-13 13:30:52 +00: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 13:06:47 +00:00
|
|
|
, outputHashAlgo ?
|
2018-12-13 13:30:52 +00:00
|
|
|
if hash != "" then "" else if sha512 != "" then "sha512" else if sha1 != "" then "sha1" else if md5 != "" then "md5" else "sha256"
|
|
|
|
|
2015-10-30 10:27:47 +00:00
|
|
|
, executable ? false
|
|
|
|
, unpack ? false
|
|
|
|
, name ? baseNameOf (toString url)
|
|
|
|
}:
|
2012-07-08 14:19:17 +00:00
|
|
|
|
|
|
|
derivation {
|
2015-07-20 02:30:16 +00:00
|
|
|
builder = "builtin:fetchurl";
|
2012-07-08 14:19:17 +00:00
|
|
|
|
|
|
|
# New-style output content requirements.
|
2017-02-16 13:06:47 +00:00
|
|
|
inherit outputHashAlgo outputHash;
|
2015-10-30 10:27:47 +00:00
|
|
|
outputHashMode = if unpack || executable then "recursive" else "flat";
|
2015-03-24 10:15:45 +00:00
|
|
|
|
2018-01-16 18:07:27 +00:00
|
|
|
inherit name url executable unpack;
|
|
|
|
|
|
|
|
system = "builtin";
|
2012-07-08 15:11:02 +00:00
|
|
|
|
|
|
|
# No need to double the amount of network traffic
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
2014-07-16 05:11:24 +00: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"
|
|
|
|
];
|
2016-09-22 13:48:14 +00:00
|
|
|
|
|
|
|
# To make "nix-prefetch-url" work.
|
|
|
|
urls = [ url ];
|
2012-07-08 14:19:17 +00:00
|
|
|
}
|