aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/realisation.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-02-05 13:03:50 +0100
committerGitHub <noreply@github.com>2021-02-05 13:03:50 +0100
commitd7c27f21ab1715857e9f275f1a231bbf6ceb96a9 (patch)
tree0a99455cf0280caa0f58544a2aefe322bdcb7e7b /src/libstore/realisation.hh
parent271eedb8373819fbeb92660e081ba5f734b54421 (diff)
parente69cfdebb090b3aabbff69a44504883d5b6fb866 (diff)
Merge pull request #4372 from tweag/ca/drvoutputs-commands
Add a new Cmd type working on RealisedPaths
Diffstat (limited to 'src/libstore/realisation.hh')
-rw-r--r--src/libstore/realisation.hh50
1 files changed, 42 insertions, 8 deletions
diff --git a/src/libstore/realisation.hh b/src/libstore/realisation.hh
index 4b8ead3c5..7c91d802a 100644
--- a/src/libstore/realisation.hh
+++ b/src/libstore/realisation.hh
@@ -2,6 +2,7 @@
#include "path.hh"
#include <nlohmann/json_fwd.hpp>
+#include "comparator.hh"
namespace nix {
@@ -17,13 +18,7 @@ struct DrvOutput {
static DrvOutput parse(const std::string &);
- bool operator<(const DrvOutput& other) const { return to_pair() < other.to_pair(); }
- bool operator==(const DrvOutput& other) const { return to_pair() == other.to_pair(); }
-
-private:
- // Just to make comparison operators easier to write
- std::pair<Hash, std::string> to_pair() const
- { return std::make_pair(drvHash, outputName); }
+ GENERATE_CMP(DrvOutput, me->drvHash, me->outputName);
};
struct Realisation {
@@ -32,8 +27,47 @@ struct Realisation {
nlohmann::json toJSON() const;
static Realisation fromJSON(const nlohmann::json& json, const std::string& whence);
+
+ StorePath getPath() const { return outPath; }
+
+ GENERATE_CMP(Realisation, me->id, me->outPath);
+};
+
+struct OpaquePath {
+ StorePath path;
+
+ StorePath getPath() const { return path; }
+
+ GENERATE_CMP(OpaquePath, me->path);
};
-typedef std::map<DrvOutput, Realisation> DrvOutputs;
+
+/**
+ * A store path with all the history of how it went into the store
+ */
+struct RealisedPath {
+ /*
+ * A path is either the result of the realisation of a derivation or
+ * an opaque blob that has been directly added to the store
+ */
+ using Raw = std::variant<Realisation, OpaquePath>;
+ Raw raw;
+
+ using Set = std::set<RealisedPath>;
+
+ RealisedPath(StorePath path) : raw(OpaquePath{path}) {}
+ RealisedPath(Realisation r) : raw(r) {}
+
+ /**
+ * Get the raw store path associated to this
+ */
+ StorePath path() const;
+
+ void closure(Store& store, Set& ret) const;
+ static void closure(Store& store, const Set& startPaths, Set& ret);
+ Set closure(Store& store) const;
+
+ GENERATE_CMP(RealisedPath, me->raw);
+};
}