-
Notifications
You must be signed in to change notification settings - Fork 8
/
shell.nix
71 lines (60 loc) · 1.68 KB
/
shell.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
let
pkgs = import <nixpkgs> {};
issStatic = (pkgs.callPackage ./ISS/static-src {});
in
pkgs.stdenv.mkDerivation {
name = "ISS";
buildInputs = [
pkgs.nodejs-18_x
pkgs.Fabric
(pkgs.python3.withPackages( ps: with ps; [
build
django
pytz
pillow
psycopg2
lxml
requests
django-debug-toolbar
(pkgs.callPackage ./nix-deps/django-recaptcha2 {})
(pkgs.callPackage ./nix-deps/email-normalize {})
(pkgs.callPackage ./nix-deps/bbcode {})
(pkgs.callPackage ./nix-deps/tripphrase {})
]))
];
nativeBuildInputs = [
pkgs.postgresql_15
];
postgresConf =
pkgs.writeText "postgresql.conf"
''
# Add Custom Settings
log_min_messages = warning
log_min_error_statement = error
log_min_duration_statement = 100 # ms
log_connections = on
log_disconnections = on
log_duration = on
#log_line_prefix = '[] '
log_timezone = 'UTC'
log_statement = 'all'
log_directory = 'pg_log'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
logging_collector = on
log_min_error_statement = error
'';
PGDATA = "${toString ./.}/.pg";
# Post Shell Hook
shellHook = ''
echo "Using ${pkgs.postgresql_15.name}."
export ISS_SETTINGS_FILE=$(pwd)/settings.py
# Setup: other env variables
export PGHOST="$PGDATA"
npm config set prefix /home/lanny/.node/18.x
# Setup: DB
[ ! -d $PGDATA ] && pg_ctl initdb -o "-U postgres" && cat "$postgresConf" >> $PGDATA/postgresql.conf
pg_ctl -o "-p 5432 -k $PGDATA" start
alias fin="pg_ctl stop && exit"
alias pg="psql -p 5432 -U postgres"
'';
}