#! /bin/sh
export NIX_USER_CONF_FILES="$PWD/dev/nix.conf"

if command -v nix >/dev/null; then
    if nix print-dev-env --help >/dev/null 2>&1; then
        use flake
    else
        use nix
        watch_file ./flake.nix
        watch_file ./dev/flake-parts.nix
    fi
else
    echo 'The development environment is using Nix to provide all the tools, please install Nix:' >&2
    echo 'https://nixos.org/download.html' >&2
fi

unset IN_NIX_SHELL
