aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libfetchers/fetchers.cc4
-rw-r--r--src/libfetchers/git.cc2
-rw-r--r--src/libfetchers/github.cc2
-rw-r--r--src/libfetchers/mercurial.cc2
-rw-r--r--src/libfetchers/tarball.cc6
5 files changed, 8 insertions, 8 deletions
diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc
index 25d3da431..94ac30e38 100644
--- a/src/libfetchers/fetchers.cc
+++ b/src/libfetchers/fetchers.cc
@@ -29,8 +29,10 @@ std::unique_ptr<Input> inputFromURL(const std::string & url)
std::unique_ptr<Input> inputFromAttrs(const Attrs & attrs)
{
+ auto attrs2(attrs);
+ attrs2.erase("narHash");
for (auto & inputScheme : *inputSchemes) {
- auto res = inputScheme->inputFromAttrs(attrs);
+ auto res = inputScheme->inputFromAttrs(attrs2);
if (res) {
if (auto narHash = maybeGetStrAttr(attrs, "narHash"))
// FIXME: require SRI hash.
diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc
index cee0713f4..3f94d9bdd 100644
--- a/src/libfetchers/git.cc
+++ b/src/libfetchers/git.cc
@@ -39,7 +39,7 @@ struct GitInput : Input
bool isImmutable() const override
{
- return (bool) rev;
+ return (bool) rev || narHash;
}
std::optional<std::string> getRef() const override { return ref; }
diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc
index 3fc95ff51..ef27eaa76 100644
--- a/src/libfetchers/github.cc
+++ b/src/libfetchers/github.cc
@@ -33,7 +33,7 @@ struct GitHubInput : Input
bool isImmutable() const override
{
- return (bool) rev;
+ return (bool) rev || narHash;
}
std::optional<std::string> getRef() const override { return ref; }
diff --git a/src/libfetchers/mercurial.cc b/src/libfetchers/mercurial.cc
index 790f7c753..1d6571571 100644
--- a/src/libfetchers/mercurial.cc
+++ b/src/libfetchers/mercurial.cc
@@ -33,7 +33,7 @@ struct MercurialInput : Input
bool isImmutable() const override
{
- return (bool) rev;
+ return (bool) rev || narHash;
}
std::optional<std::string> getRef() const override { return ref; }
diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc
index b0a83001e..4c4e5828e 100644
--- a/src/libfetchers/tarball.cc
+++ b/src/libfetchers/tarball.cc
@@ -205,9 +205,7 @@ struct TarballInput : Input
{
Attrs attrs;
attrs.emplace("url", url.to_string());
- if (narHash)
- attrs.emplace("narHash", narHash->to_string(SRI));
- else if (hash)
+ if (hash)
attrs.emplace("hash", hash->to_string(SRI));
return attrs;
}
@@ -260,7 +258,7 @@ struct TarballInputScheme : InputScheme
if (maybeGetStrAttr(attrs, "type") != "tarball") return {};
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);
auto input = std::make_unique<TarballInput>(parseURL(getStrAttr(attrs, "url")));