Skip to content

Commit 8710aa0

Browse files
committed
nixos-option: use git rev-parse --show-toplevel to check for Git repo
1 parent f2d7d55 commit 8710aa0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pkgs/by-name/ni/nixos-option/nixos-option.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ if [[ -n "$flake" ]]; then
7474
fi
7575
# Unlike nix cli, builtins.getFlake infer path:// when a path is given
7676
# See https://github.com/NixOS/nix/issues/5836
77-
if [[ -d "$flake" ]] && [[ -e "$flake/.git" ]] ; then
77+
# Using `git rev-parse --show-toplevel` since we can't assume the flake dir
78+
# itself is a git repo, because the flake could be in a sub directory
79+
if [[ -d "$flake" ]] && git -C "$flake" rev-parse --show-toplevel &>/dev/null; then
7880
flake="git+file://$(realpath "$flake")"
7981
fi
8082
if [[ -z "${flakeAttr:-}" ]]; then

pkgs/by-name/ni/nixos-option/package.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
lib,
33
coreutils,
4+
git,
45
installShellFiles,
56
jq,
67
makeWrapper,
@@ -56,6 +57,7 @@ stdenvNoCC.mkDerivation {
5657
--prefix PATH : ${
5758
lib.makeBinPath [
5859
coreutils
60+
git
5961
jq
6062
man-db
6163
nix

0 commit comments

Comments
 (0)