Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
local-fs-store.hh
Go to the documentation of this file.
1#pragma once
3
4#include "store-api.hh"
5#include "gc-store.hh"
6#include "log-store.hh"
7
8namespace nix {
9
10struct LocalFSStoreConfig : virtual StoreConfig
11{
12 using StoreConfig::StoreConfig;
13
21 LocalFSStoreConfig(PathView path, const Params & params);
22
23 const OptionalPathSetting rootDir{this, std::nullopt,
24 "root",
25 "Directory prefixed to all other paths."};
26
27 const PathSetting stateDir{this,
28 rootDir.get() ? *rootDir.get() + "/nix/var/nix" : settings.nixStateDir,
29 "state",
30 "Directory where Nix will store state."};
31
32 const PathSetting logDir{this,
33 rootDir.get() ? *rootDir.get() + "/nix/var/log/nix" : settings.nixLogDir,
34 "log",
35 "directory where Nix will store log files."};
36
37 const PathSetting realStoreDir{this,
38 rootDir.get() ? *rootDir.get() + "/nix/store" : storeDir, "real",
39 "Physical path of the Nix store."};
40};
41
42class LocalFSStore : public virtual LocalFSStoreConfig,
43 public virtual Store,
44 public virtual GcStore,
45 public virtual LogStore
46{
47public:
48 inline static std::string operationName = "Local Filesystem Store";
49
50 const static std::string drvsLogDir;
51
52 LocalFSStore(const Params & params);
53
54 void narFromPath(const StorePath & path, Sink & sink) override;
55 ref<SourceAccessor> getFSAccessor(bool requireValidPath = true) override;
56
71 virtual Path addPermRoot(const StorePath & storePath, const Path & gcRoot) = 0;
72
73 virtual Path getRealStoreDir() { return realStoreDir; }
74
75 Path toRealPath(const Path & storePath) override
76 {
77 assert(isInStore(storePath));
78 return getRealStoreDir() + "/" + std::string(storePath, storeDir.size() + 1);
79 }
80
81 std::optional<std::string> getBuildLogExact(const StorePath & path) override;
82
83};
84
85}
void narFromPath(const StorePath &path, Sink &sink) override
Definition local-fs-store.cc:83
ref< SourceAccessor > getFSAccessor(bool requireValidPath=true) override
Definition local-fs-store.cc:76
virtual Path addPermRoot(const StorePath &storePath, const Path &gcRoot)=0
Definition config.hh:367
Definition config.hh:345
Definition path.hh:27
Definition ref.hh:15
Path toRealPath(const Path &path, const NixStringContext &context)
std::string path
Definition lexer.l:1399
Definition gc-store.hh:102
LocalFSStoreConfig(PathView path, const Params &params)
Definition local-fs-store.cc:11
Definition log-store.hh:10
Definition serialise.hh:20
bool isInStore(PathView path) const
Definition store-api.cc:32
std::string Path
Definition types.hh:22