diff options
Diffstat (limited to 'src/nix/installables.hh')
-rw-r--r-- | src/nix/installables.hh | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/src/nix/installables.hh b/src/nix/installables.hh index a58f7dc59bb4..5f0b0a292242 100644 --- a/src/nix/installables.hh +++ b/src/nix/installables.hh @@ -1,48 +1,61 @@ #pragma once #include "args.hh" +#include "command.hh" namespace nix { -struct UserEnvElem -{ - Strings attrPath; +struct Value; +class EvalState; +class Expr; - // FIXME: should use boost::variant or so. - bool isDrv; +struct Installable +{ + virtual std::string what() = 0; - // Derivation case: - Path drvPath; - StringSet outputNames; + virtual PathSet toBuildable() + { + throw Error("argument ‘%s’ cannot be built", what()); + } - // Non-derivation case: - PathSet outPaths; + virtual Value * toValue(EvalState & state) + { + throw Error("argument ‘%s’ cannot be evaluated", what()); + } }; -typedef std::vector<UserEnvElem> UserEnvElems; - -struct Value; -class EvalState; - -struct MixInstallables : virtual Args +struct MixInstallables : virtual Args, StoreCommand { - Strings installables; + std::vector<std::shared_ptr<Installable>> installables; Path file; MixInstallables() { mkFlag('f', "file", "file", "evaluate FILE rather than the default", &file); - expectArgs("installables", &installables); + expectArgs("installables", &_installables); } - UserEnvElems evalInstallables(ref<Store> store); - /* 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 * buildSourceExpr(EvalState & state); + Value * getSourceExpr(EvalState & state); + + std::vector<std::shared_ptr<Installable>> parseInstallables(ref<Store> store, Strings installables); + + PathSet buildInstallables(ref<Store> store, bool dryRun); + + ref<EvalState> getEvalState(); + + void prepare() override; + +private: + + Strings _installables; + + std::shared_ptr<EvalState> evalState; + Value * vSourceExpr = 0; }; } |