-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevshell.nix
60 lines (52 loc) · 1.52 KB
/
devshell.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
{
pkgs,
lib,
project,
...
}: let
menu = ''
My Postgres Extension Development Environment
=============================================
Available commands:
menu - Show this menu
pglocal - Relocate the local Postgres installation to the project's out folder
pginit - Initialize the local Postgres installation
pgstart - Start the local Postgres installation
pgstop - Stop the local Postgres installation
pgstatus - Show the run status of the local Postgres installation
'';
makeScripts = scripts:
lib.mapAttrsToList
(name: script: pkgs.writeShellScriptBin name script)
scripts;
scripts = makeScripts {
menu = ''
cat <<EOF
${menu}
EOF
'';
};
in {
# Make project build dependencies available to the shell
inputsFrom = [project];
packages =
scripts
++ [
# Get pgzx development scripts like pglocal, pginit, pgstart...
# We also need a local postgres for pglocal that we install in the devshell.
pkgs.pgzx_scripts
pkgs.postgresql_16_jit
# Additional Zig tools.
pkgs.zls # Zig Language Server
];
# On shell startup we must set some environment variables for the pgzx scripts:
shellHook = ''
export PRJ_ROOT=$PWD
export PG_HOME=$PRJ_ROOT/out/default
export PATH="$PG_HOME/lib/postgresql/pgxs/src/test/regress:$PATH"
export PATH="$PG_HOME/bin:$PRJ_ROOT/dev/scripts:$PATH"
export NIX_PGLIBDIR=$PG_HOME/lib
alias root='cd $PRJ_ROOT'
menu
'';
}