2020-10-09 23:18:08 +03:00
|
|
|
#pragma once
|
2023-04-01 06:18:41 +03:00
|
|
|
///@file
|
2020-10-09 23:18:08 +03:00
|
|
|
|
|
|
|
#include "store-api.hh"
|
2022-03-01 20:31:36 +02:00
|
|
|
#include "gc-store.hh"
|
2022-03-08 20:20:39 +02:00
|
|
|
#include "log-store.hh"
|
2020-10-09 23:18:08 +03:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
struct LocalFSStoreConfig : virtual StoreConfig
|
|
|
|
{
|
|
|
|
using StoreConfig::StoreConfig;
|
2023-03-22 15:23:36 +02:00
|
|
|
|
2024-07-18 06:32:27 +03:00
|
|
|
/**
|
|
|
|
* Used to override the `root` settings. Can't be done via modifying
|
|
|
|
* `params` reliably because this parameter is unused except for
|
|
|
|
* passing to base class constructors.
|
|
|
|
*
|
|
|
|
* @todo Make this less error-prone with new store settings system.
|
|
|
|
*/
|
|
|
|
LocalFSStoreConfig(PathView path, const Params & params);
|
|
|
|
|
2023-10-31 00:12:37 +02:00
|
|
|
const OptionalPathSetting rootDir{this, std::nullopt,
|
2023-03-22 15:23:36 +02:00
|
|
|
"root",
|
|
|
|
"Directory prefixed to all other paths."};
|
|
|
|
|
2023-10-31 00:12:37 +02:00
|
|
|
const PathSetting stateDir{this,
|
2023-05-19 17:56:59 +03:00
|
|
|
rootDir.get() ? *rootDir.get() + "/nix/var/nix" : settings.nixStateDir,
|
2023-03-22 15:23:36 +02:00
|
|
|
"state",
|
|
|
|
"Directory where Nix will store state."};
|
|
|
|
|
2023-10-31 00:12:37 +02:00
|
|
|
const PathSetting logDir{this,
|
2023-05-19 17:56:59 +03:00
|
|
|
rootDir.get() ? *rootDir.get() + "/nix/var/log/nix" : settings.nixLogDir,
|
2023-03-22 15:23:36 +02:00
|
|
|
"log",
|
|
|
|
"directory where Nix will store log files."};
|
|
|
|
|
2023-10-31 00:12:37 +02:00
|
|
|
const PathSetting realStoreDir{this,
|
2023-05-19 17:56:59 +03:00
|
|
|
rootDir.get() ? *rootDir.get() + "/nix/store" : storeDir, "real",
|
2023-03-22 15:23:36 +02:00
|
|
|
"Physical path of the Nix store."};
|
2020-10-09 23:18:08 +03:00
|
|
|
};
|
|
|
|
|
2022-03-08 20:20:39 +02:00
|
|
|
class LocalFSStore : public virtual LocalFSStoreConfig,
|
|
|
|
public virtual Store,
|
|
|
|
public virtual GcStore,
|
|
|
|
public virtual LogStore
|
2020-10-09 23:18:08 +03:00
|
|
|
{
|
|
|
|
public:
|
2023-03-23 16:06:45 +02:00
|
|
|
inline static std::string operationName = "Local Filesystem Store";
|
2020-10-09 23:18:08 +03:00
|
|
|
|
2022-02-25 17:00:00 +02:00
|
|
|
const static std::string drvsLogDir;
|
2020-10-09 23:18:08 +03:00
|
|
|
|
|
|
|
LocalFSStore(const Params & params);
|
|
|
|
|
|
|
|
void narFromPath(const StorePath & path, Sink & sink) override;
|
2023-09-04 16:51:23 +03:00
|
|
|
ref<SourceAccessor> getFSAccessor(bool requireValidPath = true) override;
|
2020-10-09 23:18:08 +03:00
|
|
|
|
2023-04-07 16:55:28 +03:00
|
|
|
/**
|
2023-03-23 16:06:45 +02:00
|
|
|
* Creates symlink from the `gcRoot` to the `storePath` and
|
|
|
|
* registers the `gcRoot` as a permanent GC root. The `gcRoot`
|
|
|
|
* symlink lives outside the store and is created and owned by the
|
|
|
|
* user.
|
|
|
|
*
|
|
|
|
* @param gcRoot The location of the symlink.
|
|
|
|
*
|
|
|
|
* @param storePath The store object being rooted. The symlink will
|
|
|
|
* point to `toRealPath(store.printStorePath(storePath))`.
|
|
|
|
*
|
|
|
|
* How the permanent GC root corresponding to this symlink is
|
|
|
|
* managed is implementation-specific.
|
2023-04-07 16:55:28 +03:00
|
|
|
*/
|
2023-03-23 16:06:45 +02:00
|
|
|
virtual Path addPermRoot(const StorePath & storePath, const Path & gcRoot) = 0;
|
2020-10-09 23:18:08 +03:00
|
|
|
|
2021-06-18 18:04:11 +03:00
|
|
|
virtual Path getRealStoreDir() { return realStoreDir; }
|
2020-10-09 23:18:08 +03:00
|
|
|
|
|
|
|
Path toRealPath(const Path & storePath) override
|
|
|
|
{
|
|
|
|
assert(isInStore(storePath));
|
|
|
|
return getRealStoreDir() + "/" + std::string(storePath, storeDir.size() + 1);
|
|
|
|
}
|
|
|
|
|
2022-12-15 22:58:54 +02:00
|
|
|
std::optional<std::string> getBuildLogExact(const StorePath & path) override;
|
2022-01-17 23:20:05 +02:00
|
|
|
|
2020-10-09 23:18:08 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|