From 8dfa3f18d42d852ece3f2d9cf1ae117acccc0b15 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 21:09:17 +0000 Subject: populate: refer to flakes as git+file: only with a usable .git Writing the lock file of a git+file: flake, Nix runs Git, with the repository's configuration and hooks, which may run commands. A .git in a source's directory can come from anywhere, e.g. one planted in a materialized flake, or one a file source keeps. So drawing inputs refers to a flake as git+file: only if git_problems finds nothing wrong with its .git directory, the way git sources check their work trees, and else as path:. lock-foreign-git plants a .git in a materialized flake and in a file source that keeps it, whose configuration names an fsmonitor command. --- pkgs/populate/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pkgs') diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix index b724b23..7b22662 100644 --- a/pkgs/populate/default.nix +++ b/pkgs/populate/default.nix @@ -608,14 +608,20 @@ let fi } - # Prints the flake URL of the source named $1. + ${gitProblems} + # Prints the flake URL of the source named $1: git+file: if it has a + # .git directory git_problems finds nothing wrong with, else path:. + # Nix runs Git in a git+file: flake, with the repository's + # configuration and hooks. flake_url() { path=$(readlink -f ${quote target.path}/"$1") if ! test -d "$path"; then >&2 printf 'error: source %s is not a directory\n' "$1" exit 1 fi - if test -e "$path"/.git; then + if ! test -L "$path"/.git && test -d "$path"/.git && + problems=$(git_problems "$path" 2>/dev/null) && + test -z "$problems"; then if test -e "$path"/.gitmodules; then printf 'git+file:%s?submodules=1' "$(url_path "$path")" else -- cgit v1.3.1