#!/usr/bin/env bash

# Reload if any of these files change
watch_file nix/*
watch_file .envrc.local

# Build a folder that contains all the tools
nix-build ./nix -A env --out-link ./env

# source .profile from `$env`.
# This is only used to set things interpolated by nix.
# All *static* things should live inside .envrc.
source_env ./env/.profile

# used by docker-compose to run processes with the same user ID mapping
HOST_UID=$(id -u)
HOST_GID=$(id -g)
export HOST_UID HOST_GID

# set protoc path from nix env
export PROTOC_PATH=$(readlink -f ./env/bin/protoc)

# allow local .envrc overrides
[[ -f .envrc.local ]] && source_env .envrc.local
