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
|
|
|
|
2020-10-09 20:18:08 +00:00
|
|
|
// FIXME: the (StoreConfig*) cast works around a bug in gcc that causes
|
|
|
|
// it to omit the call to the Setting constructor. Clang works fine
|
|
|
|
// either way.
|
2023-03-22 13:23:36 +00:00
|
|
|
|
2023-05-19 14:56:59 +00:00
|
|
|
const OptionalPathSetting rootDir{(StoreConfig*) this, std::nullopt,
|
2023-03-22 13:23:36 +00:00
|
|
|
"root",
|
|
|
|
"Directory prefixed to all other paths."};
|
|
|
|
|
2023-05-19 14:56:59 +00:00
|
|
|
const PathSetting stateDir{(StoreConfig*) this,
|
|
|
|
rootDir.get() ? *rootDir.get() + "/nix/var/nix" : settings.nixStateDir,
|
2023-03-22 13:23:36 +00:00
|
|
|
"state",
|
|
|
|
"Directory where Nix will store state."};
|
|
|
|
|
2023-05-19 14:56:59 +00:00
|
|
|
const PathSetting logDir{(StoreConfig*) this,
|
|
|
|
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."};
|
|
|
|
|
2023-05-19 14:56:59 +00:00
|
|
|
const PathSetting realStoreDir{(StoreConfig*) this,
|
|
|
|
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:
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Register a permanent GC root.
|
|
|
|
*/
|
2020-10-09 20:18:08 +00:00
|
|
|
Path addPermRoot(const StorePath & storePath, const Path & gcRoot);
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|