Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
lockfile.hh
Go to the documentation of this file.
1#pragma once
3
5#include "lix/libutil/json-fwd.hh"
6
7namespace nix {
8class Store;
9class StorePath;
10}
11
12namespace nix::flake {
13
14typedef std::vector<FlakeId> InputPath;
15
16struct LockedNode;
17
23struct Node : std::enable_shared_from_this<Node>
24{
25 typedef std::variant<ref<LockedNode>, InputPath> Edge;
26
27 std::map<FlakeId, Edge> inputs;
28
29 virtual ~Node() { }
30};
31
35struct LockedNode : Node
36{
37 FlakeRef lockedRef, originalRef;
38 bool isFlake = true;
39
40 LockedNode(
41 const FlakeRef & lockedRef,
42 const FlakeRef & originalRef,
43 bool isFlake = true)
44 : lockedRef(lockedRef), originalRef(originalRef), isFlake(isFlake)
45 { }
46
47 LockedNode(const JSON & json);
48
49 StorePath computeStorePath(Store & store) const;
50};
51
52struct LockFile
53{
54 ref<Node> root = make_ref<Node>();
55
56 LockFile() {};
57 LockFile(const JSON & json, const Path & path);
58
59 typedef std::map<ref<const Node>, std::string> KeyMap;
60
61 JSON toJSON() const;
62
63 std::string to_string() const;
64
65 static LockFile read(const Path & path);
66
67 void write(const Path & path) const;
68
72 std::optional<FlakeRef> isUnlocked() const;
73
74 bool operator ==(const LockFile & other) const;
75 // Needed for old gcc versions that don't synthesize it (like gcc 8.2.2
76 // that is still the default on aarch64-linux)
77 bool operator !=(const LockFile & other) const;
78
79 std::shared_ptr<Node> findInput(const InputPath & path);
80
81 std::map<InputPath, Node::Edge> getAllInputs() const;
82
83 static std::string diff(const LockFile & oldLocks, const LockFile & newLocks);
84
88 void check();
89};
90
91std::ostream & operator <<(std::ostream & stream, const LockFile & lockFile);
92
93InputPath parseInputPath(std::string_view s);
94
95std::string printInputPath(const InputPath & path);
96
97}
Definition path.hh:21
Definition store-api.hh:195
Definition ref.hh:19
Definition flakeref.hh:35
Definition lockfile.hh:53
std::optional< FlakeRef > isUnlocked() const
Definition lockfile.cc:212
void check()
Definition lockfile.cc:349
Definition lockfile.hh:36
Definition lockfile.hh:24
std::string Path
Definition types.hh:28