1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 23:03:53 -04:00

GitArchiveInputScheme: Support the narHash attribute

This is required to produce a locked flakeref.
This commit is contained in:
Eelco Dolstra 2024-03-10 13:56:53 +01:00
parent c1811c1eba
commit 841fd78baa

View file

@ -98,6 +98,10 @@ struct GitArchiveInputScheme : InputScheme
if (ref) input.attrs.insert_or_assign("ref", *ref); if (ref) input.attrs.insert_or_assign("ref", *ref);
if (host_url) input.attrs.insert_or_assign("host", *host_url); if (host_url) input.attrs.insert_or_assign("host", *host_url);
auto narHash = url.query.find("narHash");
if (narHash != url.query.end())
input.attrs.insert_or_assign("narHash", narHash->second);
return input; return input;
} }
@ -135,10 +139,13 @@ struct GitArchiveInputScheme : InputScheme
assert(!(ref && rev)); assert(!(ref && rev));
if (ref) path += "/" + *ref; if (ref) path += "/" + *ref;
if (rev) path += "/" + rev->to_string(HashFormat::Base16, false); if (rev) path += "/" + rev->to_string(HashFormat::Base16, false);
return ParsedURL { auto url = ParsedURL {
.scheme = std::string { schemeName() }, .scheme = std::string { schemeName() },
.path = path, .path = path,
}; };
if (auto narHash = input.getNarHash())
url.query.insert_or_assign("narHash", narHash->to_string(HashFormat::SRI, true));
return url;
} }
Input applyOverrides( Input applyOverrides(