Postgres, initialize in mkShell

This commit is contained in:
xenia 2023-08-08 17:24:46 +02:00
parent 41d73744ca
commit 5382e74a25

View File

@ -11,11 +11,25 @@
let pkgs = nixpkgs.legacyPackages.${system}; let pkgs = nixpkgs.legacyPackages.${system};
in rec { in rec {
packages = rec { packages = rec {
hello = pkgs.hello; postgres = pkgs.postgresql_15_jit;
default = hello;
default = pkgs.hello;
}; };
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
packages = [ packages.default ]; packages = [ packages.default packages.postgres ];
shellHook = ''
set -e
[ -d ./matabas-db ] || pg_ctl initdb --pgdata=./matabas-db
mkdir -p ./matabas-db/socket
[ -f matabas-db/matabas.log ] && mv -f matabas-db/matabas.log{,.old}
pg_ctl start --pgdata=./matabas-db --log=./matabas-db/matabas.log --options="-p 2137"
trap 'pg_ctl stop --pgdata=./matabas-db' EXIT
createdb -p 2137 matabas || : 3
set +e
'';
}; };
} }
) // { ) // {