aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/buildable.hh
blob: db78316bd01be371add158752d4af389139ab8c7 (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
#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);
};

template<typename Outputs>
struct BuildableForFromDrv {
    StorePath drvPath;
    Outputs outputs;

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

template <typename Outputs>
using BuildableFor = std::variant<
    BuildableOpaque,
    BuildableForFromDrv<Outputs>
>;

typedef BuildableForFromDrv<std::set<std::string>> BuildableReqFromDrv;
typedef BuildableFor<std::set<std::string>> BuildableReq;

std::string to_string(const Store & store, const BuildableReq &);

BuildableReq parseBuildableReq(const Store & store, std::string_view);

typedef BuildableForFromDrv<std::map<std::string, std::optional<StorePath>>> BuildableFromDrv;
typedef BuildableFor<std::map<std::string, std::optional<StorePath>>> Buildable;

typedef std::vector<Buildable> Buildables;

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

}