Skip to content

Commit 96bd9ba

Browse files
committed
fetchers/git: make path absolute for local repo
1 parent 2d9b213 commit 96bd9ba

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libfetchers/git.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,16 @@ struct GitInputScheme : InputScheme
426426
auto url = parseURL(getStrAttr(input.attrs, "url"));
427427
bool isBareRepository = url.scheme == "file" && !pathExists(url.path + "/.git");
428428
repoInfo.isLocal = url.scheme == "file" && !forceHttp && !isBareRepository;
429-
repoInfo.url = repoInfo.isLocal ? url.path : url.to_string();
429+
//
430+
// FIXME: here we turn a possibly relative path into an absolute path.
431+
// This allows relative git flake inputs to be resolved against the
432+
// **current working directory** (as in POSIX), which tends to work out
433+
// ok in the context of flakes, but is the wrong behavior,
434+
// as it should resolve against the flake.nix base directory instead.
435+
//
436+
// See: https://discourse.nixos.org/t/57783 and #9708
437+
//
438+
repoInfo.url = repoInfo.isLocal ? std::filesystem::absolute(url.path).string() : url.to_string();
430439

431440
// If this is a local directory and no ref or revision is
432441
// given, then allow the use of an unclean working tree.

0 commit comments

Comments
 (0)