diff options
Diffstat (limited to 'shells/postgresql.nix')
-rw-r--r-- | shells/postgresql.nix | 26 |
1 files changed, 26 insertions, 0 deletions
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 @@ | |||
1 | with import <nixpkgs> {}; | ||
2 | mkShell { | ||
3 | buildInputs = [ postgresql_11 glibcLocales ]; | ||
4 | shellHook = '' | ||
5 | export PGDB="dummy"; | ||
6 | export PGDATA=$PWD/postgres | ||
7 | export PGHOST=$PWD/postgres | ||
8 | export PGPORT=5432 | ||
9 | export LOG_PATH=$PWD/postgres/LOG | ||
10 | export PGDATABASE=postgres | ||
11 | export DATABASE_URL="postgresql:///postgres?host=$PGDATA" | ||
12 | export LANG=en_US.UTF-8; | ||
13 | export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive; | ||
14 | mkdir -p $PGDATA | ||
15 | echo 'Initializing postgresql database...' | ||
16 | initdb $PGDATA --auth=trust >/dev/null | ||
17 | pg_ctl start -w -l $LOG_PATH -o "-c synchronous_commit=off -c listen_addresses= -c unix_socket_directories=$PGDATA" | ||
18 | createdb "$PGDB"; | ||
19 | finish() { | ||
20 | pg_ctl stop -m fast; | ||
21 | rm -rf "$PGDATA"; | ||
22 | } | ||
23 | trap finish EXIT | ||
24 | ''; | ||
25 | } | ||
26 | |||