From 8eb07d94a12f0fb8d4a8f15043aedc8cadd7c676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 22 Jul 2020 01:16:01 +0200 Subject: Initial commit --- shells/postgresql.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 shells/postgresql.nix (limited to 'shells/postgresql.nix') diff --git a/shells/postgresql.nix b/shells/postgresql.nix new file mode 100644 index 0000000..4f7bdc4 --- /dev/null +++ b/shells/postgresql.nix @@ -0,0 +1,26 @@ +with import {}; + mkShell { + buildInputs = [ postgresql_11 glibcLocales ]; + shellHook = '' + export PGDB="dummy"; + export PGDATA=$PWD/postgres + export PGHOST=$PWD/postgres + export PGPORT=5432 + export LOG_PATH=$PWD/postgres/LOG + export PGDATABASE=postgres + export DATABASE_URL="postgresql:///postgres?host=$PGDATA" + export LANG=en_US.UTF-8; + export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive; + mkdir -p $PGDATA + echo 'Initializing postgresql database...' + initdb $PGDATA --auth=trust >/dev/null + pg_ctl start -w -l $LOG_PATH -o "-c synchronous_commit=off -c listen_addresses= -c unix_socket_directories=$PGDATA" + createdb "$PGDB"; + finish() { + pg_ctl stop -m fast; + rm -rf "$PGDATA"; + } + trap finish EXIT + ''; + } + -- cgit v1.2.3