diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-10-30 11:27:47 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-10-30 11:27:47 +0100 |
commit | dae5dc7ade60aa6a9a05e41133da7faebe6bdc1b (patch) | |
tree | 73dd25edb51c70422e4cb58df6ec885d6c461557 /src/libstore | |
parent | 5c28943e8fd19d7eb55865d45d6dc61336aa04e9 (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 'src/libstore')
-rw-r--r-- | src/libstore/builtins.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/libstore/builtins.cc b/src/libstore/builtins.cc index 2a4396308..fefad63bd 100644 --- a/src/libstore/builtins.cc +++ b/src/libstore/builtins.cc @@ -1,5 +1,7 @@ #include "builtins.hh" #include "download.hh" +#include "store-api.hh" +#include "archive.hh" namespace nix { @@ -20,12 +22,21 @@ void builtinFetchurl(const BasicDerivation & drv) auto out = drv.env.find("out"); if (out == drv.env.end()) throw Error("attribute ‘url’ missing"); - writeFile(out->second, data.data); + + Path storePath = out->second; + assertStorePath(storePath); + + auto unpack = drv.env.find("unpack"); + if (unpack != drv.env.end() && unpack->second == "1") { + StringSource source(data.data); + restorePath(storePath, source); + } else + writeFile(storePath, data.data); auto executable = drv.env.find("executable"); if (executable != drv.env.end() && executable->second == "1") { - if (chmod(out->second.c_str(), 0755) == -1) - throw SysError(format("making ‘%1%’ executable") % out->second); + if (chmod(storePath.c_str(), 0755) == -1) + throw SysError(format("making ‘%1%’ executable") % storePath); } } |