From 6a67e57019f39e43866866661df17394c168d29b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 24 Aug 2020 18:54:16 +0200 Subject: Add DummyStore (dummy://) DummyStore does not allow building or adding paths. This is useful for evaluation tests when you don't want to initialize a "proper" store. --- src/libstore/dummy-store.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/libstore/dummy-store.cc (limited to 'src/libstore/dummy-store.cc') diff --git a/src/libstore/dummy-store.cc b/src/libstore/dummy-store.cc new file mode 100644 index 000000000..7a5744bc1 --- /dev/null +++ b/src/libstore/dummy-store.cc @@ -0,0 +1,59 @@ +#include "store-api.hh" + +namespace nix { + +static std::string uriScheme = "dummy://"; + +struct DummyStore : public Store +{ + DummyStore(const Params & params) + : Store(params) + { } + + string getUri() override + { + return uriScheme; + } + + void queryPathInfoUncached(const StorePath & path, + Callback> callback) noexcept override + { + callback(nullptr); + } + + std::optional queryPathFromHashPart(const std::string & hashPart) override + { unsupported("queryPathFromHashPart"); } + + void addToStore(const ValidPathInfo & info, Source & source, + RepairFlag repair, CheckSigsFlag checkSigs) override + { unsupported("addToStore"); } + + StorePath addToStore(const string & name, const Path & srcPath, + FileIngestionMethod method, HashType hashAlgo, + PathFilter & filter, RepairFlag repair) override + { unsupported("addToStore"); } + + StorePath addTextToStore(const string & name, const string & s, + const StorePathSet & references, RepairFlag repair) override + { unsupported("addTextToStore"); } + + void narFromPath(const StorePath & path, Sink & sink) override + { unsupported("narFromPath"); } + + void ensurePath(const StorePath & path) override + { unsupported("ensurePath"); } + + BuildResult buildDerivation(const StorePath & drvPath, const BasicDerivation & drv, + BuildMode buildMode) override + { unsupported("buildDerivation"); } +}; + +static RegisterStoreImplementation regStore([]( + const std::string & uri, const Store::Params & params) + -> std::shared_ptr +{ + if (uri != uriScheme) return nullptr; + return std::make_shared(params); +}); + +} -- cgit v1.2.3