mirror of
https://github.com/NixOS/nix
synced 2025-06-29 19:03:16 +02:00
Merge remote-tracking branch 'upstream/master' into path-info
Also improve content-address.hh API docs.
This commit is contained in:
commit
aa99005004
315 changed files with 6195 additions and 3610 deletions
|
@ -57,7 +57,7 @@ void printGraphML(ref<Store> store, StorePathSet && roots)
|
|||
<< "<graphml xmlns='http://graphml.graphdrawing.org/xmlns'\n"
|
||||
<< " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"
|
||||
<< " xsi:schemaLocation='http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd'>\n"
|
||||
<< "<key id='narSize' for='node' attr.name='narSize' attr.type='int'/>"
|
||||
<< "<key id='narSize' for='node' attr.name='narSize' attr.type='long'/>"
|
||||
<< "<key id='name' for='node' attr.name='name' attr.type='string'/>"
|
||||
<< "<key id='type' for='node' attr.name='type' attr.type='string'/>"
|
||||
<< "<graph id='G' edgedefault='directed'>\n";
|
||||
|
|
|
@ -72,11 +72,13 @@ static PathSet realisePath(StorePathWithOutputs path, bool build = true)
|
|||
Derivation drv = store->derivationFromPath(path.path);
|
||||
rootNr++;
|
||||
|
||||
/* FIXME: Encode this empty special case explicitly in the type. */
|
||||
if (path.outputs.empty())
|
||||
for (auto & i : drv.outputs) path.outputs.insert(i.first);
|
||||
|
||||
PathSet outputs;
|
||||
for (auto & j : path.outputs) {
|
||||
/* Match outputs of a store path with outputs of the derivation that produces it. */
|
||||
DerivationOutputs::iterator i = drv.outputs.find(j);
|
||||
if (i == drv.outputs.end())
|
||||
throw Error("derivation '%s' does not have an output named '%s'",
|
||||
|
@ -141,6 +143,7 @@ static void opRealise(Strings opFlags, Strings opArgs)
|
|||
toDerivedPaths(paths),
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
|
||||
/* Filter out unknown paths from `paths`. */
|
||||
if (ignoreUnknown) {
|
||||
std::vector<StorePathWithOutputs> paths2;
|
||||
for (auto & i : paths)
|
||||
|
@ -463,7 +466,7 @@ static void opPrintEnv(Strings opFlags, Strings opArgs)
|
|||
/* Print each environment variable in the derivation in a format
|
||||
* that can be sourced by the shell. */
|
||||
for (auto & i : drv.env)
|
||||
cout << format("export %1%; %1%=%2%\n") % i.first % shellEscape(i.second);
|
||||
logger->cout("export %1%; %1%=%2%\n", i.first, shellEscape(i.second));
|
||||
|
||||
/* Also output the arguments. This doesn't preserve whitespace in
|
||||
arguments. */
|
||||
|
@ -1026,64 +1029,109 @@ static int main_nix_store(int argc, char * * argv)
|
|||
{
|
||||
Strings opFlags, opArgs;
|
||||
Operation op = 0;
|
||||
bool readFromStdIn = false;
|
||||
std::string opName;
|
||||
bool showHelp = false;
|
||||
|
||||
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
Operation oldOp = op;
|
||||
|
||||
if (*arg == "--help")
|
||||
showManPage("nix-store");
|
||||
showHelp = true;
|
||||
else if (*arg == "--version")
|
||||
op = opVersion;
|
||||
else if (*arg == "--realise" || *arg == "--realize" || *arg == "-r")
|
||||
else if (*arg == "--realise" || *arg == "--realize" || *arg == "-r") {
|
||||
op = opRealise;
|
||||
else if (*arg == "--add" || *arg == "-A")
|
||||
opName = "-realise";
|
||||
}
|
||||
else if (*arg == "--add" || *arg == "-A"){
|
||||
op = opAdd;
|
||||
else if (*arg == "--add-fixed")
|
||||
opName = "-add";
|
||||
}
|
||||
else if (*arg == "--add-fixed") {
|
||||
op = opAddFixed;
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--print-fixed-path")
|
||||
op = opPrintFixedPath;
|
||||
else if (*arg == "--delete")
|
||||
else if (*arg == "--delete") {
|
||||
op = opDelete;
|
||||
else if (*arg == "--query" || *arg == "-q")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--query" || *arg == "-q") {
|
||||
op = opQuery;
|
||||
else if (*arg == "--print-env")
|
||||
opName = "-query";
|
||||
}
|
||||
else if (*arg == "--print-env") {
|
||||
op = opPrintEnv;
|
||||
else if (*arg == "--read-log" || *arg == "-l")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--read-log" || *arg == "-l") {
|
||||
op = opReadLog;
|
||||
else if (*arg == "--dump-db")
|
||||
opName = "-read-log";
|
||||
}
|
||||
else if (*arg == "--dump-db") {
|
||||
op = opDumpDB;
|
||||
else if (*arg == "--load-db")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--load-db") {
|
||||
op = opLoadDB;
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--register-validity")
|
||||
op = opRegisterValidity;
|
||||
else if (*arg == "--check-validity")
|
||||
op = opCheckValidity;
|
||||
else if (*arg == "--gc")
|
||||
else if (*arg == "--gc") {
|
||||
op = opGC;
|
||||
else if (*arg == "--dump")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--dump") {
|
||||
op = opDump;
|
||||
else if (*arg == "--restore")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--restore") {
|
||||
op = opRestore;
|
||||
else if (*arg == "--export")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--export") {
|
||||
op = opExport;
|
||||
else if (*arg == "--import")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--import") {
|
||||
op = opImport;
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--init")
|
||||
op = opInit;
|
||||
else if (*arg == "--verify")
|
||||
else if (*arg == "--verify") {
|
||||
op = opVerify;
|
||||
else if (*arg == "--verify-path")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--verify-path") {
|
||||
op = opVerifyPath;
|
||||
else if (*arg == "--repair-path")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--repair-path") {
|
||||
op = opRepairPath;
|
||||
else if (*arg == "--optimise" || *arg == "--optimize")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--optimise" || *arg == "--optimize") {
|
||||
op = opOptimise;
|
||||
else if (*arg == "--serve")
|
||||
opName = "-optimise";
|
||||
}
|
||||
else if (*arg == "--serve") {
|
||||
op = opServe;
|
||||
else if (*arg == "--generate-binary-cache-key")
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--generate-binary-cache-key") {
|
||||
op = opGenerateBinaryCacheKey;
|
||||
opName = arg->substr(1);
|
||||
}
|
||||
else if (*arg == "--add-root")
|
||||
gcRoot = absPath(getArg(*arg, arg, end));
|
||||
else if (*arg == "--stdin" && !isatty(STDIN_FILENO))
|
||||
readFromStdIn = true;
|
||||
else if (*arg == "--indirect")
|
||||
;
|
||||
else if (*arg == "--no-output")
|
||||
|
@ -1096,12 +1144,20 @@ static int main_nix_store(int argc, char * * argv)
|
|||
else
|
||||
opArgs.push_back(*arg);
|
||||
|
||||
if (readFromStdIn && op != opImport && op != opRestore && op != opServe) {
|
||||
std::string word;
|
||||
while (std::cin >> word) {
|
||||
opArgs.emplace_back(std::move(word));
|
||||
};
|
||||
}
|
||||
|
||||
if (oldOp && oldOp != op)
|
||||
throw UsageError("only one operation may be specified");
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if (showHelp) showManPage("nix-store" + opName);
|
||||
if (!op) throw UsageError("no operation specified");
|
||||
|
||||
if (op != opDump && op != opRestore) /* !!! hack */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue