-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
51 lines (48 loc) · 1.67 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = {nixpkgs, ...}: let
forAllSystems = with nixpkgs.lib;
f: genAttrs systems.flakeExposed (system: f nixpkgs.legacyPackages.${system});
in {
devShells = forAllSystems (pkgs: {
default = with pkgs;
mkShell {
env = {
PRISMA_QUERY_ENGINE_LIBRARY = "${prisma-engines}/lib/libquery_engine.node";
PRISMA_QUERY_ENGINE_BINARY = "${prisma-engines}/bin/query-engine";
PRISMA_SCHEMA_ENGINE_BINARY = "${prisma-engines}/bin/schema-engine";
};
buildInputs = [
postgresql_17
bun
nodePackages_latest.prettier
openssl
];
shellHook = ''
export PG=$PWD/.dev_postgres/
export PGDATA="$PG"data
export PGPORT=5432
export PGHOST=localhost
export PGUSER=$USER
export PGPASSWORD=postgres
export PGDATABASE=example
export DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/$PGDATABASE
pg_setup() {
pg_stop;
rm -rf $PG;
initdb -D $PGDATA &&
echo "unix_socket_directories = '$PGDATA'" >> $PGDATA/postgresql.conf &&
pg_ctl -D $PGDATA -l $PG/postgres.log start &&
createdb
}
alias pg_start="pg_ctl -D $PGDATA -l $PG/postgres.log start"
alias pg_stop="pg_ctl -D $PGDATA stop"
alias pg_drop="psql -U $PGUSER -c 'DROP DATABASE $PGDATABASE'"
alias exit="pg_ctl -D $PGDATA stop && exit"
'';
};
});
};
}