summaryrefslogtreecommitdiff
path: root/srv-dev-env.sh
blob: 2df99189ee588f5f16c7ad35cc0c5764e86d2d6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

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\";
}"

entrypoint=$(nix-build --no-out-link -A entrypoint \
    --arg baseConfig "$test_cfg" \
    --arg skipServices '["srv"]')

$entrypoint &
trap "kill $!; wait; rm -rf $test_dir" EXIT

# 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" \
    "$@"