diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-04-25T09·20+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-04-25T09·20+0200 |
commit | bcecc990071fd36bb88c8fd29cb009ed4c04d6a2 (patch) | |
tree | c3f2fa86b2d751418efe7727bc345d0557c3786c /src/nix/installables.hh | |
parent | 1bb87c0487ba2a10f20c07dfd828b5d043249e31 (diff) |
Restructure installables handling in the "nix" command
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; }; } |