aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorNick Van den Broeck <nick.van.den.broeck666@gmail.com>2019-02-21 06:53:01 +0100
committerNick Van den Broeck <nick.van.den.broeck666@gmail.com>2019-02-26 13:12:51 +0100
commitcfb6ab80cea7f0ed3f525e8120f2e569f963fa0e (patch)
treeb4b170bd2cd073c2aae648bb72a78a51feb2b6a1 /src/nix
parentd342de02b9f7ee07f22e1986af8d5c8eb325d8ba (diff)
Implemented "nix flake info"
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/command.hh11
-rw-r--r--src/nix/flake.cc23
2 files changed, 33 insertions, 1 deletions
diff --git a/src/nix/command.hh b/src/nix/command.hh
index a08347945..b3248222e 100644
--- a/src/nix/command.hh
+++ b/src/nix/command.hh
@@ -34,6 +34,17 @@ struct Buildable
typedef std::vector<Buildable> Buildables;
+struct FlakeCommand : virtual Args, StoreCommand, MixEvalArgs
+{
+ std::string flakeUri;
+
+public:
+ FlakeCommand()
+ {
+ expectArg("flake-uri", &flakeUri);
+ }
+};
+
struct Installable
{
virtual std::string what() = 0;
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 9b36c3cbd..099425688 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -33,10 +33,31 @@ struct CmdFlakeList : StoreCommand, MixEvalArgs
}
};
+struct CmdFlakeInfo : FlakeCommand
+{
+ std::string name() override
+ {
+ return "info";
+ }
+
+ std::string description() override
+ {
+ return "list info about a given flake";
+ }
+
+ void run(nix::ref<nix::Store> store) override
+ {
+ auto evalState = std::make_shared<EvalState>(searchPath, store);
+ nix::Flake flake = nix::getFlake(*evalState, FlakeRef(flakeUri));
+ std::cout << "Location: " << flake.path << "\n";
+ std::cout << "Description: " << flake.description << "\n";
+ }
+};
+
struct CmdFlake : virtual MultiCommand, virtual Command
{
CmdFlake()
- : MultiCommand({make_ref<CmdFlakeList>()})
+ : MultiCommand({make_ref<CmdFlakeList>(), make_ref<CmdFlakeInfo>()})
{
}