aboutsummaryrefslogtreecommitdiff
path: root/src/nix/dump-path.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-02-25 21:58:41 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-02-25 21:58:41 +0000
commit90d76fa399de4e207ea14ec4c0dd65434f60c152 (patch)
tree3c52e982cba5bcf7b91c99d1b63ba967b4ea8b92 /src/nix/dump-path.cc
parent4636cc9a1f6de70947abbfb17a0ad91981d1cad7 (diff)
parentca0994819d68aee26a2906c37a47ae609ac46c4c (diff)
Merge remote-tracking branch 'obsidian/path-info' into ca-drv-exotic
Diffstat (limited to 'src/nix/dump-path.cc')
-rw-r--r--src/nix/dump-path.cc53
1 files changed, 42 insertions, 11 deletions
diff --git a/src/nix/dump-path.cc b/src/nix/dump-path.cc
index 6fd197531..c4edc894b 100644
--- a/src/nix/dump-path.cc
+++ b/src/nix/dump-path.cc
@@ -1,5 +1,6 @@
#include "command.hh"
#include "store-api.hh"
+#include "archive.hh"
using namespace nix;
@@ -7,21 +8,16 @@ struct CmdDumpPath : StorePathCommand
{
std::string description() override
{
- return "dump a store path to stdout (in NAR format)";
+ return "serialise a store path to stdout in NAR format";
}
- Examples examples() override
+ std::string doc() override
{
- return {
- Example{
- "To get a NAR from the binary cache https://cache.nixos.org/:",
- "nix dump-path --store https://cache.nixos.org/ /nix/store/7crrmih8c52r8fbnqb933dxrsp44md93-glibc-2.25"
- },
- };
+ return
+ #include "store-dump-path.md"
+ ;
}
- Category category() override { return catUtility; }
-
void run(ref<Store> store, const StorePath & storePath) override
{
FdSink sink(STDOUT_FILENO);
@@ -30,4 +26,39 @@ struct CmdDumpPath : StorePathCommand
}
};
-static auto rDumpPath = registerCommand<CmdDumpPath>("dump-path");
+static auto rDumpPath = registerCommand2<CmdDumpPath>({"store", "dump-path"});
+
+struct CmdDumpPath2 : Command
+{
+ Path path;
+
+ CmdDumpPath2()
+ {
+ expectArgs({
+ .label = "path",
+ .handler = {&path},
+ .completer = completePath
+ });
+ }
+
+ std::string description() override
+ {
+ return "serialise a path to stdout in NAR format";
+ }
+
+ std::string doc() override
+ {
+ return
+ #include "nar-dump-path.md"
+ ;
+ }
+
+ void run() override
+ {
+ FdSink sink(STDOUT_FILENO);
+ dumpPath(path, sink);
+ sink.flush();
+ }
+};
+
+static auto rDumpPath2 = registerCommand2<CmdDumpPath2>({"nar", "dump-path"});