aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/fetchers/registry.hh
blob: 1757ce3236cdf9de90d00d61d581d8a08e87d553 (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
#pragma once

#include "types.hh"

namespace nix { class Store; }

namespace nix::fetchers {

struct Input;

struct Registry
{
    enum RegistryType {
        Flag = 0,
        User = 1,
        Global = 2,
    };

    RegistryType type;

    std::vector<std::pair<std::shared_ptr<const Input>, std::shared_ptr<const Input>>> entries;

    static std::shared_ptr<Registry> read(
        const Path & path, RegistryType type);

    void write(const Path & path);

    void add(
        const std::shared_ptr<const Input> & from,
        const std::shared_ptr<const Input> & to);

    void remove(const std::shared_ptr<const Input> & input);
};

typedef std::vector<std::shared_ptr<Registry>> Registries;

std::shared_ptr<Registry> getUserRegistry();

Path getUserRegistryPath();

Registries getRegistries(ref<Store> store);

std::shared_ptr<const Input> lookupInRegistries(
    ref<Store> store,
    std::shared_ptr<const Input> input);

}