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

#include <variant>

namespace nix {

struct Value;
class EvalState;

struct FlakeRegistry
{
    struct Entry
    {
        FlakeRef ref;
        Entry(const FlakeRef & flakeRef) : ref(flakeRef) {};
        Entry operator=(const Entry & entry) { return Entry(entry.ref); }
    };
    std::map<FlakeId, Entry> entries;
};

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::vector<FlakeRef> requires;
    std::shared_ptr<FlakeRegistry> lockFile;
    Value * vProvides; // FIXME: gc
    // commit hash
    // date
    // content hash
    Flake(FlakeRef & flakeRef) : ref(flakeRef) {};
};

Flake getFlake(EvalState &, const FlakeRef &);

FlakeRegistry updateLockFile(EvalState &, Flake &);

void updateLockFile(EvalState &, std::string);
}