Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
attrs.hh
Go to the documentation of this file.
1
#pragma once
3
4
#include "
nix/util/types.hh
"
5
#include "
nix/util/hash.hh
"
6
#include "
nix/util/ref.hh
"
7
#include "
nix/util/fun.hh
"
8
9
#include <variant>
10
11
#include <nlohmann/json_fwd.hpp>
12
13
#include <optional>
14
15
namespace
nix::fetchers {
16
20
using
ResolvedAttr
= std::variant<std::string, uint64_t, Explicit<bool>>;
21
25
struct
LazyAttrComputation
26
{
27
fun
<
ResolvedAttr
()> compute;
28
};
29
30
class
LazyAttr
31
{
32
ref<LazyAttrComputation>
inner;
33
34
public
:
35
LazyAttr(
ref<LazyAttrComputation>
inner)
36
: inner(std::move(inner))
37
{
38
}
39
40
ResolvedAttr
compute()
const
41
{
42
return
inner->compute();
43
}
44
45
bool
operator==(
const
LazyAttr & other)
const
=
delete
;
46
std::strong_ordering operator<=>(
const
LazyAttr & other)
const
=
delete
;
47
};
48
55
struct
Attr
: std::variant<std::string, uint64_t, Explicit<bool>, LazyAttr>
56
{
57
using
variant::variant;
58
59
bool
operator==(
const
Attr
& other)
const
;
60
std::strong_ordering operator<=>(
const
Attr
& other)
const
;
61
};
62
68
typedef
std::map<std::string, Attr>
Attrs
;
69
73
ResolvedAttr
forceAttr(
const
Attr
& attr);
74
78
std::optional<LazyAttr> maybeGetLazyAttr(
const
Attrs
& attrs,
const
std::string & name);
79
80
Attrs
jsonToAttrs(
const
nlohmann::json & json);
81
82
nlohmann::json attrsToJSON(
const
Attrs
& attrs);
83
84
std::optional<std::string> maybeGetStrAttr(
const
Attrs
& attrs,
const
std::string & name);
85
86
std::string getStrAttr(
const
Attrs
& attrs,
const
std::string & name);
87
88
std::optional<uint64_t> maybeGetIntAttr(
const
Attrs
& attrs,
const
std::string & name);
89
90
uint64_t getIntAttr(
const
Attrs
& attrs,
const
std::string & name);
91
92
std::optional<bool> maybeGetBoolAttr(
const
Attrs
& attrs,
const
std::string & name);
93
94
bool
getBoolAttr(
const
Attrs
& attrs,
const
std::string & name);
95
96
StringMap
attrsToQuery(
const
Attrs
& attrs);
97
98
Hash
getRevAttr(
const
Attrs
& attrs,
const
std::string & name);
99
100
}
// namespace nix::fetchers
nix::fetchers::Attrs
std::map< std::string, Attr > Attrs
Definition
attrs.hh:68
nix::fetchers::ResolvedAttr
std::variant< std::string, uint64_t, Explicit< bool > > ResolvedAttr
Definition
attrs.hh:20
nix::fun
Definition
fun.hh:19
nix::ref
Definition
ref.hh:58
fun.hh
hash.hh
ref.hh
nix::Hash
Definition
hash.hh:58
nix::fetchers::Attr
Definition
attrs.hh:56
nix::fetchers::LazyAttrComputation
Definition
attrs.hh:26
types.hh
nix::StringMap
std::map< std::string, std::string, std::less<> > StringMap
Definition
types.hh:26
libfetchers
include
nix
fetchers
attrs.hh
Generated by
1.18.0