aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/buildable.hh
blob: 8317f39950bb0362cf2bedc25cde2441e1c460f0 (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
#pragma once

#include "util.hh"
#include "path.hh"
#include "path.hh"

#include <optional>

#include <nlohmann/json_fwd.hpp>

namespace nix {

class Store;

struct BuildableOpaque {
    StorePath path;

    nlohmann::json toJSON(ref<Store> store) const;
    std::string to_string(const Store & store) const;
    static BuildableOpaque parse(const Store & store, std::string_view);
};

struct BuildableReqFromDrv {
    StorePath drvPath;
    std::set<std::string> outputs;

    std::string to_string(const Store & store) const;
    static BuildableReqFromDrv parse(const Store & store, std::string_view);
};

using _BuildableReqRaw = std::variant<
    BuildableOpaque,
    BuildableReqFromDrv
>;

struct BuildableReq : _BuildableReqRaw {
    using Raw = _BuildableReqRaw;
    using Raw::Raw;

    inline const Raw & raw() const {
        return static_cast<const Raw &>(*this);
    }

    std::string to_string(const Store & store) const;
    static BuildableReq parse(const Store & store, std::string_view);
};

struct BuildableFromDrv {
    StorePath drvPath;
    std::map<std::string, std::optional<StorePath>> outputs;

    nlohmann::json toJSON(ref<Store> store) const;
    static BuildableFromDrv parse(const Store & store, std::string_view);
};

using Buildable = std::variant<
    BuildableOpaque,
    BuildableFromDrv
>;

typedef std::vector<Buildable> Buildables;

nlohmann::json buildablesToJSON(const Buildables & buildables, ref<Store> store);

}