mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 01:26:15 +02:00
Respect the narHash attribute in more input types
(cherry picked from commit a6ff66b658
)
This commit is contained in:
parent
670feb000a
commit
f58a9b0e62
5 changed files with 8 additions and 8 deletions
|
@ -29,8 +29,10 @@ std::unique_ptr<Input> inputFromURL(const std::string & url)
|
||||||
|
|
||||||
std::unique_ptr<Input> inputFromAttrs(const Attrs & attrs)
|
std::unique_ptr<Input> inputFromAttrs(const Attrs & attrs)
|
||||||
{
|
{
|
||||||
|
auto attrs2(attrs);
|
||||||
|
attrs2.erase("narHash");
|
||||||
for (auto & inputScheme : *inputSchemes) {
|
for (auto & inputScheme : *inputSchemes) {
|
||||||
auto res = inputScheme->inputFromAttrs(attrs);
|
auto res = inputScheme->inputFromAttrs(attrs2);
|
||||||
if (res) {
|
if (res) {
|
||||||
if (auto narHash = maybeGetStrAttr(attrs, "narHash"))
|
if (auto narHash = maybeGetStrAttr(attrs, "narHash"))
|
||||||
// FIXME: require SRI hash.
|
// FIXME: require SRI hash.
|
||||||
|
|
|
@ -39,7 +39,7 @@ struct GitInput : Input
|
||||||
|
|
||||||
bool isImmutable() const override
|
bool isImmutable() const override
|
||||||
{
|
{
|
||||||
return (bool) rev;
|
return (bool) rev || narHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> getRef() const override { return ref; }
|
std::optional<std::string> getRef() const override { return ref; }
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct GitHubInput : Input
|
||||||
|
|
||||||
bool isImmutable() const override
|
bool isImmutable() const override
|
||||||
{
|
{
|
||||||
return (bool) rev;
|
return (bool) rev || narHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> getRef() const override { return ref; }
|
std::optional<std::string> getRef() const override { return ref; }
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct MercurialInput : Input
|
||||||
|
|
||||||
bool isImmutable() const override
|
bool isImmutable() const override
|
||||||
{
|
{
|
||||||
return (bool) rev;
|
return (bool) rev || narHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> getRef() const override { return ref; }
|
std::optional<std::string> getRef() const override { return ref; }
|
||||||
|
|
|
@ -205,9 +205,7 @@ struct TarballInput : Input
|
||||||
{
|
{
|
||||||
Attrs attrs;
|
Attrs attrs;
|
||||||
attrs.emplace("url", url.to_string());
|
attrs.emplace("url", url.to_string());
|
||||||
if (narHash)
|
if (hash)
|
||||||
attrs.emplace("narHash", narHash->to_string(SRI));
|
|
||||||
else if (hash)
|
|
||||||
attrs.emplace("hash", hash->to_string(SRI));
|
attrs.emplace("hash", hash->to_string(SRI));
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +258,7 @@ struct TarballInputScheme : InputScheme
|
||||||
if (maybeGetStrAttr(attrs, "type") != "tarball") return {};
|
if (maybeGetStrAttr(attrs, "type") != "tarball") return {};
|
||||||
|
|
||||||
for (auto & [name, value] : attrs)
|
for (auto & [name, value] : attrs)
|
||||||
if (name != "type" && name != "url" && name != "hash" && name != "narHash")
|
if (name != "type" && name != "url" && name != "hash")
|
||||||
throw Error("unsupported tarball input attribute '%s'", name);
|
throw Error("unsupported tarball input attribute '%s'", name);
|
||||||
|
|
||||||
auto input = std::make_unique<TarballInput>(parseURL(getStrAttr(attrs, "url")));
|
auto input = std::make_unique<TarballInput>(parseURL(getStrAttr(attrs, "url")));
|
||||||
|
|
Loading…
Reference in a new issue