Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
nar-info.hh
Go to the documentation of this file.
1
#pragma once
3
4
#include "
nix/util/compression-algo.hh
"
5
#include "
nix/util/types.hh
"
6
#include "
nix/util/hash.hh
"
7
#include "
nix/store/path-info.hh
"
8
9
namespace
nix {
10
11
struct
StoreDirConfig
;
12
13
struct
UnkeyedNarInfo :
virtual
UnkeyedValidPathInfo
14
{
15
std::string url;
16
std::optional<CompressionAlgo> compression;
17
std::optional<Hash> fileHash;
18
uint64_t fileSize = 0;
19
20
UnkeyedNarInfo(UnkeyedValidPathInfo info)
21
: UnkeyedValidPathInfo(std::move(info))
22
{
23
}
24
25
bool
operator==(
const
UnkeyedNarInfo &)
const
=
default
;
26
// TODO libc++ 16 (used by darwin) missing `std::optional::operator <=>`, can't do yet
27
// auto operator <=>(const NarInfo &) const = default;
28
29
nlohmann::json
30
toJSON
(
const
StoreDirConfig
* store,
bool
includeImpureInfo,
PathInfoJsonFormat
format)
const override
;
31
static
UnkeyedNarInfo fromJSON(
const
StoreDirConfig
* store,
const
nlohmann::json & json);
32
};
33
37
struct
NarInfo : ValidPathInfo, UnkeyedNarInfo
38
{
39
private
:
40
void
anchor()
override
;
41
42
public
:
43
NarInfo() =
delete
;
44
45
NarInfo(ValidPathInfo info)
46
:
UnkeyedValidPathInfo
{
static_cast<
UnkeyedValidPathInfo
&&
>
(info)}
47
/* Later copies from `*this` are pointless. The argument is only
48
there so the constructors can also call
49
`UnkeyedValidPathInfo`, but this won't happen since the base
50
class is virtual. Only this constructor (assuming it is most
51
derived) will initialize that virtual base class. */
52
, ValidPathInfo{info.path,
static_cast<
const
UnkeyedValidPathInfo
&
>
(*this)}
53
, UnkeyedNarInfo{
static_cast<
const
UnkeyedValidPathInfo
&
>
(*this)}
54
{
55
}
56
57
NarInfo(
const
StoreDirConfig
& store,
StorePath
path,
Hash
narHash
)
58
: NarInfo{ValidPathInfo{std::move(path),
UnkeyedValidPathInfo
{store,
narHash
}}}
59
{
60
}
61
62
NarInfo(std::string
storeDir
,
StorePath
path,
Hash
narHash
)
63
: NarInfo{ValidPathInfo{std::move(path),
UnkeyedValidPathInfo
{std::move(
storeDir
),
narHash
}}}
64
{
65
}
66
67
static
NarInfo
68
makeFromCA(
const
StoreDirConfig
& store, std::string_view name,
ContentAddressWithReferences
ca
,
Hash
narHash
)
69
{
70
return
ValidPathInfo::makeFromCA(store, std::move(name), std::move(
ca
),
narHash
);
71
}
72
73
NarInfo(
const
StoreDirConfig
& store,
const
std::string & s,
const
std::string & whence);
74
75
bool
operator==(
const
NarInfo &)
const
=
default
;
76
77
std::string to_string(
const
StoreDirConfig
& store)
const
;
78
};
79
80
}
// namespace nix
81
82
JSON_IMPL(
nix::UnkeyedNarInfo
)
nix::StorePath
Definition
path.hh:33
compression-algo.hh
hash.hh
path-info.hh
nix::PathInfoJsonFormat
PathInfoJsonFormat
Definition
path-info.hh:20
nix::ContentAddressWithReferences
Definition
content-address.hh:284
nix::Hash
Definition
hash.hh:58
nix::StoreDirConfig
Definition
store-dir-config.hh:29
nix::UnkeyedNarInfo
Definition
nar-info.hh:14
nix::UnkeyedNarInfo::toJSON
nlohmann::json toJSON(const StoreDirConfig *store, bool includeImpureInfo, PathInfoJsonFormat format) const override
Definition
nar-info.cc:145
nix::UnkeyedValidPathInfo
Definition
path-info.hh:58
nix::UnkeyedValidPathInfo::storeDir
std::string storeDir
Definition
path-info.hh:65
nix::UnkeyedValidPathInfo::ca
std::optional< ContentAddress > ca
Definition
path-info.hh:118
nix::UnkeyedValidPathInfo::narHash
Hash narHash
Definition
path-info.hh:75
types.hh
libstore
include
nix
store
nar-info.hh
Generated by
1.18.0