# Automatically load the Nix development shell when entering this directory
# Requires direnv: https://direnv.net/
#
# To enable:
#   1. Install direnv
#   2. Run: direnv allow
#
# This will automatically install all required dependencies for the project.
if ! has nix_direnv_version || ! nix_direnv_version 3.1.0; then
  source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.0/direnvrc" "sha256-yMJ2OVMzrFaDPn7q8nCBZFRYpL/f0RcHzhmw/i6btJM="
fi
use_flake

# Reclaim stale Nix store paths in the background, at most once per week.
# nix-direnv pins the current dev shell, so only older versions are freed.
if has nix-collect-garbage; then
  _gc_stamp="$PWD/.direnv/nix-gc-stamp"
  if [ ! -f "$_gc_stamp" ] || [ -n "$(find "$_gc_stamp" -mtime +7 2>/dev/null)" ]; then
    touch "$_gc_stamp"
    (nix-collect-garbage --delete-older-than 7d >/dev/null 2>&1 &)
  fi
fi
