mirror of
https://github.com/NixOS/nix
synced 2025-06-27 12:41:15 +02:00
Add path flakeref variant
Unlike file://<path>, this allows the path to be a dirty Git tree, so nix build /path/to/flake:attr is a convenient way to test building a local flake.
This commit is contained in:
parent
a9ceeeb4b0
commit
6a4c7fb975
6 changed files with 49 additions and 5 deletions
|
@ -106,6 +106,12 @@ FlakeRef::FlakeRef(const std::string & uri)
|
|||
data = d;
|
||||
}
|
||||
|
||||
else if (hasPrefix(uri, "/")) {
|
||||
IsPath d;
|
||||
d.path = canonPath(uri);
|
||||
data = d;
|
||||
}
|
||||
|
||||
else
|
||||
throw Error("'%s' is not a valid flake reference", uri);
|
||||
}
|
||||
|
@ -135,6 +141,10 @@ std::string FlakeRef::to_string() const
|
|||
(refData->rev ? "&rev=" + refData->rev->to_string(Base16, false) : "");
|
||||
}
|
||||
|
||||
else if (auto refData = std::get_if<FlakeRef::IsPath>(&data)) {
|
||||
return refData->path;
|
||||
}
|
||||
|
||||
else abort();
|
||||
}
|
||||
|
||||
|
@ -149,6 +159,9 @@ bool FlakeRef::isImmutable() const
|
|||
else if (auto refData = std::get_if<FlakeRef::IsGit>(&data))
|
||||
return (bool) refData->rev;
|
||||
|
||||
else if (std::get_if<FlakeRef::IsPath>(&data))
|
||||
return false;
|
||||
|
||||
else abort();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue