mediocre-blog/srv-dev-env.sh

30 lines
735 B
Bash
Raw Normal View History

test_dir="$(mktemp -d)"
mkdir -p "$test_dir"/run
mkdir -p "$test_dir"/data
test_cfg="(import ./config.nix) // {
runDir=\"${test_dir}/run\";
dataDir=\"${test_dir}/data\";
}"
2022-05-08 22:57:04 +00:00
entrypoint=$(nix-build --no-out-link -A entrypoint \
--arg baseConfig "$test_cfg" \
2022-05-20 19:37:43 +00:00
--arg skipServices '["srv"]')
2022-05-08 22:57:04 +00:00
$entrypoint &
trap "kill $!; wait; rm -rf $test_dir" EXIT
2022-05-08 22:57:04 +00:00
# NOTE this is a bit of a hack... the location of the redis socket's source of
# truth is in default.nix, but it's not clear how to get that from there to
# here, so we reproduce the calculation here.
while [ ! -e $test_dir/run/redis ]; do
echo "waiting for redis unix socket"
sleep 1
done
nix-shell -A srv.shell \
--arg baseConfig "$test_cfg" \
"$@"