1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// FIXME: integrate this with nix path-info?
// FIXME: rename to 'nix store derivation show' or 'nix debug derivation show'?
#include "lix/libcmd/command.hh"
#include "lix/libmain/common-args.hh"
#include "lix/libstore/store-api.hh"
#include "lix/libutil/archive.hh"
#include "lix/libutil/json.hh"
#include "lix/libstore/derivations.hh"
namespace nix {
struct CmdShowDerivation : InstallablesCommand
{
bool recursive = false;
CmdShowDerivation()
{
addFlag({
.longName = "recursive",
.shortName = 'r',
.description = "Include the dependencies of the specified derivations.",
.handler = {&recursive, true}
});
}
std::string description() override
{
return "show the contents of a store derivation";
}
std::string doc() override
{
return
#include "derivation-show.md"
;
}
Category category() override { return catUtility; }
void run(ref<Store> store, Installables && installables) override
{
auto drvPaths =
Installable::toDerivations(*getEvaluator()->begin(aio()), store, installables, true);
if (recursive) {
StorePathSet closure;
aio().blockOn(store->computeFSClosure(drvPaths, closure));
drvPaths = std::move(closure);
}
JSON jsonRoot = JSON::object();
for (auto & drvPath : drvPaths) {
if (!drvPath.isDerivation()) continue;
jsonRoot[store->printStorePath(drvPath)] =
aio().blockOn(store->readDerivation(drvPath)).toJSON(*store);
}
logger->cout(jsonRoot.dump(2));
}
};
void registerNixDerivationShow()
{
registerCommand2<CmdShowDerivation>({"derivation", "show"});
}
}
|