-
Notifications
You must be signed in to change notification settings - Fork 12
/
devshell.nix
77 lines (65 loc) · 1.85 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
pkgs,
lib,
...
}: let
menu = ''
PGZX development shell
======================
Available commands:
menu - show this menu
pglocal - Create local installation from existing postgresql installation
pguse - Change default local installation to use
pginit - Initialize new test database in local installation
pgstart - Start local installation
pgstop - Stop local installation
Shell aliases (might not work with direnv):
root - cd to project root
'';
makeScripts = scripts:
lib.mapAttrsToList
(name: script: pkgs.writeShellScriptBin name script)
scripts;
scripts = makeScripts {
menu = ''
cat <<EOF
${menu}
EOF
'';
};
# On darwin we expect command line tools to be installed.
# It is possible to install clang/gcc as nix package, but linking
# can be quite a pain.
# On non-darwin systems we will use the nix toolchain for now.
#useSystemCC = pkgs.stdenv.isDarwin;
in {
packages =
scripts
++ [
# make linters and formatters available in dev shell
pkgs.pre-commit
pkgs.alejandra
pkgs.deadnix
pkgs.shellcheck
pkgs.shfmt
pkgs.postgresql_16_jit
pkgs.openssl
pkgs.gss
pkgs.krb5
pkgs.pkg-config
pkgs.zigpkgs.master
pkgs.zls
];
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/bin:$PATH"
# Nix postgres is patched to find and install libraries into another directory
# than the default. For our local setup we must overwrite the default location by using
# the NIX_PGLIBDIR environment variable.
export NIX_PGLIBDIR=$PG_HOME/lib
alias root='cd $PRJ_ROOT'
menu
'';
}