aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops/flake.hh
blob: 9da0652346d5b652198f626b31a78e10ab9668af (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
#include "types.hh"
#include "flakeref.hh"

#include <variant>

namespace nix {

struct Value;
class EvalState;

struct FlakeRegistry
{
    std::map<FlakeRef, FlakeRef> entries;
};

struct LockFile
{
    struct FlakeEntry
    {
        FlakeRef ref;
        std::map<FlakeId, FlakeEntry> flakeEntries;
        std::map<FlakeId, FlakeRef> nonFlakeEntries;
        FlakeEntry(const FlakeRef & flakeRef) : ref(flakeRef) {};
    };

    std::map<FlakeId, FlakeEntry> flakeEntries;
    std::map<FlakeId, FlakeRef> nonFlakeEntries;
};

Path getUserRegistryPath();

Value * makeFlakeRegistryValue(EvalState & state);

Value * makeFlakeValue(EvalState & state, const FlakeRef & flakeRef, bool impureTopRef, Value & v);

std::shared_ptr<FlakeRegistry> readRegistry(const Path &);

void writeRegistry(FlakeRegistry, Path);

struct Flake
{
    FlakeId id;
    FlakeRef ref;
    std::string description;
    Path path;
    std::optional<uint64_t> revCount;
    std::vector<FlakeRef> requires;
    LockFile lockFile;
    std::map<FlakeAlias, FlakeRef> nonFlakeRequires;
    Value * vProvides; // FIXME: gc
    // date
    // content hash
    Flake(const FlakeRef flakeRef) : ref(flakeRef) {};
};

struct NonFlake
{
    FlakeAlias alias;
    FlakeRef ref;
    Path path;
    // date
    // content hash
    NonFlake(const FlakeRef flakeRef) : ref(flakeRef) {};
};

Flake getFlake(EvalState &, const FlakeRef &, bool impureIsAllowed);

struct Dependencies
{
    Flake flake;
    std::vector<Dependencies> flakeDeps; // The flake dependencies
    std::vector<NonFlake> nonFlakeDeps;
    Dependencies(const Flake & flake) : flake(flake) {}
};

Dependencies resolveFlake(EvalState &, const FlakeRef &, bool impureTopRef, bool isTopFlake = true);

FlakeRegistry updateLockFile(EvalState &, Flake &);

void updateLockFile(EvalState &, Path path);
}