File tree Expand file tree Collapse file tree 5 files changed +90
-1
lines changed Expand file tree Collapse file tree 5 files changed +90
-1
lines changed Original file line number Diff line number Diff line change 14
14
in
15
15
runCommand "ubuntu-cloudimg" { nativeBuildInputs = [ xz ] ; } ''
16
16
mkdir -p $out
17
+ # Remove (among other things) builtin logrotate to avoid conflicts with the one set-up by system-manager
17
18
tar --exclude='dev/*' \
18
19
--exclude='etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service' \
19
20
--exclude='etc/systemd/system/multi-user.target.wants/systemd-resolved.service' \
21
+ --exclude='etc/systemd/system/timers.target.wants/logrotate.timer' \
20
22
--exclude='usr/lib/systemd/system/tpm-udev.service' \
21
23
--exclude='usr/lib/systemd/system/systemd-remount-fs.service' \
22
24
--exclude='usr/lib/systemd/system/systemd-resolved.service' \
25
+ --exclude='usr/lib/systemd/system/logrotate.service' \
26
+ --exclude='usr/lib/systemd/system/logrotate.timer' \
23
27
--exclude='usr/lib/systemd/system/proc-sys-fs-binfmt_misc.automount' \
24
28
--exclude='usr/lib/systemd/system/sys-kernel-*' \
25
29
--exclude='var/lib/apt/lists/*' \
Original file line number Diff line number Diff line change 1
1
{ self , inputs , ... } :
2
2
let
3
3
mkModules = system : [
4
+ self . systemModules . logrotate
4
5
( {
5
6
services . nginx . enable = true ;
6
7
nixpkgs . hostPlatform = system ;
8
+ supabase . services . logrotate . enable = true ;
7
9
} )
8
10
] ;
9
11
Original file line number Diff line number Diff line change 4
4
{
5
5
imports = [ ./tests ] ;
6
6
flake = {
7
- systemModules = { } ;
7
+ systemModules = {
8
+ logrotate = ./logrotate.nix ;
9
+ } ;
8
10
} ;
9
11
}
Original file line number Diff line number Diff line change
1
+ {
2
+ lib ,
3
+ nixosModulesPath ,
4
+ config ,
5
+ ...
6
+ } :
7
+ let
8
+ cfg = config . supabase . services . logrotate ;
9
+ in
10
+ {
11
+ imports = map ( path : nixosModulesPath + path ) [
12
+ # FIXME: error: The option `services.logrotate' in module `/nix/store/...-source/nix/modules'
13
+ # would be a parent of the following options,but its type `attribute set' does not support nested options.
14
+ # "/services/logging/logrotate.nix"
15
+ ] ;
16
+
17
+ options = {
18
+ supabase . services . logrotate = {
19
+ enable = lib . mkEnableOption "Whether to enable the logrotate systemd service." ;
20
+ } ;
21
+ } ;
22
+
23
+ config = lib . mkIf cfg . enable {
24
+ services . logrotate = {
25
+ enable = true ;
26
+ settings = {
27
+ "/var/log/postgresql/auth-failures.csv" = {
28
+ size = "10M" ;
29
+ rotate = 5 ;
30
+ compress = true ;
31
+ delaycompress = true ;
32
+ notifempty = true ;
33
+ missingok = true ;
34
+ } ;
35
+ "/var/log/postgresql/postgresql.csv" = {
36
+ size = "50M" ;
37
+ rotate = 9 ;
38
+ compress = true ;
39
+ delaycompress = true ;
40
+ notifempty = true ;
41
+ missingok = true ;
42
+ postrotate = ''
43
+ sudo -u postgres /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data logrotate
44
+ '' ;
45
+ } ;
46
+ "/var/log/postgresql/postgresql.log" = {
47
+ size = "50M" ;
48
+ rotate = 3 ;
49
+ copytruncate = true ;
50
+ delaycompress = true ;
51
+ compress = true ;
52
+ notifempty = true ;
53
+ missingok = true ;
54
+ } ;
55
+ "/var/log/wal-g/*.log" = {
56
+ size = "50M" ;
57
+ rotate = 3 ;
58
+ copytruncate = true ;
59
+ delaycompress = true ;
60
+ compress = true ;
61
+ notifempty = true ;
62
+ missingok = true ;
63
+ } ;
64
+ } ;
65
+ } ;
66
+
67
+ # FIXME: logrotate.service isn't a valid unit file (missing ExecStart)
68
+ # systemd.services.logrotate = {
69
+ # wantedBy = lib.mkForce [
70
+ # "system-manager.target"
71
+ # ];
72
+ # };
73
+ } ;
74
+ }
Original file line number Diff line number Diff line change
1
+ # from time import sleep
2
+
3
+
4
+ def test_logrotate_service (host ):
5
+ # sleep(5000) # Handy for interactive debugging (with docker exec -it $CONTAINER_ID /bin/bash)
6
+ assert host .service ("logrotate.service" ).is_valid
7
+ assert host .service ("logrotate.service" ).is_running , "Logrotate service should be running but failed: {}" .format (host .run ("systemctl status logrotate.service" ).stdout )
You can’t perform that action at this time.
0 commit comments