# This file will be called by direnv.
# See https://direnv.net/

if [ ! -d .direnv ]
then
	echo "envrc: Creating .direnv"
	mkdir .direnv
fi

if [ -f .env ]
then
	dotenv
elif [ -f .env.example ]
then
	echo "envrc: '.env.example' exists, but '.env' does not."
	echo "envrc: Consider doing 'cp .env.example .env'."
fi

# Nix related switches
# This should not do anything if nix is not in $PATH
#if LC_ALL=C type use_flake 2>&1 >/dev/null
# If `use_flake` is defined, call that to use nix-direnv. See
# https://github.com/nix-community/nix-direnv/tree/912b847b4d1ce7d41b41b796e1bcdebc14a4bc45#flakes-support
#then
	#use_flake
#elif [ -x "$(command -v nix)" ]
# If `use_flake` is not defined, but `nix` can be found, manually load the flake.
#then
	watch_file flake.nix
	watch_file flake.lock
	eval "$(nix print-dev-env --profile $(direnv_layout_dir)/flake-profile)"
#fi
