aboutsummaryrefslogtreecommitdiff
path: root/src/nix/command.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/command.hh')
-rw-r--r--src/nix/command.hh51
1 files changed, 32 insertions, 19 deletions
diff --git a/src/nix/command.hh b/src/nix/command.hh
index 23f5c9898..8b910ba78 100644
--- a/src/nix/command.hh
+++ b/src/nix/command.hh
@@ -4,12 +4,18 @@
#include "args.hh"
#include "common-eval-args.hh"
#include "path.hh"
-#include "eval.hh"
+#include "flake/lockfile.hh"
+
+#include <optional>
namespace nix {
extern std::string programPath;
+class EvalState;
+struct Pos;
+class Store;
+
/* A command that requires a Nix store. */
struct StoreCommand : virtual Command
{
@@ -23,25 +29,36 @@ private:
std::shared_ptr<Store> _store;
};
-struct SourceExprCommand : virtual StoreCommand, MixEvalArgs
+struct EvalCommand : virtual StoreCommand, MixEvalArgs
{
- Path file;
+ ref<EvalState> getEvalState();
- SourceExprCommand();
+ std::shared_ptr<EvalState> evalState;
+};
- /* Return a value representing the Nix expression from which we
- are installing. This is either the file specified by ‘--file’,
- or an attribute set constructed from $NIX_PATH, e.g. ‘{ nixpkgs
- = import ...; bla = import ...; }’. */
- Value * getSourceExpr(EvalState & state);
+struct MixFlakeOptions : virtual Args
+{
+ flake::LockFlags lockFlags;
- ref<EvalState> getEvalState();
+ MixFlakeOptions();
+};
-private:
+struct SourceExprCommand : virtual Args, EvalCommand, MixFlakeOptions
+{
+ std::optional<Path> file;
+ std::optional<std::string> expr;
- std::shared_ptr<EvalState> evalState;
+ SourceExprCommand();
- Value * vSourceExpr = 0;
+ std::vector<std::shared_ptr<Installable>> parseInstallables(
+ ref<Store> store, std::vector<std::string> ss);
+
+ std::shared_ptr<Installable> parseInstallable(
+ ref<Store> store, const std::string & installable);
+
+ virtual Strings getDefaultFlakeAttrPaths();
+
+ virtual Strings getDefaultFlakeAttrPathPrefixes();
};
enum RealiseMode { Build, NoBuild, DryRun };
@@ -73,14 +90,14 @@ struct InstallableCommand : virtual Args, SourceExprCommand
InstallableCommand()
{
- expectArg("installable", &_installable);
+ expectArg("installable", &_installable, true);
}
void prepare() override;
private:
- std::string _installable;
+ std::string _installable{"."};
};
/* A command that operates on zero or more store paths. */
@@ -137,10 +154,6 @@ static RegisterCommand registerCommand(const std::string & name)
return RegisterCommand(name, [](){ return make_ref<T>(); });
}
-std::shared_ptr<Installable> parseInstallable(
- SourceExprCommand & cmd, ref<Store> store, const std::string & installable,
- bool useDefaultInstallables);
-
Buildables build(ref<Store> store, RealiseMode mode,
std::vector<std::shared_ptr<Installable>> installables);