Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
local-overlay-store.hh
1
#include "
nix/store/local-store.hh
"
2
3
namespace
nix {
4
8
struct
LocalOverlayStoreConfig :
virtual
LocalStoreConfig
9
{
10
private
:
11
void
anchor()
override
;
12
13
public
:
14
LocalOverlayStoreConfig(
const
StringMap
& params)
15
: LocalOverlayStoreConfig(
""
, params)
16
{
17
}
18
19
LocalOverlayStoreConfig(
const
std::filesystem::path & path,
const
Params & params)
20
:
StoreConfig
(params,
FilePathType::Native
)
21
,
LocalFSStoreConfig
(path, params)
22
, LocalStoreConfig(path, params)
23
{
24
}
25
26
Setting<std::string>
lowerStoreUri{
27
(
StoreConfig
*)
this
,
28
""
,
29
"lower-store"
,
30
R
"(
31
[Store URL](@docroot@/command-ref/new-cli/nix3-help-stores.md#store-url-format)
32
for the lower store. The default is `auto` (i.e. use the Nix daemon or `/nix/store` directly).
33
34
Must be a store with a store dir on the file system.
35
Must be used as OverlayFS lower layer for this store's store dir.
36
)"};
37
38
/* The default is a placeholder, but it must still be an absolute
39
path on the host. */
40
const
Setting<AbsolutePath>
upperLayer{
41
(
StoreConfig
*)
this
,
42
#ifdef _WIN32
43
"C:\\"
44
#
else
45
"/"
46
#endif
47
"upper-layer-must-be-set"
,
48
"upper-layer"
,
49
R
"(
50
Directory containing the OverlayFS upper layer for this store's store dir.
51
)"};
52
53
Setting<bool>
checkMount{
54
(
StoreConfig
*)
this
,
55
true
,
56
"check-mount"
,
57
R
"(
58
Check that the overlay filesystem is correctly mounted.
59
60
Nix does not manage the overlayfs mount point itself, but the correct
61
functioning of the overlay store does depend on this mount point being set up
62
correctly. Rather than just assume this is the case, check that the lowerdir
63
and upperdir options are what we expect them to be. This check is on by
64
default, but can be disabled if needed.
65
)"};
66
67
const
Setting<std::optional<AbsolutePath>
> remountHook{
68
(
StoreConfig
*)
this
,
69
std::nullopt,
70
"remount-hook"
,
71
R
"(
72
Script or other executable to run when overlay filesystem needs remounting.
73
74
This is occasionally necessary when deleting a store path that exists in both upper and lower layers.
75
In such a situation, bypassing OverlayFS and deleting the path in the upper layer directly
76
is the only way to perform the deletion without creating a "whiteout".
77
However this causes the OverlayFS kernel data structures to get out-of-sync,
78
and can lead to 'stale file handle' errors; remounting solves the problem.
79
80
The store directory is passed as an argument to the invoked executable.
81
)"};
82
83
static
const
std::string name()
84
{
85
return
"Experimental Local Overlay Store"
;
86
}
87
88
static
std::optional<ExperimentalFeature> experimentalFeature()
89
{
90
return
ExperimentalFeature::LocalOverlayStore;
91
}
92
93
static
StringSet
uriSchemes()
94
{
95
return
{
"local-overlay"
};
96
}
97
98
static
std::string doc();
99
100
ref<Store>
openStore
()
const override
;
101
102
StoreReference
getReference
()
const override
;
103
104
protected
:
113
std::filesystem::path
toUpperPath
(
const
StorePath
& path)
const
;
114
115
friend
struct
LocalOverlayStore;
116
};
117
124
struct
LocalOverlayStore :
virtual
LocalStore
125
{
126
using
Config =
LocalOverlayStoreConfig
;
127
128
ref<const Config>
config;
129
130
LocalOverlayStore(
ref<const Config>
);
131
132
private
:
133
void
anchor()
override
;
134
142
ref<LocalFSStore>
lowerStore;
143
148
void
registerDrvOutputUnchecked(
const
Realisation
& info)
override
;
149
153
void
queryPathInfoUncached(
154
const
StorePath
& path,
Callback
<std::shared_ptr<const ValidPathInfo>> callback)
noexcept
override
;
155
162
bool
isValidPathUncached(
const
StorePath
& path)
override
;
163
167
void
queryReferrers(
const
StorePath
& path, StorePathSet & referrers)
override
;
168
172
StorePathSet queryValidDerivers(
const
StorePath
& path)
override
;
173
177
std::optional<StorePath> queryPathFromHashPart(
const
std::string & hashPart)
override
;
178
183
void
registerValidPaths(
const
ValidPathInfos & infos)
override
;
184
188
void
queryRealisationUncached(
189
const
DrvOutput
&,
Callback
<std::shared_ptr<const UnkeyedRealisation>> callback)
noexcept
override
;
190
194
void
collectGarbage(
const
GCOptions
& options,
GCResults
& results)
override
;
195
200
void
deleteStorePath(
const
std::filesystem::path & path, uint64_t & bytesFreed,
bool
isKnownPath)
override
;
201
215
void
optimiseStore()
override
;
216
226
VerificationResult
verifyAllValidPaths(RepairFlag repair)
override
;
227
231
void
queryGCReferrers(
const
StorePath
& path, StorePathSet & referrers)
override
;
232
238
void
remountIfNecessary();
239
243
std::atomic_bool _remountRequired =
false
;
244
};
245
246
}
// namespace nix
nix::Callback
Definition
callback.hh:19
nix::LocalStore::LocalStore
LocalStore(ref< const Config > params)
Definition
local-store.cc:126
nix::Setting
Definition
configuration.hh:476
nix::StorePath
Definition
path.hh:33
nix::ref
Definition
ref.hh:58
local-store.hh
nix::DrvOutput
Definition
realisation.hh:26
nix::GCOptions
Definition
gc-store.hh:38
nix::GCResults
Definition
gc-store.hh:78
nix::LocalFSStoreConfig
Definition
local-fs-store.hh:11
nix::LocalOverlayStoreConfig
Definition
local-overlay-store.hh:9
nix::LocalOverlayStoreConfig::openStore
ref< Store > openStore() const override
Definition
local-overlay-store.cc:24
nix::LocalOverlayStoreConfig::getReference
StoreReference getReference() const override
Definition
local-overlay-store.cc:30
nix::LocalOverlayStoreConfig::toUpperPath
std::filesystem::path toUpperPath(const StorePath &path) const
Definition
local-overlay-store.cc:40
nix::LocalStore::VerificationResult
Definition
local-store.hh:416
nix::Realisation
Definition
realisation.hh:103
nix::StoreConfigBase::FilePathType::Native
@ Native
Definition
store-api.hh:163
nix::StoreConfig
Definition
store-api.hh:240
nix::StringMap
std::map< std::string, std::string, std::less<> > StringMap
Definition
types.hh:26
nix::StringSet
std::set< std::string, std::less<> > StringSet
Definition
types.hh:45
libstore
include
nix
store
local-overlay-store.hh
Generated by
1.18.0