From 12e14956e22a42c26715ca084bb6b17d35628bb9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 16 Jan 2025 17:22:54 +0100 Subject: [PATCH 1/2] Warn against the use of relative 'git+file:' flake inputs --- src/libfetchers/git.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index c4dfc27a2..3f196da54 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -435,7 +435,16 @@ struct GitInputScheme : InputScheme // // See: https://discourse.nixos.org/t/57783 and #9708 // - repoInfo.url = repoInfo.isLocal ? std::filesystem::absolute(url.path).string() : url.to_string(); + if (repoInfo.isLocal) { + if (!isAbsolute(url.path)) { + warn( + "Fetching Git repository '%s', which uses a path relative to the current directory. " + "This is not supported and will stop working in a future release.", + url); + } + repoInfo.url = std::filesystem::absolute(url.path).string(); + } else + repoInfo.url = url.to_string(); // If this is a local directory and no ref or revision is // given, then allow the use of an unclean working tree. From 3197c19a31f5ce42b099d257b6ba22fb25e707c4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 17 Jan 2025 12:33:23 +0100 Subject: [PATCH 2/2] Add link to tracking issue --- src/libfetchers/git.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index 3f196da54..5a9679199 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -439,7 +439,8 @@ struct GitInputScheme : InputScheme if (!isAbsolute(url.path)) { warn( "Fetching Git repository '%s', which uses a path relative to the current directory. " - "This is not supported and will stop working in a future release.", + "This is not supported and will stop working in a future release. " + "See https://github.com/NixOS/nix/issues/12281 for details.", url); } repoInfo.url = std::filesystem::absolute(url.path).string();