Skip to content

Commit 2ebdf36

Browse files
committed
nix: check if we are in the repository root
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent cec4833 commit 2ebdf36

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

shell.nix

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ pkgs.mkShell {
99
];
1010

1111
shellHook = ''
12-
# Symlink the pre-commit hook into the .git/hooks directory
13-
ln -sf ../../scripts/pre-commit.sh .git/hooks/pre-commit
12+
# Determine the repository root
13+
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
14+
15+
# Check if we are in the repository root
16+
if [ "$REPO_ROOT" = "$(pwd)" ]; then
17+
# Symlink the pre-commit hook into the .git/hooks directory
18+
ln -sf ../../scripts/pre-commit.sh .git/hooks/pre-commit
19+
fi
1420
'';
1521
}

0 commit comments

Comments
 (0)