37 lines
812 B
Nix
37 lines
812 B
Nix
{ pkgs ? import <nixpkgs> { } }:
|
|
|
|
with pkgs;
|
|
|
|
let
|
|
sql_file = "psql_creation.sql";
|
|
data_dir = "$(pwd)/.pgdata";
|
|
origin = "databases/odyfo.db";
|
|
|
|
in mkShell {
|
|
buildInputs = [ postgresql python27 python27Packages.virtualenv ];
|
|
|
|
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
|
|
|
|
alias psql='psql -d postgres'
|
|
alias nuke='rm -rf ${data_dir}'
|
|
|
|
# Workaround to use pip
|
|
SOURCE_DATE_EPOCH=$(date +%s)
|
|
virtualenv .venv
|
|
export PATH=$PWD/.venv/bin:$PATH
|
|
pip install etlalchemy
|
|
pip install psycopg2
|
|
'';
|
|
}
|