blob: a9710524bd2951541a208557b6de5d2621990e2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#pragma once
#include "flakeref.hh"
#include <nlohmann/json_fwd.hpp>
namespace nix {
class Store;
struct StorePath;
}
namespace nix::flake {
typedef std::vector<FlakeId> InputPath;
struct LockedInput;
/* Lock file information about the dependencies of a flake. */
struct LockedInputs
{
std::map<FlakeId, LockedInput> inputs;
LockedInputs() {};
LockedInputs(const nlohmann::json & json);
nlohmann::json toJson() const;
bool isImmutable() const;
std::optional<LockedInput *> findInput(const InputPath & path);
void removeInput(const InputPath & path);
};
/* Lock file information about a flake input. */
struct LockedInput : LockedInputs
{
FlakeRef ref, originalRef;
Hash narHash;
LockedInput(const FlakeRef & ref, const FlakeRef & originalRef, const Hash & narHash)
: ref(ref), originalRef(originalRef), narHash(narHash)
{ }
LockedInput(const nlohmann::json & json);
bool operator ==(const LockedInput & other) const
{
return
ref == other.ref
&& narHash == other.narHash
&& inputs == other.inputs;
}
nlohmann::json toJson() const;
StorePath computeStorePath(Store & store) const;
};
/* An entire lock file. Note that this cannot be a FlakeInput for the
top-level flake, because then the lock file would need to contain
the hash of the top-level flake, but committing the lock file
would invalidate that hash. */
struct LockFile : LockedInputs
{
bool operator ==(const LockFile & other) const
{
return inputs == other.inputs;
}
LockFile() {}
LockFile(const nlohmann::json & json) : LockedInputs(json) {}
LockFile(LockedInput && dep)
{
inputs = std::move(dep.inputs);
}
nlohmann::json toJson() const;
static LockFile read(const Path & path);
void write(const Path & path) const;
};
std::ostream & operator <<(std::ostream & stream, const LockFile & lockFile);
InputPath parseInputPath(std::string_view s);
}
|