forked from lix-project/lix
Merge remote-tracking branch 'upstream/master' into make-narHash-not-optional
This commit is contained in:
commit
5e59b25a23
|
@ -170,7 +170,45 @@ static int _main(int argc, char * * argv)
|
||||||
if (rightType && !canBuildLocally)
|
if (rightType && !canBuildLocally)
|
||||||
std::cerr << "# postpone\n";
|
std::cerr << "# postpone\n";
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// build the hint template.
|
||||||
|
string hintstring = "derivation: %s\nrequired (system, features): (%s, %s)";
|
||||||
|
hintstring += "\n%s available machines:";
|
||||||
|
hintstring += "\n(systems, maxjobs, supportedFeatures, mandatoryFeatures)";
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < machines.size(); ++i) {
|
||||||
|
hintstring += "\n(%s, %s, %s, %s)";
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the template values.
|
||||||
|
string drvstr;
|
||||||
|
if (drvPath.has_value())
|
||||||
|
drvstr = drvPath->to_string();
|
||||||
|
else
|
||||||
|
drvstr = "<unknown>";
|
||||||
|
|
||||||
|
auto hint = hintformat(hintstring);
|
||||||
|
hint
|
||||||
|
% drvstr
|
||||||
|
% neededSystem
|
||||||
|
% concatStringsSep<StringSet>(", ", requiredFeatures)
|
||||||
|
% machines.size();
|
||||||
|
|
||||||
|
for (auto & m : machines) {
|
||||||
|
hint % concatStringsSep<vector<string>>(", ", m.systemTypes)
|
||||||
|
% m.maxJobs
|
||||||
|
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
|
||||||
|
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
|
||||||
|
}
|
||||||
|
|
||||||
|
logError({
|
||||||
|
.name = "Remote build",
|
||||||
|
.description = "Failed to find a machine for remote build!",
|
||||||
|
.hint = hint
|
||||||
|
});
|
||||||
|
|
||||||
std::cerr << "# decline\n";
|
std::cerr << "# decline\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4876,8 +4876,17 @@ void Worker::run(const Goals & _topGoals)
|
||||||
waitForInput();
|
waitForInput();
|
||||||
else {
|
else {
|
||||||
if (awake.empty() && 0 == settings.maxBuildJobs)
|
if (awake.empty() && 0 == settings.maxBuildJobs)
|
||||||
|
{
|
||||||
|
if (getMachines().empty())
|
||||||
throw Error("unable to start any build; either increase '--max-jobs' "
|
throw Error("unable to start any build; either increase '--max-jobs' "
|
||||||
"or enable remote builds");
|
"or enable remote builds."
|
||||||
|
"\nhttps://nixos.org/nix/manual/#chap-distributed-builds");
|
||||||
|
else
|
||||||
|
throw Error("unable to start any build; remote machines may not have "
|
||||||
|
"all required system features."
|
||||||
|
"\nhttps://nixos.org/nix/manual/#chap-distributed-builds");
|
||||||
|
|
||||||
|
}
|
||||||
assert(!awake.empty());
|
assert(!awake.empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,17 +64,24 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
|
||||||
|
|
||||||
if (dryRun) return;
|
if (dryRun) return;
|
||||||
|
|
||||||
if (outLink != "") {
|
if (outLink != "")
|
||||||
for (size_t i = 0; i < buildables.size(); ++i) {
|
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
|
||||||
for (auto & output : buildables[i].outputs)
|
for (size_t i = 0; i < buildables.size(); ++i)
|
||||||
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) {
|
std::visit(overloaded {
|
||||||
|
[&](BuildableOpaque bo) {
|
||||||
|
std::string symlink = outLink;
|
||||||
|
if (i) symlink += fmt("-%d", i);
|
||||||
|
store2->addPermRoot(bo.path, absPath(symlink), true);
|
||||||
|
},
|
||||||
|
[&](BuildableFromDrv bfd) {
|
||||||
|
for (auto & output : bfd.outputs) {
|
||||||
std::string symlink = outLink;
|
std::string symlink = outLink;
|
||||||
if (i) symlink += fmt("-%d", i);
|
if (i) symlink += fmt("-%d", i);
|
||||||
if (output.first != "out") symlink += fmt("-%s", output.first);
|
if (output.first != "out") symlink += fmt("-%s", output.first);
|
||||||
store2->addPermRoot(output.second, absPath(symlink), true);
|
store2->addPermRoot(output.second, absPath(symlink), true);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}, buildables[i]);
|
||||||
|
|
||||||
updateProfile(buildables);
|
updateProfile(buildables);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,20 +128,25 @@ void MixProfile::updateProfile(const Buildables & buildables)
|
||||||
{
|
{
|
||||||
if (!profile) return;
|
if (!profile) return;
|
||||||
|
|
||||||
std::optional<StorePath> result;
|
std::vector<StorePath> result;
|
||||||
|
|
||||||
for (auto & buildable : buildables) {
|
for (auto & buildable : buildables) {
|
||||||
for (auto & output : buildable.outputs) {
|
std::visit(overloaded {
|
||||||
if (result)
|
[&](BuildableOpaque bo) {
|
||||||
throw Error("'--profile' requires that the arguments produce a single store path, but there are multiple");
|
result.push_back(bo.path);
|
||||||
result = output.second;
|
},
|
||||||
|
[&](BuildableFromDrv bfd) {
|
||||||
|
for (auto & output : bfd.outputs) {
|
||||||
|
result.push_back(output.second);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
}, buildable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result)
|
if (result.size() != 1)
|
||||||
throw Error("'--profile' requires that the arguments produce a single store path, but there are none");
|
throw Error("'--profile' requires that the arguments produce a single store path, but there are %d", result.size());
|
||||||
|
|
||||||
updateProfile(*result);
|
updateProfile(result[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
MixDefaultProfile::MixDefaultProfile()
|
MixDefaultProfile::MixDefaultProfile()
|
||||||
|
|
|
@ -308,16 +308,15 @@ struct InstallableStorePath : Installable
|
||||||
for (auto & [name, output] : drv.outputs)
|
for (auto & [name, output] : drv.outputs)
|
||||||
outputs.emplace(name, output.path(*store, drv.name));
|
outputs.emplace(name, output.path(*store, drv.name));
|
||||||
return {
|
return {
|
||||||
Buildable {
|
BuildableFromDrv {
|
||||||
.drvPath = storePath,
|
.drvPath = storePath,
|
||||||
.outputs = std::move(outputs)
|
.outputs = std::move(outputs)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
Buildable {
|
BuildableOpaque {
|
||||||
.drvPath = {},
|
.path = storePath,
|
||||||
.outputs = {{"out", storePath}}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -333,32 +332,19 @@ Buildables InstallableValue::toBuildables()
|
||||||
{
|
{
|
||||||
Buildables res;
|
Buildables res;
|
||||||
|
|
||||||
StorePathSet drvPaths;
|
std::map<StorePath, OutputPathMap> drvsToOutputs;
|
||||||
|
|
||||||
|
// Group by derivation, helps with .all in particular
|
||||||
for (auto & drv : toDerivations()) {
|
for (auto & drv : toDerivations()) {
|
||||||
Buildable b{.drvPath = drv.drvPath};
|
|
||||||
drvPaths.insert(drv.drvPath);
|
|
||||||
|
|
||||||
auto outputName = drv.outputName;
|
auto outputName = drv.outputName;
|
||||||
if (outputName == "")
|
if (outputName == "")
|
||||||
throw Error("derivation '%s' lacks an 'outputName' attribute", state->store->printStorePath(*b.drvPath));
|
throw Error("derivation '%s' lacks an 'outputName' attribute", state->store->printStorePath(drv.drvPath));
|
||||||
|
drvsToOutputs[drv.drvPath].insert_or_assign(outputName, drv.outPath);
|
||||||
b.outputs.emplace(outputName, drv.outPath);
|
|
||||||
|
|
||||||
res.push_back(std::move(b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hack to recognize .all: if all drvs have the same drvPath,
|
for (auto & i : drvsToOutputs)
|
||||||
// merge the buildables.
|
res.push_back(BuildableFromDrv { i.first, i.second });
|
||||||
if (drvPaths.size() == 1) {
|
|
||||||
Buildable b{.drvPath = *drvPaths.begin()};
|
|
||||||
for (auto & b2 : res)
|
|
||||||
for (auto & output : b2.outputs)
|
|
||||||
b.outputs.insert_or_assign(output.first, output.second);
|
|
||||||
Buildables bs;
|
|
||||||
bs.push_back(std::move(b));
|
|
||||||
return bs;
|
|
||||||
} else
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,14 +642,17 @@ Buildables build(ref<Store> store, Realise mode,
|
||||||
|
|
||||||
for (auto & i : installables) {
|
for (auto & i : installables) {
|
||||||
for (auto & b : i->toBuildables()) {
|
for (auto & b : i->toBuildables()) {
|
||||||
if (b.drvPath) {
|
std::visit(overloaded {
|
||||||
|
[&](BuildableOpaque bo) {
|
||||||
|
pathsToBuild.push_back({bo.path});
|
||||||
|
},
|
||||||
|
[&](BuildableFromDrv bfd) {
|
||||||
StringSet outputNames;
|
StringSet outputNames;
|
||||||
for (auto & output : b.outputs)
|
for (auto & output : bfd.outputs)
|
||||||
outputNames.insert(output.first);
|
outputNames.insert(output.first);
|
||||||
pathsToBuild.push_back({*b.drvPath, outputNames});
|
pathsToBuild.push_back({bfd.drvPath, outputNames});
|
||||||
} else
|
},
|
||||||
for (auto & output : b.outputs)
|
}, b);
|
||||||
pathsToBuild.push_back({output.second});
|
|
||||||
buildables.push_back(std::move(b));
|
buildables.push_back(std::move(b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -684,16 +673,23 @@ StorePathSet toStorePaths(ref<Store> store,
|
||||||
|
|
||||||
if (operateOn == OperateOn::Output) {
|
if (operateOn == OperateOn::Output) {
|
||||||
for (auto & b : build(store, mode, installables))
|
for (auto & b : build(store, mode, installables))
|
||||||
for (auto & output : b.outputs)
|
std::visit(overloaded {
|
||||||
|
[&](BuildableOpaque bo) {
|
||||||
|
outPaths.insert(bo.path);
|
||||||
|
},
|
||||||
|
[&](BuildableFromDrv bfd) {
|
||||||
|
for (auto & output : bfd.outputs)
|
||||||
outPaths.insert(output.second);
|
outPaths.insert(output.second);
|
||||||
|
},
|
||||||
|
}, b);
|
||||||
} else {
|
} else {
|
||||||
if (mode == Realise::Nothing)
|
if (mode == Realise::Nothing)
|
||||||
settings.readOnlyMode = true;
|
settings.readOnlyMode = true;
|
||||||
|
|
||||||
for (auto & i : installables)
|
for (auto & i : installables)
|
||||||
for (auto & b : i->toBuildables())
|
for (auto & b : i->toBuildables())
|
||||||
if (b.drvPath)
|
if (auto bfd = std::get_if<BuildableFromDrv>(&b))
|
||||||
outPaths.insert(*b.drvPath);
|
outPaths.insert(bfd->drvPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return outPaths;
|
return outPaths;
|
||||||
|
@ -717,20 +713,21 @@ StorePathSet toDerivations(ref<Store> store,
|
||||||
StorePathSet drvPaths;
|
StorePathSet drvPaths;
|
||||||
|
|
||||||
for (auto & i : installables)
|
for (auto & i : installables)
|
||||||
for (auto & b : i->toBuildables()) {
|
for (auto & b : i->toBuildables())
|
||||||
if (!b.drvPath) {
|
std::visit(overloaded {
|
||||||
|
[&](BuildableOpaque bo) {
|
||||||
if (!useDeriver)
|
if (!useDeriver)
|
||||||
throw Error("argument '%s' did not evaluate to a derivation", i->what());
|
throw Error("argument '%s' did not evaluate to a derivation", i->what());
|
||||||
for (auto & output : b.outputs) {
|
auto derivers = store->queryValidDerivers(bo.path);
|
||||||
auto derivers = store->queryValidDerivers(output.second);
|
|
||||||
if (derivers.empty())
|
if (derivers.empty())
|
||||||
throw Error("'%s' does not have a known deriver", i->what());
|
throw Error("'%s' does not have a known deriver", i->what());
|
||||||
// FIXME: use all derivers?
|
// FIXME: use all derivers?
|
||||||
drvPaths.insert(*derivers.begin());
|
drvPaths.insert(*derivers.begin());
|
||||||
}
|
},
|
||||||
} else
|
[&](BuildableFromDrv bfd) {
|
||||||
drvPaths.insert(*b.drvPath);
|
drvPaths.insert(bfd.drvPath);
|
||||||
}
|
},
|
||||||
|
}, b);
|
||||||
|
|
||||||
return drvPaths;
|
return drvPaths;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,20 @@ struct SourceExprCommand;
|
||||||
|
|
||||||
namespace eval_cache { class EvalCache; class AttrCursor; }
|
namespace eval_cache { class EvalCache; class AttrCursor; }
|
||||||
|
|
||||||
struct Buildable
|
struct BuildableOpaque {
|
||||||
{
|
StorePath path;
|
||||||
std::optional<StorePath> drvPath;
|
};
|
||||||
|
|
||||||
|
struct BuildableFromDrv {
|
||||||
|
StorePath drvPath;
|
||||||
std::map<std::string, StorePath> outputs;
|
std::map<std::string, StorePath> outputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::variant<
|
||||||
|
BuildableOpaque,
|
||||||
|
BuildableFromDrv
|
||||||
|
> Buildable;
|
||||||
|
|
||||||
typedef std::vector<Buildable> Buildables;
|
typedef std::vector<Buildable> Buildables;
|
||||||
|
|
||||||
struct App
|
struct App
|
||||||
|
|
|
@ -45,11 +45,14 @@ struct CmdLog : InstallableCommand
|
||||||
|
|
||||||
RunPager pager;
|
RunPager pager;
|
||||||
for (auto & sub : subs) {
|
for (auto & sub : subs) {
|
||||||
auto log = b.drvPath ? sub->getBuildLog(*b.drvPath) : nullptr;
|
auto log = std::visit(overloaded {
|
||||||
for (auto & output : b.outputs) {
|
[&](BuildableOpaque bo) {
|
||||||
if (log) break;
|
return sub->getBuildLog(bo.path);
|
||||||
log = sub->getBuildLog(output.second);
|
},
|
||||||
}
|
[&](BuildableFromDrv bfd) {
|
||||||
|
return sub->getBuildLog(bfd.drvPath);
|
||||||
|
},
|
||||||
|
}, b);
|
||||||
if (!log) continue;
|
if (!log) continue;
|
||||||
stopProgressBar();
|
stopProgressBar();
|
||||||
printInfo("got build log for '%s' from '%s'", installable->what(), sub->getUri());
|
printInfo("got build log for '%s' from '%s'", installable->what(), sub->getUri());
|
||||||
|
|
|
@ -33,12 +33,17 @@ extern "C" {
|
||||||
#include "command.hh"
|
#include "command.hh"
|
||||||
#include "finally.hh"
|
#include "finally.hh"
|
||||||
|
|
||||||
|
#if HAVE_BOEHMGC
|
||||||
#define GC_INCLUDE_NEW
|
#define GC_INCLUDE_NEW
|
||||||
#include <gc/gc_cpp.h>
|
#include <gc/gc_cpp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
struct NixRepl : gc
|
struct NixRepl
|
||||||
|
#if HAVE_BOEHMGC
|
||||||
|
: gc
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
string curDir;
|
string curDir;
|
||||||
std::unique_ptr<EvalState> state;
|
std::unique_ptr<EvalState> state;
|
||||||
|
|
Loading…
Reference in a new issue