-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
74 lines (71 loc) · 2.42 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
description = "virtual environments";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { flake-utils, nixpkgs, devshell, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlays.default ];
};
in
with pkgs; {
devShells.default = pkgs.devshell.mkShell {
packages = [ nodejs nodePackages.pnpm nodePackages.yarn postgresql_16 redis ];
commands = [
{
name = "pg:setup";
category = "database";
help = "Setup postgres in project folder";
command = ''
initdb --encoding=UTF8 --no-locale --no-instructions -U postgres
echo "listen_addresses = ${"'"}${"'"}" >> $PGDATA/postgresql.conf
echo "unix_socket_directories = '$PGDATA'" >> $PGDATA/postgresql.conf
echo "CREATE USER postgres WITH PASSWORD 'password' CREATEDB SUPERUSER;" | postgres --single -E postgres
'';
}
{
name = "pg:start";
category = "database";
help = "Start postgres instance";
command = ''
[ ! -d $PGDATA ] && pg:setup
postgres
'';
}
{
name = "pg:console";
category = "database";
help = "Open database console";
command = ''
psql --host $PGDATA s
'';
}
];
env = [
{ name = "DATABASE_URL"; eval = "postgresql://postgres:password@localhost/postgres?host=$PRJ_DATA_DIR/postgres"; }
{ name = "PGDATA"; eval = "$PRJ_DATA_DIR/postgres"; }
{
name = "PRISMA_QUERY_ENGINE_BINARY";
value = "${prisma-engines}/bin/query_engine";
}
{
name = "PRISMA_QUERY_ENGINE_LIBRARY";
value = "${prisma-engines}/lib/libquery_engine.node";
}
{
name = "PRISMA_SCHEMA_ENGINE_BINARY";
value = "${pkgs.prisma-engines}/bin/schema-engine";
}
];
};
}
);
}