if [ -f flake.lock ] && [ -f flake.nix ]; then
    # reload when these files change
    watch_file flake.nix
    watch_file flake.lock
    # load the flake devShell
    if [ ! -d $(direnv_layout_dir) ]; then
        mkdir $(direnv_layout_dir)
    fi
    eval "$(nix --experimental-features 'nix-command flakes' print-dev-env --profile "$(direnv_layout_dir)/flake-profile")"
elif type lorri &>/dev/null; then
    echo "direnv: using lorri from PATH ($(type -p lorri))"
    eval "$(lorri direnv)"
else
    # fall back to using direnv's builtin nix support
    # to prevent bootstrapping problems.
    use nix
fi