Postgres, initialize in mkShell
This commit is contained in:
parent
41d73744ca
commit
5382e74a25
20
flake.nix
20
flake.nix
|
@ -11,11 +11,25 @@
|
|||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
in rec {
|
||||
packages = rec {
|
||||
hello = pkgs.hello;
|
||||
default = hello;
|
||||
postgres = pkgs.postgresql_15_jit;
|
||||
|
||||
default = pkgs.hello;
|
||||
};
|
||||
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
|
||||
'';
|
||||
};
|
||||
}
|
||||
) // {
|
||||
|
|
Loading…
Reference in New Issue
Block a user