mirror of
https://github.com/NixOS/nix
synced 2025-06-27 12:41:15 +02:00
Allow relative paths in flakerefs
Also allow "." as an installable to refer to the flake in the current directory. E.g. $ nix build . will build 'provides.defaultPackage' in the flake in the current directory.
This commit is contained in:
parent
507da65900
commit
c996e04aca
4 changed files with 15 additions and 8 deletions
|
@ -32,7 +32,7 @@ const static std::string segmentRegex = "[a-zA-Z0-9._~-]+";
|
|||
const static std::string pathRegex = "/?" + segmentRegex + "(?:/" + segmentRegex + ")*";
|
||||
const static std::string paramRegex = "[a-z]+=[a-zA-Z0-9._-]*";
|
||||
|
||||
FlakeRef::FlakeRef(const std::string & uri)
|
||||
FlakeRef::FlakeRef(const std::string & uri, bool allowRelative)
|
||||
{
|
||||
// FIXME: could combine this into one regex.
|
||||
|
||||
|
@ -106,9 +106,9 @@ FlakeRef::FlakeRef(const std::string & uri)
|
|||
data = d;
|
||||
}
|
||||
|
||||
else if (hasPrefix(uri, "/")) {
|
||||
else if (hasPrefix(uri, "/") || (allowRelative && (hasPrefix(uri, "./") || uri == "."))) {
|
||||
IsPath d;
|
||||
d.path = canonPath(uri);
|
||||
d.path = allowRelative ? absPath(uri) : canonPath(uri);
|
||||
data = d;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue