about summary refs log tree commit diff
path: root/src/nix/command.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-07-17T17·02+0200
committerEelco Dolstra <edolstra@gmail.com>2017-07-20T11·33+0200
commit90825dea518ea078f0783a72cc471a5b3716d198 (patch)
treeb6f6fed6e8c7a96a6769344060409f19a56290b9 /src/nix/command.hh
parent3162ad5ff497b92fc25cd3f397eaff01d67340cc (diff)
Add "nix search" command
Diffstat (limited to 'src/nix/command.hh')
-rw-r--r--src/nix/command.hh34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/nix/command.hh b/src/nix/command.hh
index ae7709b5dc83..536802653819 100644
--- a/src/nix/command.hh
+++ b/src/nix/command.hh
@@ -62,17 +62,13 @@ struct Installable
     }
 };
 
-/* A command that operates on a list of "installables", which can be
-   store paths, attribute paths, Nix expressions, etc. */
-struct InstallablesCommand : virtual Args, StoreCommand
+struct SourceExprCommand : virtual Args, StoreCommand
 {
-    std::vector<std::shared_ptr<Installable>> installables;
     Path file;
 
-    InstallablesCommand()
+    SourceExprCommand()
     {
         mkFlag('f', "file", "file", "evaluate FILE rather than the default", &file);
-        expectArgs("installables", &_installables);
     }
 
     /* Return a value representing the Nix expression from which we
@@ -81,14 +77,32 @@ struct InstallablesCommand : virtual Args, StoreCommand
        = import ...; bla = import ...; }’. */
     Value * getSourceExpr(EvalState & state);
 
+    ref<EvalState> getEvalState();
+
+private:
+
+    std::shared_ptr<EvalState> evalState;
+
+    Value * vSourceExpr = 0;
+};
+
+/* A command that operates on a list of "installables", which can be
+   store paths, attribute paths, Nix expressions, etc. */
+struct InstallablesCommand : virtual Args, SourceExprCommand
+{
+    std::vector<std::shared_ptr<Installable>> installables;
+
+    InstallablesCommand()
+    {
+        expectArgs("installables", &_installables);
+    }
+
     std::vector<std::shared_ptr<Installable>> parseInstallables(ref<Store> store, Strings ss);
 
     enum ToStorePathsMode { Build, NoBuild, DryRun };
 
     PathSet toStorePaths(ref<Store> store, ToStorePathsMode mode);
 
-    ref<EvalState> getEvalState();
-
     void prepare() override;
 
     virtual bool useDefaultInstallables() { return true; }
@@ -96,10 +110,6 @@ struct InstallablesCommand : virtual Args, StoreCommand
 private:
 
     Strings _installables;
-
-    std::shared_ptr<EvalState> evalState;
-
-    Value * vSourceExpr = 0;
 };
 
 /* A command that operates on zero or more store paths. */