# For use with direnv: https://direnv.net
# See also: ./env.sh

if [ "$OMICRON_USE_FLAKE" = 1 ] && nix flake show &> /dev/null
then
    # watch the files that the Nix flake takes as inputs, so that changing them
    # invalidates the nix-direnv cache. note that the version and checksum files
    # should always be updated together, but we will watch both nonetheless.
    watch_file rust-toolchain.toml
    watch_file tools/maghemite_mg_openapi_version
    watch_file tools/maghemite_ddm_openapi_version
    watch_file tools/maghemite_mgd_checksums
    watch_file tools/dendrite_version
    watch_file tools/dendrite_stub_checksums
    watch_file tools/clickhouse_version
    watch_file tools/clickhouse_checksums
    watch_file tools/cockroachdb_version
    watch_file tools/cockroachdb_checksums
    use flake
else
    # only add `out/` paths to the PATH if we're not using the Nix flake. for
    # Nix users, the PATH is instead directly munged to contain the
    # `/nix/store/` paths at which we've downloaded all the test dependencies,
    # and adding `out/` paths would fight with that.
    PATH_add out/cockroachdb/bin
    PATH_add out/clickhouse
    PATH_add out/dendrite-stub/bin
    PATH_add out/mgd/root/opt/oxide/mgd/bin
    PATH_add out/mg-ddm/root/opt/oxide/mg-ddm/bin
fi
