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
|
|
|
|
2020-10-09 23:18:08 +03: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 15:23:36 +02:00
|
|
|
|
2023-05-19 17:56:59 +03:00
|
|
|
const OptionalPathSetting rootDir{(StoreConfig*) this, std::nullopt,
|
2023-03-22 15:23:36 +02:00
|
|
|
"root",
|
|
|
|
"Directory prefixed to all other paths."};
|
|
|
|
|
2023-05-19 17:56:59 +03:00
|
|
|
const PathSetting stateDir{(StoreConfig*) this,
|
|
|
|
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-05-19 17:56:59 +03:00
|
|
|
const PathSetting logDir{(StoreConfig*) this,
|
|
|
|
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-05-19 17:56:59 +03:00
|
|
|
const PathSetting realStoreDir{(StoreConfig*) this,
|
|
|
|
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:
|
|
|
|
|
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;
|
|
|
|
ref<FSAccessor> getFSAccessor() override;
|
|
|
|
|
2023-04-07 16:55:28 +03:00
|
|
|
/**
|
|
|
|
* Register a permanent GC root.
|
|
|
|
*/
|
2020-10-09 23:18:08 +03:00
|
|
|
Path addPermRoot(const StorePath & storePath, const Path & gcRoot);
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|