diff options
author | regnat <rg@regnat.ovh> | 2020-12-14 17:24:30 +0100 |
---|---|---|
committer | regnat <rg@regnat.ovh> | 2021-01-28 09:38:44 +0100 |
commit | 9355ecd54301372b6a919a2205340f904c7a51c6 (patch) | |
tree | 94f055cc7c91e90dba6ca4f8dc325c95ca34a8f1 /src/libcmd/command.hh | |
parent | b8f345b29a65669f4d6966ba3837fda2341c5ec2 (diff) |
Add a new Cmd type working on RealisedPaths
Where a `RealisedPath` is a store path with its history, meaning either
an opaque path for stuff that has been directly added to the store, or a
`Realisation` for stuff that has been built by a derivation
This is a low-level refactoring that doesn't bring anything by itself
(except a few dozen extra lines of code :/ ), but raising the
abstraction level a bit is important on a number of levels:
- Commands like `nix build` have to query for the realisations after the
build is finished which is fragile (see
27905f12e4a7207450abe37c9ed78e31603b67e1 for example). Having them
oprate directly at the realisation level would avoid that
- Others like `nix copy` currently operate directly on (built) store
paths, but need a bit more information as they will need to register
the realisations on the remote side
Diffstat (limited to 'src/libcmd/command.hh')
-rw-r--r-- | src/libcmd/command.hh | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/libcmd/command.hh b/src/libcmd/command.hh index ed6980075..8c0b3a94a 100644 --- a/src/libcmd/command.hh +++ b/src/libcmd/command.hh @@ -141,7 +141,7 @@ private: }; /* A command that operates on zero or more store paths. */ -struct StorePathsCommand : public InstallablesCommand +struct RealisedPathsCommand : public InstallablesCommand { private: @@ -154,17 +154,28 @@ protected: public: - StorePathsCommand(bool recursive = false); + RealisedPathsCommand(bool recursive = false); using StoreCommand::run; - virtual void run(ref<Store> store, std::vector<StorePath> storePaths) = 0; + virtual void run(ref<Store> store, std::vector<RealisedPath> paths) = 0; void run(ref<Store> store) override; bool useDefaultInstallables() override { return !all; } }; +struct StorePathsCommand : public RealisedPathsCommand +{ + StorePathsCommand(bool recursive = false); + + using RealisedPathsCommand::run; + + virtual void run(ref<Store> store, std::vector<StorePath> storePaths) = 0; + + void run(ref<Store> store, std::vector<RealisedPath> paths) override; +}; + /* A command that operates on exactly one store path. */ struct StorePathCommand : public InstallablesCommand { @@ -218,6 +229,12 @@ std::set<StorePath> toDerivations(ref<Store> store, std::vector<std::shared_ptr<Installable>> installables, bool useDeriver = false); +std::set<RealisedPath> toRealisedPaths( + ref<Store> store, + Realise mode, + OperateOn operateOn, + std::vector<std::shared_ptr<Installable>> installables); + /* Helper function to generate args that invoke $EDITOR on filename:lineno. */ Strings editorFor(const Pos & pos); |