mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 18:56:16 +02:00
470c0501eb
In particular `local://<path>` and `unix://` (without any path) now work, and mean the same things as `local` and `daemon`, respectively. We thus now have the opportunity to desguar `local` and `daemon` early. This will allow me to make a change to https://github.com/NixOS/nix/pull/9839 requested during review to desugar those earlier. Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
87 lines
2.5 KiB
C++
87 lines
2.5 KiB
C++
#include "store-api.hh"
|
|
#include "callback.hh"
|
|
|
|
namespace nix {
|
|
|
|
struct DummyStoreConfig : virtual StoreConfig {
|
|
using StoreConfig::StoreConfig;
|
|
|
|
const std::string name() override { return "Dummy Store"; }
|
|
|
|
std::string doc() override
|
|
{
|
|
return
|
|
#include "dummy-store.md"
|
|
;
|
|
}
|
|
};
|
|
|
|
struct DummyStore : public virtual DummyStoreConfig, public virtual Store
|
|
{
|
|
DummyStore(std::string_view scheme, std::string_view authority, const Params & params)
|
|
: DummyStore(params)
|
|
{
|
|
if (!authority.empty())
|
|
throw UsageError("`%s` store URIs must not contain an authority part %s", scheme, authority);
|
|
}
|
|
|
|
DummyStore(const Params & params)
|
|
: StoreConfig(params)
|
|
, DummyStoreConfig(params)
|
|
, Store(params)
|
|
{ }
|
|
|
|
std::string getUri() override
|
|
{
|
|
return *uriSchemes().begin();
|
|
}
|
|
|
|
void queryPathInfoUncached(const StorePath & path,
|
|
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept override
|
|
{
|
|
callback(nullptr);
|
|
}
|
|
|
|
/**
|
|
* The dummy store is incapable of *not* trusting! :)
|
|
*/
|
|
virtual std::optional<TrustedFlag> isTrustedClient() override
|
|
{
|
|
return Trusted;
|
|
}
|
|
|
|
static std::set<std::string> uriSchemes() {
|
|
return {"dummy"};
|
|
}
|
|
|
|
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"); }
|
|
|
|
virtual StorePath addToStoreFromDump(
|
|
Source & dump,
|
|
std::string_view name,
|
|
FileSerialisationMethod dumpMethod = FileSerialisationMethod::Recursive,
|
|
ContentAddressMethod hashMethod = FileIngestionMethod::Recursive,
|
|
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
|
const StorePathSet & references = StorePathSet(),
|
|
RepairFlag repair = NoRepair) override
|
|
{ unsupported("addToStore"); }
|
|
|
|
void narFromPath(const StorePath & path, Sink & sink) override
|
|
{ unsupported("narFromPath"); }
|
|
|
|
void queryRealisationUncached(const DrvOutput &,
|
|
Callback<std::shared_ptr<const Realisation>> callback) noexcept override
|
|
{ callback(nullptr); }
|
|
|
|
virtual ref<SourceAccessor> getFSAccessor(bool requireValidPath) override
|
|
{ unsupported("getFSAccessor"); }
|
|
};
|
|
|
|
static RegisterStoreImplementation<DummyStore, DummyStoreConfig> regDummyStore;
|
|
|
|
}
|