mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Change lock file format to use an attribute representation of flake refs rather than URLs
This commit is contained in:
parent
dbefe9e6b8
commit
8414685c0f
12 changed files with 293 additions and 39 deletions
|
@ -74,9 +74,9 @@ struct GitInput : Input
|
|||
std::optional<Hash> rev;
|
||||
|
||||
GitInput(const ParsedURL & url) : url(url)
|
||||
{
|
||||
type = "git";
|
||||
}
|
||||
{ }
|
||||
|
||||
std::string type() const override { return "git"; }
|
||||
|
||||
bool operator ==(const Input & other) const override
|
||||
{
|
||||
|
@ -105,6 +105,17 @@ struct GitInput : Input
|
|||
return url2.to_string();
|
||||
}
|
||||
|
||||
Attrs toAttrsInternal() const override
|
||||
{
|
||||
Attrs attrs;
|
||||
attrs.emplace("url", url.to_string());
|
||||
if (ref)
|
||||
attrs.emplace("ref", *ref);
|
||||
if (rev)
|
||||
attrs.emplace("rev", rev->gitRev());
|
||||
return attrs;
|
||||
}
|
||||
|
||||
void clone(const Path & destDir) const override
|
||||
{
|
||||
auto [isLocal, actualUrl] = getActualUrl();
|
||||
|
@ -379,6 +390,16 @@ struct GitInputScheme : InputScheme
|
|||
|
||||
return input;
|
||||
}
|
||||
|
||||
std::unique_ptr<Input> inputFromAttrs(const Input::Attrs & attrs) override
|
||||
{
|
||||
if (maybeGetStrAttr(attrs, "type") != "git") return {};
|
||||
auto input = std::make_unique<GitInput>(parseURL(getStrAttr(attrs, "url")));
|
||||
input->ref = maybeGetStrAttr(attrs, "ref");
|
||||
if (auto rev = maybeGetStrAttr(attrs, "rev"))
|
||||
input->rev = Hash(*rev, htSHA1);
|
||||
return input;
|
||||
}
|
||||
};
|
||||
|
||||
static auto r1 = OnStartup([] { registerInputScheme(std::make_unique<GitInputScheme>()); });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue