mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-01-31 15:36:47 +02:00
builtin:{unpack-channel,buildenv}: Get output path from the derivation
Similar to 1ee42c5b88
, get the "out"
path from the derivation (and complain if it doesn't exist), rather
than getting it from the environment.
This commit is contained in:
parent
c4ebb82da4
commit
a9b69b2fff
7 changed files with 33 additions and 23 deletions
|
@ -2130,16 +2130,17 @@ void LocalDerivationGoal::runChild()
|
||||||
try {
|
try {
|
||||||
logger = makeJSONLogger(*logger);
|
logger = makeJSONLogger(*logger);
|
||||||
|
|
||||||
BasicDerivation & drv2(*drv);
|
std::map<std::string, Path> outputs;
|
||||||
for (auto & e : drv2.env)
|
for (auto & e : drv->outputs)
|
||||||
e.second = rewriteStrings(e.second, inputRewrites);
|
outputs.insert_or_assign(e.first,
|
||||||
|
worker.store.printStorePath(scratchOutputs.at(e.first)));
|
||||||
|
|
||||||
if (drv->builder == "builtin:fetchurl")
|
if (drv->builder == "builtin:fetchurl")
|
||||||
builtinFetchurl(drv2, netrcData);
|
builtinFetchurl(*drv, outputs, netrcData);
|
||||||
else if (drv->builder == "builtin:buildenv")
|
else if (drv->builder == "builtin:buildenv")
|
||||||
builtinBuildenv(drv2);
|
builtinBuildenv(*drv, outputs);
|
||||||
else if (drv->builder == "builtin:unpack-channel")
|
else if (drv->builder == "builtin:unpack-channel")
|
||||||
builtinUnpackChannel(drv2);
|
builtinUnpackChannel(*drv, outputs);
|
||||||
else
|
else
|
||||||
throw Error("unsupported builtin builder '%1%'", drv->builder.substr(8));
|
throw Error("unsupported builtin builder '%1%'", drv->builder.substr(8));
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
|
|
@ -106,7 +106,7 @@ struct LocalDerivationGoal : public DerivationGoal
|
||||||
RedirectedOutputs redirectedOutputs;
|
RedirectedOutputs redirectedOutputs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The outputs paths used during the build.
|
* The output paths used during the build.
|
||||||
*
|
*
|
||||||
* - Input-addressed derivations or fixed content-addressed outputs are
|
* - Input-addressed derivations or fixed content-addressed outputs are
|
||||||
* sometimes built when some of their outputs already exist, and can not
|
* sometimes built when some of their outputs already exist, and can not
|
||||||
|
|
|
@ -6,7 +6,13 @@
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
// TODO: make pluggable.
|
// TODO: make pluggable.
|
||||||
void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData);
|
void builtinFetchurl(
|
||||||
void builtinUnpackChannel(const BasicDerivation & drv);
|
const BasicDerivation & drv,
|
||||||
|
const std::map<std::string, Path> & outputs,
|
||||||
|
const std::string & netrcData);
|
||||||
|
|
||||||
|
void builtinUnpackChannel(
|
||||||
|
const BasicDerivation & drv,
|
||||||
|
const std::map<std::string, Path> & outputs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,9 @@ void buildProfile(const Path & out, Packages && pkgs)
|
||||||
debug("created %d symlinks in user environment", state.symlinks);
|
debug("created %d symlinks in user environment", state.symlinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void builtinBuildenv(const BasicDerivation & drv)
|
void builtinBuildenv(
|
||||||
|
const BasicDerivation & drv,
|
||||||
|
const std::map<std::string, Path> & outputs)
|
||||||
{
|
{
|
||||||
auto getAttr = [&](const std::string & name) {
|
auto getAttr = [&](const std::string & name) {
|
||||||
auto i = drv.env.find(name);
|
auto i = drv.env.find(name);
|
||||||
|
@ -169,7 +171,7 @@ void builtinBuildenv(const BasicDerivation & drv)
|
||||||
return i->second;
|
return i->second;
|
||||||
};
|
};
|
||||||
|
|
||||||
Path out = getAttr("out");
|
auto out = outputs.at("out");
|
||||||
createDirs(out);
|
createDirs(out);
|
||||||
|
|
||||||
/* Convert the stuff we get from the environment back into a
|
/* Convert the stuff we get from the environment back into a
|
||||||
|
|
|
@ -45,6 +45,8 @@ typedef std::vector<Package> Packages;
|
||||||
|
|
||||||
void buildProfile(const Path & out, Packages && pkgs);
|
void buildProfile(const Path & out, Packages && pkgs);
|
||||||
|
|
||||||
void builtinBuildenv(const BasicDerivation & drv);
|
void builtinBuildenv(
|
||||||
|
const BasicDerivation & drv,
|
||||||
|
const std::map<std::string, Path> & outputs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
|
void builtinFetchurl(
|
||||||
|
const BasicDerivation & drv,
|
||||||
|
const std::map<std::string, Path> & outputs,
|
||||||
|
const std::string & netrcData)
|
||||||
{
|
{
|
||||||
/* Make the host's netrc data available. Too bad curl requires
|
/* Make the host's netrc data available. Too bad curl requires
|
||||||
this to be stored in a file. It would be nice if we could just
|
this to be stored in a file. It would be nice if we could just
|
||||||
|
@ -24,14 +27,8 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
|
||||||
if (!dof)
|
if (!dof)
|
||||||
throw Error("'builtin:fetchurl' must be a fixed-output derivation");
|
throw Error("'builtin:fetchurl' must be a fixed-output derivation");
|
||||||
|
|
||||||
auto getAttr = [&](const std::string & name) {
|
auto storePath = outputs.at("out");
|
||||||
auto i = drv.env.find(name);
|
auto mainUrl = drv.env.at("url");
|
||||||
if (i == drv.env.end()) throw Error("attribute '%s' missing", name);
|
|
||||||
return i->second;
|
|
||||||
};
|
|
||||||
|
|
||||||
Path storePath = getAttr("out");
|
|
||||||
auto mainUrl = getAttr("url");
|
|
||||||
bool unpack = getOr(drv.env, "unpack", "") == "1";
|
bool unpack = getOr(drv.env, "unpack", "") == "1";
|
||||||
|
|
||||||
/* Note: have to use a fresh fileTransfer here because we're in
|
/* Note: have to use a fresh fileTransfer here because we're in
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
void builtinUnpackChannel(const BasicDerivation & drv)
|
void builtinUnpackChannel(
|
||||||
|
const BasicDerivation & drv,
|
||||||
|
const std::map<std::string, Path> & outputs)
|
||||||
{
|
{
|
||||||
auto getAttr = [&](const std::string & name) {
|
auto getAttr = [&](const std::string & name) {
|
||||||
auto i = drv.env.find(name);
|
auto i = drv.env.find(name);
|
||||||
|
@ -11,7 +13,7 @@ void builtinUnpackChannel(const BasicDerivation & drv)
|
||||||
return i->second;
|
return i->second;
|
||||||
};
|
};
|
||||||
|
|
||||||
Path out = getAttr("out");
|
auto out = outputs.at("out");
|
||||||
auto channelName = getAttr("channelName");
|
auto channelName = getAttr("channelName");
|
||||||
auto src = getAttr("src");
|
auto src = getAttr("src");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue