Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
realisation.hh
Go to the documentation of this file.
1#pragma once
3
4#include <variant>
5
6#include "lix/libutil/hash.hh"
7#include "lix/libutil/json-fwd.hh"
12
13namespace nix {
14
15class Store;
16struct OutputsSpec;
17
24struct DrvOutput {
33
38
39 std::string to_string() const;
40
41 std::string strHash() const
42 { return drvHash.to_string(Base::Base16, true); }
43
44 static DrvOutput parse(const std::string &);
45
46 GENERATE_CMP(DrvOutput, me->drvHash, me->outputName);
47};
48
50 DrvOutput id;
51 StorePath outPath;
52
53 StringSet signatures = {};
54
61 std::map<DrvOutput, StorePath> dependentRealisations = {};
62
63 JSON toJSON() const;
64 static Realisation fromJSON(const JSON& json, const std::string& whence);
65
66 std::string fingerprint() const;
67 void sign(const SecretKey &);
68 bool checkSignature(const PublicKeys & publicKeys, const std::string & sig) const;
69 size_t checkSignatures(const PublicKeys & publicKeys) const;
70
71 static kj::Promise<Result<std::set<Realisation>>>
72 closure(Store &, const std::set<Realisation> &);
73 static kj::Promise<Result<void>>
74 closure(Store &, const std::set<Realisation> &, std::set<Realisation> & res);
75
76 bool isCompatibleWith(const Realisation & other) const;
77
78 StorePath getPath() const { return outPath; }
79
80 GENERATE_CMP(Realisation, me->id, me->outPath);
81};
82
89typedef std::map<OutputName, Realisation> SingleDrvOutputs;
90
98typedef std::map<DrvOutput, Realisation> DrvOutputs;
99
105SingleDrvOutputs filterDrvOutputs(const OutputsSpec&, SingleDrvOutputs&&);
106
107
109 StorePath path;
110
111 StorePath getPath() const { return path; }
112
113 GENERATE_CMP(OpaquePath, me->path);
114};
115
116
120struct RealisedPath {
121 /*
122 * A path is either the result of the realisation of a derivation or
123 * an opaque blob that has been directly added to the store
124 */
125 using Raw = std::variant<Realisation, OpaquePath>;
126 Raw raw;
127
128 using Set = std::set<RealisedPath>;
129
130 RealisedPath(StorePath path) : raw(OpaquePath{path}) {}
131 RealisedPath(Realisation r) : raw(r) {}
132
136 StorePath path() const;
137
138 kj::Promise<Result<void>> closure(Store & store, Set & ret) const;
139 static kj::Promise<Result<void>> closure(Store & store, const Set & startPaths, Set & ret);
140 kj::Promise<Result<Set>> closure(Store & store) const;
141
142 GENERATE_CMP(RealisedPath, me->raw);
143};
144
145class MissingRealisation : public Error
146{
147public:
148 MissingRealisation(DrvOutput & outputId)
149 : MissingRealisation(outputId.outputName, outputId.strHash())
150 {}
151 MissingRealisation(std::string_view drv, OutputName outputName)
152 : Error( "cannot operate on output '%s' of the "
153 "unbuilt derivation '%s'",
154 outputName,
155 drv)
156 {}
157};
158
159}
Definition path.hh:21
Definition store-api.hh:195
#define GENERATE_CMP(args...)
Definition comparator.hh:65
std::map< DrvOutput, Realisation > DrvOutputs
Definition realisation.hh:98
std::map< OutputName, Realisation > SingleDrvOutputs
Definition realisation.hh:89
std::string OutputName
Definition outputs-spec.hh:20
Definition realisation.hh:24
OutputName outputName
Definition realisation.hh:37
Hash drvHash
Definition realisation.hh:32
Definition hash.hh:41
Definition realisation.hh:108
Definition outputs-spec.hh:28
Definition realisation.hh:49
std::map< DrvOutput, StorePath > dependentRealisations
Definition realisation.hh:61
StorePath path() const
Definition realisation.cc:154
Definition crypto.hh:31