From e670c267d098fd19bce9f7dd3ba79dde129e9c26 Mon Sep 17 00:00:00 2001 From: Erik Post Date: Mon, 16 Mar 2020 21:20:44 +0100 Subject: [PATCH] Add initial nix-shell setup for test db. --- shell.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..fb8dc64 --- /dev/null +++ b/shell.nix @@ -0,0 +1,23 @@ +{ pkgs ? import {}, ... }: +let + inherit (pkgs) stdenv; +in stdenv.mkDerivation { + name = "myproject-devenv"; + buildInputs = with pkgs; [ + # postgresql + postgresql_12 + ]; + shellHook = '' + export PGDATA=$PWD/postgres_data + export PGHOST=localhost + export PGPORT=5432 + export LOG_PATH=$PWD/postgres.log + export PGDATABASE=postgres + + if [ ! -d $PGDATA ]; then + echo 'Initializing postgresql database...' + initdb $PGDATA --auth=trust >/dev/null + fi + pg_ctl start -l $LOG_PATH -o "-c listen_addresses='$PGHOST' -c port=$PGPORT" + ''; +}