Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
local-fs-store.hh
Go to the documentation of this file.
1
#pragma once
3
4
#include "
nix/store/store-api.hh
"
5
#include "
nix/store/gc-store.hh
"
6
#include "
nix/store/log-store.hh
"
7
8
namespace
nix {
9
10
struct
LocalFSStoreConfig :
virtual
StoreConfig
11
{
12
private
:
13
void
anchor()
override
;
14
15
static
Setting<std::optional<AbsolutePath>
>
16
makeRootDirSetting(LocalFSStoreConfig & self, std::optional<AbsolutePath> defaultValue)
17
{
18
return
{
19
&self,
20
std::move(defaultValue),
21
"root"
,
22
"Directory prefixed to all other paths."
,
23
};
24
}
25
26
public
:
27
LocalFSStoreConfig(
const
Params & params)
28
: StoreConfig(params,
FilePathType::Native
)
29
{
30
}
31
39
LocalFSStoreConfig(
const
std::filesystem::path & path,
const
Params & params);
40
41
Setting<std::optional<AbsolutePath>
> rootDir = makeRootDirSetting(*
this
, std::nullopt);
42
43
Setting<AbsolutePath>
stateDir{
44
this
,
45
rootDir.get() ? *rootDir.get() /
"nix"
/
"var"
/
"nix"
:
StoreConfig::getStateDir
(),
46
"state"
,
47
R
"(
48
Directory where Nix stores state.
49
50
Defaults to [`NIX_STATE_DIR`](@docroot@/command-ref/env-common.md#env-NIX_STATE_DIR) when [`root`](#@store-slug@-root) is not set.
51
)",
52
};
53
54
Setting<AbsolutePath>
logDir{
55
this
,
56
rootDir.get() ? *rootDir.get() /
"nix"
/
"var"
/
"log"
/
"nix"
:
StoreConfig::getLogDir
(),
57
"log"
,
58
R
"(
59
Directory where Nix stores log files.
60
61
Defaults to [`NIX_LOG_DIR`](@docroot@/command-ref/env-common.md#env-NIX_LOG_DIR) when [`root`](#@store-slug@-root) is not set.
62
)",
63
};
64
65
Setting<AbsolutePath>
realStoreDir{
66
this
,
67
rootDir.get() ? *rootDir.get() /
"nix"
/
"store"
: std::filesystem::path{storeDir},
68
"real"
,
69
R
"(
70
Physical path of the Nix store.
71
72
Defaults to [`store`](#@store-slug@-store) when [`root`](#@store-slug@-root) is not set.
73
)",
74
};
75
76
const
std::filesystem::path &
getStateDir
()
const override
77
{
78
return
stateDir.get();
79
}
80
81
const
std::filesystem::path &
getLogDir
()
const override
82
{
83
return
logDir.get();
84
}
85
};
86
87
struct
alignas
(8)
/* Work around ASAN failures on i686-linux. */
88
LocalFSStore :
virtual
Store,
89
virtual
GcStore
,
90
virtual
LogStore
91
{
92
private
:
93
void
anchor()
override
;
94
95
public
:
96
using
Config =
LocalFSStoreConfig
;
97
98
const
Config & config;
99
100
inline
static
std::string operationName =
"Local Filesystem Store"
;
101
102
static
const
std::filesystem::path drvsLogDir;
103
104
LocalFSStore(
const
Config & params);
105
106
ref<SourceAccessor>
getFSAccessor
(
bool
requireValidPath =
true
)
override
;
107
std::shared_ptr<SourceAccessor>
getFSAccessor
(
const
StorePath
& path,
bool
requireValidPath =
true
)
override
;
108
123
virtual
std::filesystem::path
addPermRoot
(
const
StorePath
& storePath,
const
std::filesystem::path & gcRoot) = 0;
124
125
virtual
std::filesystem::path getRealStoreDir()
126
{
127
return
config.realStoreDir;
128
}
129
130
std::filesystem::path toRealPath(
const
StorePath
& storePath)
131
{
132
return
getRealStoreDir() / storePath.to_string();
133
}
134
135
std::optional<std::string> getBuildLogExact(
const
StorePath & path)
override
;
136
};
137
138
}
// namespace nix
nix::Setting
Definition
configuration.hh:476
nix::StorePath
Definition
path.hh:33
nix::ref
Definition
ref.hh:58
gc-store.hh
log-store.hh
store-api.hh
nix::GcStore
Definition
gc-store.hh:118
nix::LocalFSStoreConfig
Definition
local-fs-store.hh:11
nix::LocalFSStoreConfig::getStateDir
const std::filesystem::path & getStateDir() const override
Definition
local-fs-store.hh:76
nix::LocalFSStoreConfig::getLogDir
const std::filesystem::path & getLogDir() const override
Definition
local-fs-store.hh:81
nix::LocalFSStore::addPermRoot
virtual std::filesystem::path addPermRoot(const StorePath &storePath, const std::filesystem::path &gcRoot)=0
nix::LocalFSStore::getFSAccessor
ref< SourceAccessor > getFSAccessor(bool requireValidPath=true) override
Definition
local-fs-store.cc:178
nix::LogStore
Definition
log-store.hh:9
nix::StoreConfigBase::FilePathType::Native
@ Native
Definition
store-api.hh:163
nix::StoreConfig::getLogDir
virtual const std::filesystem::path & getLogDir() const
Definition
store-api.cc:1301
nix::StoreConfig::getStateDir
virtual const std::filesystem::path & getStateDir() const
Definition
store-api.cc:1296
libstore
include
nix
store
local-fs-store.hh
Generated by
1.18.0