blob: 14bfc6863ac556834400303ab3488dfd0249ce18 (
plain)
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
|
{
config,
lib,
pkgs,
this,
...
}:
with lib; let
cfg = config.nixfiles.modules.postgresql;
in {
options.nixfiles.modules.postgresql.enable = mkEnableOption "PostgeSQL";
config = mkIf cfg.enable {
services = {
postgresql = {
enable = true;
package = pkgs.postgresql_14; # Pin version to prevent any surprises.
authentication = ''
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
'';
};
prometheus.exporters.postgres = {
enable = true;
listenAddress = mkDefault this.wireguard.ipv4.address;
port = mkDefault 9187;
};
};
environment.sessionVariables.PSQLRC = toString (pkgs.writeText "psqlrc" ''
\set QUIET 1
\timing
\x auto
\pset null '[NULL]'
\set PROMPT1 '%[%033[1m%]%M %n@%/%R%[%033[0m%]% λ '
\set PROMPT2 ' … > '
\set VERBOSITY verbose
\set HISTCONTROL ignoredups
\set HISTFILE /dev/null
\unset QUIET
'');
};
}
|