forked from omnigres/omnigres
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevenv.nix
100 lines (87 loc) · 2.48 KB
/
devenv.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{ pkgs, lib, ... }:
{
packages = with pkgs; [
pkgsStatic.openssl
pkgconfig
cmake
flex
readline
zlib
clang-tools
python3
];
languages = {
python.enable = true;
c.enable = true;
cplusplus.enable = true;
};
# use the superior process manager
# process.implementation = "process-compose";
# processes.omnigres = {
# exec = "echo TODO";
# process-compose = {
# depends_on.postgres.condition = "process_healthy";
# availability.restart = "on_failure";
# };
# };
# https://devenv.sh/reference/options/#servicespostgresenable
services.postgres = {
enable = true;
package = pkgs.postgresql_15;
# install all extensions sans timescaledb
extensions =
let
# TODO: package omnigres extensions via Nix, import them here
omnigres-extensions = [ ];
filterBrokenAndNonHostPackages = hostPlatform: pkgs:
lib.filterAttrs
(name: pkg:
!(pkg.meta ? broken && pkg.meta.broken) &&
(pkg.meta ? platforms && lib.lists.elem hostPlatform pkg.meta.platforms)
)
pkgs;
in
extensions: (lib.attrValues
(builtins.removeAttrs
(filterBrokenAndNonHostPackages pkgs.system extensions)
[ "tds_fdw" "timescaledb_toolkit" "timescaledb-apache" "timescaledb" ])) ++
omnigres-extensions;
initdbArgs = [
"--locale=C"
"--encoding=UTF8"
];
initialDatabases = [
{ name = "omnigres"; }
];
initialScript = ''
create user omnigres with password 'omnigres';
grant all privileges on database omnigres to omnigres;
alter database omnigres owner to omnigres;
'';
listen_addresses = "127.0.0.1,localhost";
port = 5432;
# https://www.postgresql.org/docs/11/config-setting.html#CONFIG-SETTING-CONFIGURATION-FILE
settings = {
max_connections = 500;
work_mem = "20MB";
log_error_verbosity = "TERSE";
log_min_messages = "NOTICE";
log_min_error_statement = "WARNING";
log_line_prefix = "%m [%p] %u@%d/%a";
shared_preload_libraries = "pg_stat_statements";
statement_timeout = "100s";
deadlock_timeout = 3000;
# maximize speed for local development
fsync = "off";
jit = "0";
synchronous_commit = "off";
};
};
scripts = {
"pg".exec = "psql -U omnigres $@";
"pg-clear".exec = "git clean -xf $PGDATA";
};
pre-commit.hooks = {
nixpkgs-fmt.enable = true;
};
}