#!/usr/bin/env bash
# Script to start the local dev server

set -e

# Unless the RunDevServer binary is available, we rebuild the .envrc cache with nix-shell
# and config cachix for using our binary cache
command -v RunDevServer >/dev/null 2>&1 \
    || { echo "PATH_add $(nix-shell -j auto --cores 0 --run 'printf %q $PATH')" > .envrc; }

# Now we have to load the PATH variable from the .envrc cache
direnv allow
eval "$(direnv hook bash)"
eval "$(direnv export bash)"

# Finally start the dev server
RunDevServer
