summaryrefslogtreecommitdiffstats
path: root/corepkgs
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-10-30 11:27:47 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-10-30 11:27:47 +0100
commitdae5dc7ade60aa6a9a05e41133da7faebe6bdc1b (patch)
tree73dd25edb51c70422e4cb58df6ec885d6c461557 /corepkgs
parent5c28943e8fd19d7eb55865d45d6dc61336aa04e9 (diff)
<nix/fetchurl.nix>: Support downloading and unpacking NARs
This removes the need to have multiple downloads in the stdenv bootstrap process (like a separate busybox binary for Linux, or curl/mkdir/sh/bzip2 for Darwin). Now all those files can be combined into a single NAR.
Diffstat (limited to 'corepkgs')
-rw-r--r--corepkgs/fetchurl.nix15
1 files changed, 11 insertions, 4 deletions
diff --git a/corepkgs/fetchurl.nix b/corepkgs/fetchurl.nix
index 9ecb2225b..5e0ad9da3 100644
--- a/corepkgs/fetchurl.nix
+++ b/corepkgs/fetchurl.nix
@@ -1,12 +1,19 @@
with import <nix/config.nix>;
-{system ? builtins.currentSystem, url, outputHash ? "", outputHashAlgo ? "", md5 ? "", sha1 ? "", sha256 ? "", executable ? false}:
+{ system ? builtins.currentSystem
+, url
+, outputHash ? ""
+, outputHashAlgo ? ""
+, md5 ? "", sha1 ? "", sha256 ? ""
+, executable ? false
+, unpack ? false
+, name ? baseNameOf (toString url)
+}:
assert (outputHash != "" && outputHashAlgo != "")
|| md5 != "" || sha1 != "" || sha256 != "";
derivation {
- name = baseNameOf (toString url);
builder = "builtin:fetchurl";
# New-style output content requirements.
@@ -14,9 +21,9 @@ derivation {
if sha256 != "" then "sha256" else if sha1 != "" then "sha1" else "md5";
outputHash = if outputHash != "" then outputHash else
if sha256 != "" then sha256 else if sha1 != "" then sha1 else md5;
- outputHashMode = if executable then "recursive" else "flat";
+ outputHashMode = if unpack || executable then "recursive" else "flat";
- inherit system url executable;
+ inherit name system url executable unpack;
# No need to double the amount of network traffic
preferLocalBuild = true;