summary refs log tree commit diff
path: root/.husky/pre-commit
blob: bc8bed76b64806289c39573b2f4c6fb7355b170d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env sh
#!nix-shell -i "bash" -p bash prefetch-npm-deps jq nodejs nix-output-monitor
. "$(dirname -- "$0")/_/husky.sh"

# Check if nix is available
if [ -n "$(find "flake.lock" -mtime +7 -print)" ]; then
  if [ -x "$(/usr/bin/env which nix-shell 2>/dev/null)" ]; then
    # Check if we haven't re-executed ourselves yet
    if [ ! "$HOOK_NIX_SHELL" ]; then
      echo "Nix is available, updating nix flake..."
      export HOOK_NIX_SHELL=1
      nix-shell $0
      exit $?
    else
       nix flake update --extra-experimental-features 'nix-command flakes' -vL
       git add flake.lock
    fi
  else
    echo "You do not appear to have nix installed. Skipping update of nix dependencies."
  fi
else
  echo "Nix flake lock was updated less than 7 days ago. Skipping update."
fi

npx -y lint-staged