2015-10-30 12:27:47 +02:00
|
|
|
{ system ? builtins.currentSystem
|
|
|
|
, url
|
2017-07-04 15:45:50 +03:00
|
|
|
, md5 ? "", sha1 ? "", sha256 ? "", sha512 ? ""
|
2017-02-16 15:06:47 +02:00
|
|
|
, outputHash ?
|
2017-07-04 15:45:50 +03:00
|
|
|
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 ?
|
2017-07-04 15:45:50 +03:00
|
|
|
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)
|
|
|
|
}:
|
2012-07-08 17:19:17 +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.
|
2017-02-16 15:06:47 +02:00
|
|
|
inherit outputHashAlgo outputHash;
|
2015-10-30 12:27:47 +02:00
|
|
|
outputHashMode = if unpack || executable then "recursive" else "flat";
|
2015-03-24 12:15:45 +02:00
|
|
|
|
2015-10-30 12:27:47 +02:00
|
|
|
inherit name system url executable unpack;
|
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"
|
|
|
|
];
|
2016-09-22 16:48:14 +03:00
|
|
|
|
|
|
|
# To make "nix-prefetch-url" work.
|
|
|
|
urls = [ url ];
|
2012-07-08 17:19:17 +03:00
|
|
|
}
|