diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-03-02 13:54:08 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-03-02 19:19:51 +0100 |
commit | 54888b92ded6c242ce4914628553d8b2c9c55d10 (patch) | |
tree | 17d530a11628a99bb61434e62a7547c284b23f1e /src/libcmd/installables.hh | |
parent | b2da2a22c64a040f3cc83180f636b5fe972c16b1 (diff) |
Move installables-related operations
Diffstat (limited to 'src/libcmd/installables.hh')
-rw-r--r-- | src/libcmd/installables.hh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/libcmd/installables.hh b/src/libcmd/installables.hh index 3d2563e4b..f296434c5 100644 --- a/src/libcmd/installables.hh +++ b/src/libcmd/installables.hh @@ -5,6 +5,7 @@ #include "path-with-outputs.hh" #include "derived-path.hh" #include "eval.hh" +#include "store-api.hh" #include "flake/flake.hh" #include <optional> @@ -29,6 +30,27 @@ struct UnresolvedApp App resolve(ref<Store> evalStore, ref<Store> store); }; +enum class Realise { + /* Build the derivation. Postcondition: the + derivation outputs exist. */ + Outputs, + /* Don't build the derivation. Postcondition: the store derivation + exists. */ + Derivation, + /* Evaluate in dry-run mode. Postcondition: nothing. */ + // FIXME: currently unused, but could be revived if we can + // evaluate derivations in-memory. + Nothing +}; + +/* How to handle derivations in commands that operate on store paths. */ +enum class OperateOn { + /* Operate on the output path. */ + Output, + /* Operate on the .drv path. */ + Derivation +}; + struct Installable { virtual ~Installable() { } @@ -68,6 +90,39 @@ struct Installable { return FlakeRef::fromAttrs({{"type","indirect"}, {"id", "nixpkgs"}}); } + + static BuiltPaths build( + ref<Store> evalStore, + ref<Store> store, + Realise mode, + const std::vector<std::shared_ptr<Installable>> & installables, + BuildMode bMode = bmNormal); + + static std::set<StorePath> toStorePaths( + ref<Store> evalStore, + ref<Store> store, + Realise mode, + OperateOn operateOn, + const std::vector<std::shared_ptr<Installable>> & installables); + + static StorePath toStorePath( + ref<Store> evalStore, + ref<Store> store, + Realise mode, + OperateOn operateOn, + std::shared_ptr<Installable> installable); + + static std::set<StorePath> toDerivations( + ref<Store> store, + const std::vector<std::shared_ptr<Installable>> & installables, + bool useDeriver = false); + + static BuiltPaths toBuiltPaths( + ref<Store> evalStore, + ref<Store> store, + Realise mode, + OperateOn operateOn, + const std::vector<std::shared_ptr<Installable>> & installables); }; struct InstallableValue : Installable @@ -131,4 +186,9 @@ ref<eval_cache::EvalCache> openEvalCache( EvalState & state, std::shared_ptr<flake::LockedFlake> lockedFlake); +BuiltPaths getBuiltPaths( + ref<Store> evalStore, + ref<Store> store, + const DerivedPaths & hopefullyBuiltPaths); + } |