mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-16 03:06:17 +02:00
a9b69b2fff
Similar to 1ee42c5b88
, get the "out"
path from the derivation (and complain if it doesn't exist), rather
than getting it from the environment.
30 lines
763 B
C++
30 lines
763 B
C++
#include "builtins.hh"
|
|
#include "tarfile.hh"
|
|
|
|
namespace nix {
|
|
|
|
void builtinUnpackChannel(
|
|
const BasicDerivation & drv,
|
|
const std::map<std::string, Path> & outputs)
|
|
{
|
|
auto getAttr = [&](const std::string & name) {
|
|
auto i = drv.env.find(name);
|
|
if (i == drv.env.end()) throw Error("attribute '%s' missing", name);
|
|
return i->second;
|
|
};
|
|
|
|
auto out = outputs.at("out");
|
|
auto channelName = getAttr("channelName");
|
|
auto src = getAttr("src");
|
|
|
|
createDirs(out);
|
|
|
|
unpackTarfile(src, out);
|
|
|
|
auto entries = readDirectory(out);
|
|
if (entries.size() != 1)
|
|
throw Error("channel tarball '%s' contains more than one file", src);
|
|
renameFile((out + "/" + entries[0].name), (out + "/" + channelName));
|
|
}
|
|
|
|
}
|