Created
September 19, 2022 20:24
-
-
Save danidiaz/c9a9fec9cc934ffc781ac68315fbcb65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} }: | |
pkgs.mkShell { | |
packages = [ | |
pkgs.glibcLocales | |
(pkgs.postgresql.withPackages (p: [])) | |
pkgs.pgcli | |
]; | |
shellHook = '' | |
StartPG(){ | |
pg_ctl -w -l $PGDATA/log start | |
} | |
StopPG(){ | |
echo "stopping PG..." | |
pg_ctl stop | |
} | |
export PGDATA="$PWD/.pg" | |
export PGHOST="$PWD/.pg_sockets" | |
export PGDATABASE="foodb" | |
if [ ! -d $PGDATA ]; then | |
initdb &> /dev/null | |
mkdir -p $PGHOST | |
echo "unix_socket_directories = '$PGHOST'" >> $PGDATA/postgresql.conf | |
CREATE=true | |
fi | |
StartPG | |
trap StopPG EXIT # ~ trapping HUP/EXIT | |
if [[ $CREATE ]]; then | |
createuser -s postgres &> /dev/null | |
createdb $PGDATABASE | |
# set a stable crappy password for local/dev | |
# create db | |
fi | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment