# Automatically activate the Nix dev shell when entering this directory.
# Requires: nix + direnv + nix-direnv
#
# Install nix-direnv: https://github.com/nix-community/nix-direnv
#
# To use a specific shell instead of the default, put only the flake target
# in .envrc.local (for example: .#go). This file is treated as data and is
# not executed as shell code.
#
if [ -f .envrc.local ]; then
  flake_target="$(tr -d '\r\n' < .envrc.local)"
  case "$flake_target" in
    .#[A-Za-z0-9._-]*)
      use flake "$flake_target"
      ;;
    "")
      use flake
      ;;
    *)
      echo "Invalid .envrc.local: expected a flake target like .#go" >&2
      return 1
      ;;
  esac
else
  use flake
fi
