2021-02-05 20:14:43 +01:00
|
|
|
{ pkgs ? import <nixpkgs> { } }:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
|
|
|
let
|
2021-02-09 15:17:02 +01:00
|
|
|
sql_file = "psql_creation.sql";
|
|
|
|
data_dir = "$(pwd)/.pgdata";
|
|
|
|
origin = "databases/odyfo.db";
|
2021-02-05 20:14:43 +01:00
|
|
|
|
|
|
|
in mkShell {
|
2021-02-10 01:26:54 +01:00
|
|
|
buildInputs = [ postgresql python27 python27Packages.virtualenv ];
|
2021-02-05 20:14:43 +01:00
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
trap "kill 0" EXIT
|
2021-02-09 15:17:02 +01:00
|
|
|
export PGDATA="${data_dir}"
|
|
|
|
export PGHOST="${data_dir}"
|
2021-02-05 20:14:43 +01:00
|
|
|
|
2021-02-09 15:17:02 +01:00
|
|
|
if [ ! -d ${data_dir} ]; then
|
2021-02-05 20:14:43 +01:00
|
|
|
initdb --auth-local=trust --no-locale --encoding=UTF8
|
|
|
|
fi
|
|
|
|
|
2021-02-05 21:16:35 +01:00
|
|
|
if ! pg_ctl status; then
|
2021-02-09 15:17:02 +01:00
|
|
|
pg_ctl start -o "--unix_socket_directories=${data_dir} --listen_addresses='''"
|
2021-02-05 21:16:35 +01:00
|
|
|
fi
|
2021-02-05 20:14:43 +01:00
|
|
|
|
|
|
|
alias psql='psql -d postgres'
|
2021-02-09 15:17:02 +01:00
|
|
|
alias nuke='rm -rf ${data_dir}'
|
|
|
|
|
2021-02-10 01:26:54 +01:00
|
|
|
# Workaround to use pip
|
|
|
|
SOURCE_DATE_EPOCH=$(date +%s)
|
|
|
|
virtualenv .venv
|
|
|
|
export PATH=$PWD/.venv/bin:$PATH
|
|
|
|
pip install etlalchemy
|
|
|
|
pip install psycopg2
|
2021-02-05 20:14:43 +01:00
|
|
|
'';
|
|
|
|
}
|