From dae5dc7ade60aa6a9a05e41133da7faebe6bdc1b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 30 Oct 2015 11:27:47 +0100 Subject: : 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. --- src/libstore/builtins.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/libstore/builtins.cc') diff --git a/src/libstore/builtins.cc b/src/libstore/builtins.cc index 2a4396308399..fefad63bd1bb 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); } } -- cgit 1.4.1