aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/populate/src
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/populate/src')
-rw-r--r--pkgs/populate/src/flake.rs6
-rw-r--r--pkgs/populate/src/sh.rs11
2 files changed, 12 insertions, 5 deletions
diff --git a/pkgs/populate/src/flake.rs b/pkgs/populate/src/flake.rs
index 26373d4..ded7692 100644
--- a/pkgs/populate/src/flake.rs
+++ b/pkgs/populate/src/flake.rs
@@ -228,8 +228,9 @@ impl<'a> Flakes<'a> {
String::new()
};
format!(
- "{}{}{require}{snippet}",
+ "{}{}{}{require}{snippet}",
sh::prelude(),
+ sh::GIT_PROBLEMS,
sh::draw::DEFINITIONS
)
}
@@ -270,7 +271,8 @@ impl<'a> Flakes<'a> {
.collect())
}
- /// The flake URL of the source named name, at resolved.
+ /// The flake URL of the source named name, at resolved: git+file: if
+ /// it has a .git directory populate can use, else path:.
fn flake_url(name: &str, resolved: &Resolved) -> Result<String> {
if !resolved.dir {
return Err(Failure::Message(format!(
diff --git a/pkgs/populate/src/sh.rs b/pkgs/populate/src/sh.rs
index f76a0f7..15da78c 100644
--- a/pkgs/populate/src/sh.rs
+++ b/pkgs/populate/src/sh.rs
@@ -812,14 +812,19 @@ use_state "$@"
/// resolve PATH...: prints, for each PATH, what's there and where it
/// resolves to, as two fields, each ending in a null byte. The first
- /// holds d if PATH is a directory, g if it has .git, s if it has
- /// .gitmodules, and f if it has flake.nix.
+ /// holds d if PATH is a directory, g if it has a .git directory that
+ /// git_problems finds nothing wrong with, s if it has .gitmodules, and
+ /// f if it has flake.nix. Nix runs Git in a git+file: flake, with the
+ /// repository's configuration and hooks, so it only gets such ones.
pub const RESOLVE: &str = r#"
for path; do
resolved=$(readlink -f "$path") || resolved=
flags=
if test -d "$path"; then flags=${flags}d; fi
- if test -e "$path"/.git; then flags=${flags}g; fi
+ if ! test -L "$path"/.git && test -d "$path"/.git; then
+ problems=$(git_problems "$path" 2>/dev/null) || problems=failed
+ if test -z "$problems"; then flags=${flags}g; fi
+ fi
if test -e "$path"/.gitmodules; then flags=${flags}s; fi
if test -e "$path"/flake.nix; then flags=${flags}f; fi
printf '%s\0%s\0' "$flags" "$resolved"