mirror of
https://github.com/NixOS/nix
synced 2025-06-25 14:51:16 +02:00
Move uriSchemes
to *StoreConfig
It is a property of the configuration of a store --- how a store URL is parsed into a store config, not a store itself. Progress towards #10766
This commit is contained in:
parent
57399bfc0e
commit
2aa9cf34dd
14 changed files with 50 additions and 39 deletions
|
@ -21,6 +21,10 @@ struct DummyStoreConfig : virtual StoreConfig {
|
||||||
#include "dummy-store.md"
|
#include "dummy-store.md"
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::set<std::string> uriSchemes() {
|
||||||
|
return {"dummy"};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DummyStore : public virtual DummyStoreConfig, public virtual Store
|
struct DummyStore : public virtual DummyStoreConfig, public virtual Store
|
||||||
|
@ -54,10 +58,6 @@ struct DummyStore : public virtual DummyStoreConfig, public virtual Store
|
||||||
return Trusted;
|
return Trusted;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::set<std::string> uriSchemes() {
|
|
||||||
return {"dummy"};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override
|
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override
|
||||||
{ unsupported("queryPathFromHashPart"); }
|
{ unsupported("queryPathFromHashPart"); }
|
||||||
|
|
||||||
|
|
|
@ -83,14 +83,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::set<std::string> uriSchemes()
|
|
||||||
{
|
|
||||||
static bool forceHttp = getEnv("_NIX_FORCE_HTTP") == "1";
|
|
||||||
auto ret = std::set<std::string>({"http", "https"});
|
|
||||||
if (forceHttp) ret.insert("file");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void maybeDisable()
|
void maybeDisable()
|
||||||
|
|
|
@ -15,6 +15,15 @@ struct HttpBinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
|
||||||
return "HTTP Binary Cache Store";
|
return "HTTP Binary Cache Store";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::set<std::string> uriSchemes()
|
||||||
|
{
|
||||||
|
static bool forceHttp = getEnv("_NIX_FORCE_HTTP") == "1";
|
||||||
|
auto ret = std::set<std::string>({"http", "https"});
|
||||||
|
if (forceHttp)
|
||||||
|
ret.insert("file");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
std::string doc() override;
|
std::string doc() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ struct LegacySSHStoreConfig : virtual CommonSSHStoreConfig
|
||||||
|
|
||||||
const std::string name() override { return "SSH Store"; }
|
const std::string name() override { return "SSH Store"; }
|
||||||
|
|
||||||
|
static std::set<std::string> uriSchemes() { return {"ssh"}; }
|
||||||
|
|
||||||
std::string doc() override;
|
std::string doc() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,8 +48,6 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
|
||||||
|
|
||||||
SSHMaster master;
|
SSHMaster master;
|
||||||
|
|
||||||
static std::set<std::string> uriSchemes() { return {"ssh"}; }
|
|
||||||
|
|
||||||
LegacySSHStore(
|
LegacySSHStore(
|
||||||
std::string_view scheme,
|
std::string_view scheme,
|
||||||
std::string_view host,
|
std::string_view host,
|
||||||
|
|
|
@ -51,8 +51,6 @@ struct LocalBinaryCacheStore : virtual LocalBinaryCacheStoreConfig, virtual Bina
|
||||||
return "file://" + binaryCacheDir;
|
return "file://" + binaryCacheDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::set<std::string> uriSchemes();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool fileExists(const std::string & path) override;
|
bool fileExists(const std::string & path) override;
|
||||||
|
@ -121,7 +119,7 @@ bool LocalBinaryCacheStore::fileExists(const std::string & path)
|
||||||
return pathExists(binaryCacheDir + "/" + path);
|
return pathExists(binaryCacheDir + "/" + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string> LocalBinaryCacheStore::uriSchemes()
|
std::set<std::string> LocalBinaryCacheStoreConfig::uriSchemes()
|
||||||
{
|
{
|
||||||
if (getEnv("_NIX_FORCE_HTTP") == "1")
|
if (getEnv("_NIX_FORCE_HTTP") == "1")
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -15,6 +15,8 @@ struct LocalBinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
|
||||||
return "Local Binary Cache Store";
|
return "Local Binary Cache Store";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::set<std::string> uriSchemes();
|
||||||
|
|
||||||
std::string doc() override;
|
std::string doc() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,11 @@ struct LocalOverlayStoreConfig : virtual LocalStoreConfig
|
||||||
return ExperimentalFeature::LocalOverlayStore;
|
return ExperimentalFeature::LocalOverlayStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::set<std::string> uriSchemes()
|
||||||
|
{
|
||||||
|
return { "local-overlay" };
|
||||||
|
}
|
||||||
|
|
||||||
std::string doc() override;
|
std::string doc() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -102,11 +107,6 @@ public:
|
||||||
|
|
||||||
LocalOverlayStore(std::string_view scheme, PathView path, const Params & params);
|
LocalOverlayStore(std::string_view scheme, PathView path, const Params & params);
|
||||||
|
|
||||||
static std::set<std::string> uriSchemes()
|
|
||||||
{
|
|
||||||
return { "local-overlay" };
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getUri() override
|
std::string getUri() override
|
||||||
{
|
{
|
||||||
return "local-overlay://";
|
return "local-overlay://";
|
||||||
|
|
|
@ -67,6 +67,9 @@ struct LocalStoreConfig : virtual LocalFSStoreConfig
|
||||||
|
|
||||||
const std::string name() override { return "Local Store"; }
|
const std::string name() override { return "Local Store"; }
|
||||||
|
|
||||||
|
static std::set<std::string> uriSchemes()
|
||||||
|
{ return {"local"}; }
|
||||||
|
|
||||||
std::string doc() override;
|
std::string doc() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -149,9 +152,6 @@ public:
|
||||||
|
|
||||||
~LocalStore();
|
~LocalStore();
|
||||||
|
|
||||||
static std::set<std::string> uriSchemes()
|
|
||||||
{ return {"local"}; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementations of abstract store API methods.
|
* Implementations of abstract store API methods.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -475,9 +475,6 @@ struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStoreConfig, public virtual
|
||||||
{
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::set<std::string> uriSchemes() { return {"s3"}; }
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static RegisterStoreImplementation<S3BinaryCacheStoreImpl, S3BinaryCacheStoreConfig> regS3BinaryCacheStore;
|
static RegisterStoreImplementation<S3BinaryCacheStoreImpl, S3BinaryCacheStoreConfig> regS3BinaryCacheStore;
|
||||||
|
|
|
@ -94,6 +94,11 @@ public:
|
||||||
return "S3 Binary Cache Store";
|
return "S3 Binary Cache Store";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::set<std::string> uriSchemes()
|
||||||
|
{
|
||||||
|
return {"s3"};
|
||||||
|
}
|
||||||
|
|
||||||
std::string doc() override;
|
std::string doc() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::set<std::string> uriSchemes() { return {"ssh-ng"}; }
|
|
||||||
|
|
||||||
std::string getUri() override
|
std::string getUri() override
|
||||||
{
|
{
|
||||||
return *uriSchemes().begin() + "://" + host;
|
return *uriSchemes().begin() + "://" + host;
|
||||||
|
@ -154,11 +152,6 @@ public:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::set<std::string> uriSchemes()
|
|
||||||
{
|
|
||||||
return {"mounted-ssh-ng"};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getUri() override
|
std::string getUri() override
|
||||||
{
|
{
|
||||||
return *uriSchemes().begin() + "://" + host;
|
return *uriSchemes().begin() + "://" + host;
|
||||||
|
|
|
@ -23,6 +23,11 @@ struct SSHStoreConfig : virtual RemoteStoreConfig, virtual CommonSSHStoreConfig
|
||||||
return "Experimental SSH Store";
|
return "Experimental SSH Store";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::set<std::string> uriSchemes()
|
||||||
|
{
|
||||||
|
return {"ssh-ng"};
|
||||||
|
}
|
||||||
|
|
||||||
std::string doc() override;
|
std::string doc() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,6 +45,11 @@ struct MountedSSHStoreConfig : virtual SSHStoreConfig, virtual LocalFSStoreConfi
|
||||||
return "Experimental SSH Store with filesystem mounted";
|
return "Experimental SSH Store with filesystem mounted";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::set<std::string> uriSchemes()
|
||||||
|
{
|
||||||
|
return {"mounted-ssh-ng"};
|
||||||
|
}
|
||||||
|
|
||||||
std::string doc() override;
|
std::string doc() override;
|
||||||
|
|
||||||
std::optional<ExperimentalFeature> experimentalFeature() const override
|
std::optional<ExperimentalFeature> experimentalFeature() const override
|
||||||
|
|
|
@ -216,6 +216,10 @@ public:
|
||||||
|
|
||||||
virtual ~Store() { }
|
virtual ~Store() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo move to `StoreConfig` one we store enough information in
|
||||||
|
* those to recover the scheme and authority in all cases.
|
||||||
|
*/
|
||||||
virtual std::string getUri() = 0;
|
virtual std::string getUri() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -897,7 +901,7 @@ struct Implementations
|
||||||
{
|
{
|
||||||
if (!registered) registered = new std::vector<StoreFactory>();
|
if (!registered) registered = new std::vector<StoreFactory>();
|
||||||
StoreFactory factory{
|
StoreFactory factory{
|
||||||
.uriSchemes = T::uriSchemes(),
|
.uriSchemes = TConfig::uriSchemes(),
|
||||||
.create =
|
.create =
|
||||||
([](auto scheme, auto uri, auto & params)
|
([](auto scheme, auto uri, auto & params)
|
||||||
-> std::shared_ptr<Store>
|
-> std::shared_ptr<Store>
|
||||||
|
|
|
@ -36,6 +36,10 @@ struct UDSRemoteStoreConfig : virtual LocalFSStoreConfig, virtual RemoteStoreCon
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static constexpr char const * scheme = "unix";
|
static constexpr char const * scheme = "unix";
|
||||||
|
|
||||||
|
public:
|
||||||
|
static std::set<std::string> uriSchemes()
|
||||||
|
{ return {scheme}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class UDSRemoteStore : public virtual UDSRemoteStoreConfig
|
class UDSRemoteStore : public virtual UDSRemoteStoreConfig
|
||||||
|
@ -59,9 +63,6 @@ public:
|
||||||
|
|
||||||
std::string getUri() override;
|
std::string getUri() override;
|
||||||
|
|
||||||
static std::set<std::string> uriSchemes()
|
|
||||||
{ return {scheme}; }
|
|
||||||
|
|
||||||
ref<SourceAccessor> getFSAccessor(bool requireValidPath = true) override
|
ref<SourceAccessor> getFSAccessor(bool requireValidPath = true) override
|
||||||
{ return LocalFSStore::getFSAccessor(requireValidPath); }
|
{ return LocalFSStore::getFSAccessor(requireValidPath); }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue