2020-05-28 00:53:23 +02:00
|
|
|
{ pkgs ? import <nixpkgs> { } }:
|
|
|
|
|
2020-06-21 15:58:43 +02:00
|
|
|
with pkgs;
|
2020-05-28 00:53:23 +02:00
|
|
|
|
2021-02-05 18:47:14 +01:00
|
|
|
let
|
|
|
|
sql_file = "assets/db_creation.sql";
|
|
|
|
data_dir = "$(pwd)/.pgdata";
|
|
|
|
|
|
|
|
in mkShell {
|
|
|
|
buildInputs = [ python38 poetry postgresql ];
|
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
trap "kill 0" EXIT
|
|
|
|
export PGDATA="${data_dir}"
|
|
|
|
export PGHOST="${data_dir}"
|
|
|
|
|
|
|
|
if [ ! -d ${data_dir} ]; then
|
|
|
|
initdb --auth-local=trust --no-locale --encoding=UTF8
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! pg_ctl status; then
|
|
|
|
pg_ctl start -o "--unix_socket_directories=${data_dir} --listen_addresses='''"
|
|
|
|
fi
|
|
|
|
|
|
|
|
psql -d postgres -f ${sql_file}
|
|
|
|
alias psql='psql -d postgres'
|
|
|
|
'';
|
2020-05-28 00:53:23 +02:00
|
|
|
}
|