Respect the narHash attribute in more input types
call-flake.nix now passes node.info.narHash to fetchTree. This ensures that dirty Git trees work even in pure mode.
This commit is contained in:
parent
78ad5b3d91
commit
a6ff66b658
6 changed files with 12 additions and 9 deletions
|
@ -8,7 +8,10 @@ let
|
|||
builtins.mapAttrs
|
||||
(key: node:
|
||||
let
|
||||
sourceInfo = if key == lockFile.root then rootSrc else fetchTree (removeAttrs node.locked ["dir"]);
|
||||
sourceInfo =
|
||||
if key == lockFile.root
|
||||
then rootSrc
|
||||
else fetchTree ({ inherit (node.info) narHash; } // removeAttrs node.locked ["dir"]);
|
||||
subdir = if key == lockFile.root then rootSubdir else node.locked.dir or "";
|
||||
flake = import (sourceInfo + (if subdir != "" then "/" else "") + subdir + "/flake.nix");
|
||||
inputs = builtins.mapAttrs (inputName: key: allNodes.${key}) (node.inputs or {});
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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")));
|
||||
|
|
Loading…
Reference in a new issue