mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 09:36:15 +02:00
Automatically determine subdir for path flakes
This means that in a flake in a subdirectory of a Git repo, you can now do $ nix build rather than the inconvenient $ nix build ../..?dir=foo/bar
This commit is contained in:
parent
ccb1bad612
commit
8abb8647a3
1 changed files with 11 additions and 1 deletions
|
@ -140,7 +140,17 @@ FlakeRef::FlakeRef(const std::string & uri_, bool allowRelative)
|
||||||
&& uri.find(':') == std::string::npos)
|
&& uri.find(':') == std::string::npos)
|
||||||
{
|
{
|
||||||
IsPath d;
|
IsPath d;
|
||||||
d.path = allowRelative ? absPath(uri) : canonPath(uri);
|
if (allowRelative) {
|
||||||
|
d.path = absPath(uri);
|
||||||
|
while (true) {
|
||||||
|
if (pathExists(d.path + "/.git")) break;
|
||||||
|
subdir = baseNameOf(d.path) + (subdir.empty() ? "" : "/" + subdir);
|
||||||
|
d.path = dirOf(d.path);
|
||||||
|
if (d.path == "/")
|
||||||
|
throw BadFlakeRef("path '%s' does not reference a Git repository", uri);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
d.path = canonPath(uri);
|
||||||
data = d;
|
data = d;
|
||||||
for (auto & param : params) {
|
for (auto & param : params) {
|
||||||
if (handleGitParams(param.first, param.second))
|
if (handleGitParams(param.first, param.second))
|
||||||
|
|
Loading…
Reference in a new issue