2020-10-09 20:18:08 +00:00
|
|
|
#pragma once
|
2023-04-01 03:18:41 +00:00
|
|
|
///@file
|
2020-10-09 20:18:08 +00:00
|
|
|
|
|
|
|
#include "store-api.hh"
|
2022-03-01 18:31:36 +00:00
|
|
|
#include "gc-store.hh"
|
2022-03-08 18:20:39 +00:00
|
|
|
#include "log-store.hh"
|
2020-10-09 20:18:08 +00:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
struct LocalFSStoreConfig : virtual StoreConfig
|
|
|
|
{
|
|
|
|
using StoreConfig::StoreConfig;
|
2023-03-22 13:23:36 +00:00
|
|
|
|
2024-03-04 04:24:33 +00:00
|
|
|
const OptionalPathSetting rootDir{this, std::nullopt,
|
2023-03-22 13:23:36 +00:00
|
|
|
"root",
|
|
|
|
"Directory prefixed to all other paths."};
|
|
|
|
|
2024-03-04 04:24:33 +00:00
|
|
|
const PathSetting stateDir{this,
|
2023-05-19 14:56:59 +00:00
|
|
|
rootDir.get() ? *rootDir.get() + "/nix/var/nix" : settings.nixStateDir,
|
2023-03-22 13:23:36 +00:00
|
|
|
"state",
|
|
|
|
"Directory where Nix will store state."};
|
|
|
|
|
2024-03-04 04:24:33 +00:00
|
|
|
const PathSetting logDir{this,
|
2023-05-19 14:56:59 +00:00
|
|
|
rootDir.get() ? *rootDir.get() + "/nix/var/log/nix" : settings.nixLogDir,
|
2023-03-22 13:23:36 +00:00
|
|
|
"log",
|
|
|
|
"directory where Nix will store log files."};
|
|
|
|
|
2024-03-04 04:24:33 +00:00
|
|
|
const PathSetting realStoreDir{this,
|
2023-05-19 14:56:59 +00:00
|
|
|
rootDir.get() ? *rootDir.get() + "/nix/store" : storeDir, "real",
|
2023-03-22 13:23:36 +00:00
|
|
|
"Physical path of the Nix store."};
|
2020-10-09 20:18:08 +00:00
|
|
|
};
|
|
|
|
|
2022-03-08 18:20:39 +00:00
|
|
|
class LocalFSStore : public virtual LocalFSStoreConfig,
|
|
|
|
public virtual Store,
|
|
|
|
public virtual GcStore,
|
|
|
|
public virtual LogStore
|
2020-10-09 20:18:08 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-03-23 14:06:45 +00:00
|
|
|
inline static std::string operationName = "Local Filesystem Store";
|
2020-10-09 20:18:08 +00:00
|
|
|
|
2022-02-25 15:00:00 +00:00
|
|
|
const static std::string drvsLogDir;
|
2020-10-09 20:18:08 +00:00
|
|
|
|
|
|
|
LocalFSStore(const Params & params);
|
|
|
|
|
|
|
|
void narFromPath(const StorePath & path, Sink & sink) override;
|
|
|
|
ref<FSAccessor> getFSAccessor() override;
|
|
|
|
|
2023-04-07 13:55:28 +00:00
|
|
|
/**
|
2023-03-23 14:06:45 +00: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 13:55:28 +00:00
|
|
|
*/
|
2023-03-23 14:06:45 +00:00
|
|
|
virtual Path addPermRoot(const StorePath & storePath, const Path & gcRoot) = 0;
|
2020-10-09 20:18:08 +00:00
|
|
|
|
2021-06-18 15:04:11 +00:00
|
|
|
virtual Path getRealStoreDir() { return realStoreDir; }
|
2020-10-09 20:18:08 +00:00
|
|
|
|
|
|
|
Path toRealPath(const Path & storePath) override
|
|
|
|
{
|
|
|
|
assert(isInStore(storePath));
|
|
|
|
return getRealStoreDir() + "/" + std::string(storePath, storeDir.size() + 1);
|
|
|
|
}
|
|
|
|
|
2022-12-15 20:58:54 +00:00
|
|
|
std::optional<std::string> getBuildLogExact(const StorePath & path) override;
|
2022-01-17 21:20:05 +00:00
|
|
|
|
2020-10-09 20:18:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|