2020-10-09 20:18:08 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "store-api.hh"
|
2022-03-01 18:31:36 +00:00
|
|
|
#include "gc-store.hh"
|
2020-10-09 20:18:08 +00:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
struct LocalFSStoreConfig : virtual StoreConfig
|
|
|
|
{
|
|
|
|
using StoreConfig::StoreConfig;
|
|
|
|
// 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.
|
|
|
|
const PathSetting rootDir{(StoreConfig*) this, true, "",
|
|
|
|
"root", "directory prefixed to all other paths"};
|
|
|
|
const PathSetting stateDir{(StoreConfig*) this, false,
|
|
|
|
rootDir != "" ? rootDir + "/nix/var/nix" : settings.nixStateDir,
|
|
|
|
"state", "directory where Nix will store state"};
|
|
|
|
const PathSetting logDir{(StoreConfig*) this, false,
|
|
|
|
rootDir != "" ? rootDir + "/nix/var/log/nix" : settings.nixLogDir,
|
|
|
|
"log", "directory where Nix will store state"};
|
2021-06-18 15:04:11 +00:00
|
|
|
const PathSetting realStoreDir{(StoreConfig*) this, false,
|
|
|
|
rootDir != "" ? rootDir + "/nix/store" : storeDir, "real",
|
|
|
|
"physical path to the Nix store"};
|
2020-10-09 20:18:08 +00:00
|
|
|
};
|
|
|
|
|
2022-03-01 18:31:36 +00:00
|
|
|
class LocalFSStore : public virtual LocalFSStoreConfig, public virtual Store, virtual GcStore
|
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;
|
|
|
|
|
|
|
|
/* Register a permanent GC root. */
|
|
|
|
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-01-17 21:20:05 +00:00
|
|
|
std::optional<std::string> getBuildLog(const StorePath & path) override;
|
|
|
|
|
2020-10-09 20:18:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|