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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user