14#include <unordered_set>
33 unsigned long filesLinked = 0;
34 uint64_t bytesFreed = 0;
42 std::string_view scheme,
43 std::string_view authority,
44 const Params & params);
49 "Whether store paths copied into this store should have a trusted signature."};
55 Allow this store to be opened when its [database](@docroot@/glossary.md#gloss-nix-database) is on a read-only filesystem.
57 Normally Nix will attempt to open the store database in read-write mode, even for querying (when write access is not needed), causing it to fail if the database is on a read-only filesystem.
59 Enable read-only mode to disable locking and open the SQLite database with the [`immutable` parameter](https://www.sqlite.org/c3ref/open.html) set.
62 > Do not use this unless the filesystem is read-only.
64 > Using it when the filesystem is writable can cause incorrect query results or corruption errors if the database is changed by another process.
65 > While the filesystem the database resides on might appear to be read-only, consider whether another user or system might have write access to it.
68 const std::string
name()
override {
return "Local Store"; }
70 static std::set<std::string> uriSchemes()
73 std::string
doc()
override;
95 std::unique_ptr<Stmts> stmts;
101 std::chrono::time_point<std::chrono::steady_clock> lastGCCheck;
107 bool gcRunning =
false;
108 std::shared_future<void> gcFuture;
116 uint64_t availAfterGC = std::numeric_limits<uint64_t>::max();
118 std::unique_ptr<PublicKeys> publicKeys;
127 const Path reservedPath;
128 const Path schemaPath;
129 const Path tempRootsDir;
130 const Path fnTempRoots;
134 const PublicKeys & getPublicKeys();
149 std::string_view scheme,
151 const Params & params);
159 std::string
getUri()
override;
161 bool isValidPathUncached(
const StorePath & path)
override;
164 SubstituteFlag maybeSubstitute = NoSubstitute)
override;
168 void queryPathInfoUncached(
const StorePath & path,
169 Callback<std::shared_ptr<const ValidPathInfo>> callback)
noexcept override;
182 bool realisationIsUntrusted(
const Realisation & )
override;
185 RepairFlag
repair, CheckSigsFlag checkSigs)
override;
189 std::string_view
name,
192 HashAlgorithm hashAlgo,
193 const StorePathSet & references,
194 RepairFlag
repair)
override;
200 void createTempRootsFile();
205 Sync<AutoCloseFD> _fdTempRoots;
210 Sync<AutoCloseFD> _fdGCLock;
215 Sync<AutoCloseFD> _fdRootsSocket;
229 void findTempRoots(Roots & roots,
bool censor);
309 virtual void registerValidPaths(
const ValidPathInfos & infos);
323 void autoGC(
bool sync =
true);
331 void cacheDrvOutputMapping(
333 const uint64_t deriver,
334 const std::string & outputName,
337 std::optional<const Realisation> queryRealisation_(State & state,
const DrvOutput &
id);
338 std::optional<std::pair<int64_t, Realisation>> queryRealisationCore_(State & state,
const DrvOutput &
id);
339 void queryRealisationUncached(
const DrvOutput&,
340 Callback<std::shared_ptr<const Realisation>> callback)
noexcept override;
342 std::optional<std::string> getVersion()
override;
346 void verifyPath(
const StorePath & path, std::function<
bool(
const StorePath &)> existsInStoreDir,
347 StorePathSet & done, StorePathSet & validPaths, RepairFlag
repair,
bool &
errors);
357 void openDB(State & state,
bool create);
359 void upgradeDBSchema(State & state);
361 void makeStoreWritable();
363 uint64_t queryValidPathId(State & state,
const StorePath & path);
365 uint64_t addValidPath(State & state,
const ValidPathInfo & info,
bool checkOutputs =
true);
367 void invalidatePath(State & state,
const StorePath & path);
372 void invalidatePathChecked(
const StorePath & path);
374 std::shared_ptr<const ValidPathInfo> queryPathInfoInternal(State & state,
const StorePath & path);
376 void updatePathInfo(State & state,
const ValidPathInfo & info);
378 PathSet queryValidPathsOld();
381 void findRoots(
const Path & path, std::filesystem::file_type
type, Roots & roots);
383 void findRootsNoTemp(Roots & roots,
bool censor);
385 void findRuntimeRoots(Roots & roots,
bool censor);
387 std::pair<std::filesystem::path, AutoCloseFD> createTempDirInStore();
389 typedef std::unordered_set<ino_t> InodeHash;
391 InodeHash loadInodeHash();
392 Strings readDirectoryIgnoringInodes(
const Path & path,
const InodeHash & inodeHash);
396 bool isValidPath_(State & state,
const StorePath & path);
406 void addBuildLog(
const StorePath & drvPath, std::string_view log)
override;
408 friend struct LocalDerivationGoal;
409 friend struct PathSubstitutionGoal;
410 friend struct SubstitutionGoal;
411 friend struct DerivationGoal;
Definition file-descriptor.hh:152
Definition callback.hh:17
virtual VerificationResult verifyAllValidPaths(RepairFlag repair)
Definition local-store.cc:1439
StorePathSet queryValidPaths(const StorePathSet &paths, SubstituteFlag maybeSubstitute=NoSubstitute) override
Definition local-store.cc:790
std::string getUri() override
Definition local-store.cc:407
StorePathSet queryAllValidPaths() override
Definition local-store.cc:799
Roots findRoots(bool censor) override
Definition gc.cc:299
std::optional< TrustedFlag > isTrustedClient() override
Definition local-store.cc:1529
void queryReferrers(const StorePath &path, StorePathSet &referrers) override
Definition local-store.cc:820
void addSignatures(const StorePath &storePath, const StringSet &sigs) override
Definition local-store.cc:1542
virtual void deleteStorePath(const Path &path, uint64_t &bytesFreed)
Definition local-store.cc:374
void addTempRoot(const StorePath &path) override
Definition gc.cc:81
LocalStore(const Params ¶ms)
Definition local-store.cc:354
bool pathInfoIsUntrusted(const ValidPathInfo &) override
Definition local-store.cc:1006
void addIndirectRoot(const Path &path) override
Definition gc.cc:41
StorePathSet queryValidDerivers(const StorePath &path) override
Definition local-store.cc:829
void addToStore(const ValidPathInfo &info, Source &source, RepairFlag repair, CheckSigsFlag checkSigs) override
Definition local-store.cc:1016
void registerDrvOutput(const Realisation &info) override
Definition local-store.cc:571
void collectGarbage(const GCOptions &options, GCResults &results) override
Definition gc.cc:452
void registerValidPath(const ValidPathInfo &info)
Definition local-store.cc:914
bool verifyStore(bool checkContents, RepairFlag repair) override
Definition local-store.cc:1342
unsigned int getProtocol() override
Definition local-store.cc:1524
StorePath addToStoreFromDump(Source &dump, std::string_view name, FileSerialisationMethod dumpMethod, ContentAddressMethod hashMethod, HashAlgorithm hashAlgo, const StorePathSet &references, RepairFlag repair) override
Definition local-store.cc:1133
virtual void queryGCReferrers(const StorePath &path, StorePathSet &referrers)
Definition local-store.hh:246
PathSet locksHeld
Definition local-store.hh:141
std::map< std::string, std::optional< StorePath > > queryStaticPartialDerivationOutputMap(const StorePath &path) override
Definition local-store.cc:846
StorePathSet querySubstitutablePaths(const StorePathSet &paths) override
Definition local-store.cc:883
void optimiseStore() override
Definition optimise-store.cc:294
void autoGC(bool sync=true)
Definition gc.cc:898
void optimisePath(const Path &path, RepairFlag repair)
Definition optimise-store.cc:305
std::optional< StorePath > queryPathFromHashPart(const std::string &hashPart) override
Definition local-store.cc:862
FileSerialisationMethod
Definition file-content-address.hh:20
ErrorPrintBehavior errors
Definition lexer.l:4867
const Activity & act
Definition lexer.l:2371
Symbol create(std::string_view s)
Definition lexer.l:1018
ValueType type
Definition lexer.l:7098
RepairFlag repair
Definition lexer.l:7173
const int nixSchemaVersion
Definition local-store.hh:28
Definition logging.hh:137
Definition content-address.hh:31
Definition realisation.hh:24
Definition gc-store.hh:15
Definition gc-store.hh:60
Definition gc-store.hh:102
Definition indirect-root-store.hh:40
LocalFSStoreConfig(PathView path, const Params ¶ms)
Definition local-fs-store.cc:11
const std::string name() override
Definition local-store.hh:68
LocalFSStoreConfig(PathView path, const Params ¶ms)
Definition local-fs-store.cc:11
std::string doc() override
Definition local-store.cc:69
Definition local-store.hh:279
StorePathSet validPaths
Definition local-store.hh:289
bool errors
Definition local-store.hh:283
Definition local-store.hh:32
Definition realisation.hh:49
Definition serialise.hh:68
Definition path-info.hh:130
std::string Path
Definition types.hh:22