aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/primops/flake.cc13
-rw-r--r--src/libexpr/primops/flake.hh14
-rw-r--r--src/nix/command.hh11
-rw-r--r--src/nix/flake.cc23
4 files changed, 47 insertions, 14 deletions
diff --git a/src/libexpr/primops/flake.cc b/src/libexpr/primops/flake.cc
index 3998f9ef9..9f137a0b9 100644
--- a/src/libexpr/primops/flake.cc
+++ b/src/libexpr/primops/flake.cc
@@ -141,19 +141,6 @@ static FlakeSourceInfo fetchFlake(EvalState & state, const FlakeRef & flakeRef)
else abort();
}
-struct Flake
-{
- FlakeId id;
- std::string description;
- Path path;
- std::vector<FlakeRef> requires;
- std::unique_ptr<FlakeRegistry> lockFile;
- Value * vProvides; // FIXME: gc
- // commit hash
- // date
- // content hash
-};
-
static Flake getFlake(EvalState & state, const FlakeRef & flakeRef)
{
auto sourceInfo = fetchFlake(state, flakeRef);
diff --git a/src/libexpr/primops/flake.hh b/src/libexpr/primops/flake.hh
index e504dc196..af28bc5b0 100644
--- a/src/libexpr/primops/flake.hh
+++ b/src/libexpr/primops/flake.hh
@@ -21,4 +21,18 @@ Value * makeFlakeRegistryValue(EvalState & state);
Value * makeFlakeValue(EvalState & state, std::string flakeUri, Value & v);
+struct Flake
+{
+ FlakeId id;
+ std::string description;
+ Path path;
+ std::vector<FlakeRef> requires;
+ std::unique_ptr<FlakeRegistry> lockFile;
+ Value * vProvides; // FIXME: gc
+ // commit hash
+ // date
+ // content hash
+};
+
+static Flake getFlake(EvalState & state, const FlakeRef & flakeRef);
}
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>()})
{
}