]> git.immae.eu Git - perso/Immae/Config/Nixies.git/blob - shells/postgresql.nix
Initial commit
[perso/Immae/Config/Nixies.git] / shells / postgresql.nix
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