Init local overlay store

This commit is contained in:
John Ericson 2023-05-08 10:20:06 -04:00
parent d62f6da81f
commit f0a176e2f1
3 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,20 @@
#include "local-overlay-store.hh"
namespace nix {
LocalOverlayStore::LocalOverlayStore(const Params & params)
: StoreConfig(params)
, LocalFSStoreConfig(params)
, LocalStoreConfig(params)
, LocalOverlayStoreConfig(params)
, Store(params)
, LocalFSStore(params)
, LocalStore(params)
, lowerStore(openStore(lowerStoreUri).dynamic_pointer_cast<LocalFSStore>())
{
}
static RegisterStoreImplementation<LocalOverlayStore, LocalOverlayStoreConfig> regLocalOverlayStore;
}

View file

@ -0,0 +1,74 @@
#include "local-store.hh"
namespace nix {
/**
* Configuration for `LocalOverlayStore`.
*/
struct LocalOverlayStoreConfig : virtual LocalStoreConfig
{
// FIXME why doesn't this work?
// using LocalStoreConfig::LocalStoreConfig;
LocalOverlayStoreConfig(const StringMap & params)
: StoreConfig(params)
, LocalFSStoreConfig(params)
, LocalStoreConfig(params)
{ }
const Setting<std::string> lowerStoreUri{(StoreConfig*) this, "", "lower-store",
R"(
[Store URL](@docroot@/command-ref/new-cli/nix3-help-stores.md#store-url-format)
for the lower store. The default is `auto` (i.e. use the Nix daemon or `/nix/store` directly).
Must be a store with a store dir on the file system.
)"};
const std::string name() override { return "Experimental Local Overlay Store"; }
std::string doc() override
{
return
""
// FIXME write docs
//#include "local-overlay-store.md"
;
}
};
/**
* Variation of local store using overlayfs for the store dir.
*/
class LocalOverlayStore : public virtual LocalOverlayStoreConfig, public virtual LocalStore
{
/**
* The store beneath us.
*
* Our store dir should be an overlay fs where the lower layer
* is that store's store dir, and the upper layer is some
* scratch storage just for us.
*/
ref<LocalFSStore> lowerStore;
public:
LocalOverlayStore(const Params & params);
LocalOverlayStore(std::string scheme, std::string path, const Params & params)
: LocalOverlayStore(params)
{
throw UnimplementedError("LocalOverlayStore");
}
static std::set<std::string> uriSchemes()
{ return {}; }
std::string getUri() override
{
return "local-overlay";
}
private:
// Overridden methods…
};
}

View file

@ -10,6 +10,7 @@
#include "archive.hh"
#include "callback.hh"
#include "remote-store.hh"
#include "local-overlay-store.hh"
#include <nlohmann/json.hpp>
#include <regex>
@ -1391,6 +1392,8 @@ std::shared_ptr<Store> openFromNonUri(const std::string & uri, const Store::Para
return std::make_shared<UDSRemoteStore>(params);
} else if (uri == "local") {
return std::make_shared<LocalStore>(params);
} else if (uri == "local-overlay") {
return std::make_shared<LocalOverlayStore>(params);
} else if (isNonUriPath(uri)) {
Store::Params params2 = params;
params2["root"] = absPath(uri);