2020-08-24 19:54:16 +03:00
|
|
|
#include "store-api.hh"
|
2020-09-21 19:40:11 +03:00
|
|
|
#include "callback.hh"
|
2020-08-24 19:54:16 +03:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2020-09-14 12:18:45 +03:00
|
|
|
struct DummyStoreConfig : virtual StoreConfig {
|
2020-09-11 12:06:18 +03:00
|
|
|
using StoreConfig::StoreConfig;
|
2020-09-14 15:04:02 +03:00
|
|
|
|
|
|
|
const std::string name() override { return "Dummy Store"; }
|
2023-03-21 15:03:05 +02:00
|
|
|
|
|
|
|
std::string doc() override
|
|
|
|
{
|
|
|
|
return
|
|
|
|
#include "dummy-store.md"
|
|
|
|
;
|
|
|
|
}
|
2020-09-11 12:06:18 +03:00
|
|
|
};
|
2020-09-10 11:55:51 +03:00
|
|
|
|
2020-12-20 17:33:12 +02:00
|
|
|
struct DummyStore : public virtual DummyStoreConfig, public virtual Store
|
2020-08-24 19:54:16 +03:00
|
|
|
{
|
2024-01-25 17:31:52 +02:00
|
|
|
DummyStore(std::string_view scheme, std::string_view authority, const Params & params)
|
2020-09-09 12:29:17 +03:00
|
|
|
: DummyStore(params)
|
2024-01-25 17:31:52 +02:00
|
|
|
{
|
|
|
|
if (!authority.empty())
|
|
|
|
throw UsageError("`%s` store URIs must not contain an authority part %s", scheme, authority);
|
|
|
|
}
|
2020-09-09 12:29:17 +03:00
|
|
|
|
|
|
|
DummyStore(const Params & params)
|
2020-09-11 12:06:18 +03:00
|
|
|
: StoreConfig(params)
|
2020-12-20 17:33:12 +02:00
|
|
|
, DummyStoreConfig(params)
|
2020-09-11 12:06:18 +03:00
|
|
|
, Store(params)
|
2020-10-06 15:00:42 +03:00
|
|
|
{ }
|
2020-08-24 19:54:16 +03:00
|
|
|
|
2022-02-25 17:00:00 +02:00
|
|
|
std::string getUri() override
|
2020-08-24 19:54:16 +03:00
|
|
|
{
|
2020-09-11 12:11:05 +03:00
|
|
|
return *uriSchemes().begin();
|
2020-08-24 19:54:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void queryPathInfoUncached(const StorePath & path,
|
|
|
|
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept override
|
|
|
|
{
|
|
|
|
callback(nullptr);
|
|
|
|
}
|
|
|
|
|
2022-12-26 22:21:08 +02:00
|
|
|
/**
|
|
|
|
* The dummy store is incapable of *not* trusting! :)
|
|
|
|
*/
|
|
|
|
virtual std::optional<TrustedFlag> isTrustedClient() override
|
|
|
|
{
|
|
|
|
return Trusted;
|
|
|
|
}
|
|
|
|
|
2020-09-11 12:11:05 +03:00
|
|
|
static std::set<std::string> uriSchemes() {
|
2020-09-08 15:50:23 +03:00
|
|
|
return {"dummy"};
|
|
|
|
}
|
|
|
|
|
2020-08-24 19:54:16 +03:00
|
|
|
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override
|
|
|
|
{ unsupported("queryPathFromHashPart"); }
|
|
|
|
|
|
|
|
void addToStore(const ValidPathInfo & info, Source & source,
|
|
|
|
RepairFlag repair, CheckSigsFlag checkSigs) override
|
|
|
|
{ unsupported("addToStore"); }
|
|
|
|
|
2024-01-18 06:46:03 +02:00
|
|
|
virtual StorePath addToStoreFromDump(
|
|
|
|
Source & dump,
|
|
|
|
std::string_view name,
|
2024-01-19 06:57:26 +02:00
|
|
|
FileSerialisationMethod dumpMethod = FileSerialisationMethod::Recursive,
|
|
|
|
ContentAddressMethod hashMethod = FileIngestionMethod::Recursive,
|
2024-01-18 06:46:03 +02:00
|
|
|
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
|
|
|
const StorePathSet & references = StorePathSet(),
|
|
|
|
RepairFlag repair = NoRepair) override
|
|
|
|
{ unsupported("addToStore"); }
|
|
|
|
|
2020-08-24 19:54:16 +03:00
|
|
|
void narFromPath(const StorePath & path, Sink & sink) override
|
|
|
|
{ unsupported("narFromPath"); }
|
|
|
|
|
2021-10-27 12:36:51 +03:00
|
|
|
void queryRealisationUncached(const DrvOutput &,
|
|
|
|
Callback<std::shared_ptr<const Realisation>> callback) noexcept override
|
|
|
|
{ callback(nullptr); }
|
2023-04-13 20:38:12 +03:00
|
|
|
|
2023-11-01 18:09:28 +02:00
|
|
|
virtual ref<SourceAccessor> getFSAccessor(bool requireValidPath) override
|
2023-04-13 20:38:12 +03:00
|
|
|
{ unsupported("getFSAccessor"); }
|
2020-08-24 19:54:16 +03:00
|
|
|
};
|
|
|
|
|
2020-10-06 14:36:55 +03:00
|
|
|
static RegisterStoreImplementation<DummyStore, DummyStoreConfig> regDummyStore;
|
2020-08-24 19:54:16 +03:00
|
|
|
|
|
|
|
}
|