···5354 backlogLimit = lib.mkOption {
55 type = lib.types.int;
56- default = 64; # Apparently the kernel default
0057 description = ''
58 The maximum number of outstanding audit buffers allowed; exceeding this is
59 considered a failure and handled in a manner specified by failureMode.
···81 };
8283 config = lib.mkIf (cfg.enable == "lock" || cfg.enable) {
00000000000084 systemd.services.audit-rules = {
85 description = "Load Audit Rules";
86 wantedBy = [ "sysinit.target" ];
···5354 backlogLimit = lib.mkOption {
55 type = lib.types.int;
56+ # Significantly increase from the kernel default of 64 because a
57+ # normal systems generates way more logs.
58+ default = 1024;
59 description = ''
60 The maximum number of outstanding audit buffers allowed; exceeding this is
61 considered a failure and handled in a manner specified by failureMode.
···83 };
8485 config = lib.mkIf (cfg.enable == "lock" || cfg.enable) {
86+ boot.kernelParams = [
87+ # A lot of audit events happen before the systemd service starts. Thus
88+ # enable it via the kernel commandline to have the audit subsystem ready
89+ # as soon as the kernel starts.
90+ "audit=1"
91+ # Also set the backlog limit because the kernel default is too small to
92+ # capture all of them before the service starts.
93+ "audit_backlog_limit=${toString cfg.backlogLimit}"
94+ ];
95+96+ environment.systemPackages = [ pkgs.audit ];
97+98 systemd.services.audit-rules = {
99 description = "Load Audit Rules";
100 wantedBy = [ "sysinit.target" ];
+1-3
nixos/modules/security/auditd.nix
···202 }
203 ];
204205- # Starting auditd should also enable loading the audit rules..
206 security.audit.enable = lib.mkDefault true;
207-208- environment.systemPackages = [ pkgs.audit ];
209210 # setting this to anything other than /etc/audit/plugins.d will break, so we pin it here
211 security.auditd.settings.plugin_dir = "/etc/audit/plugins.d";
···202 }
203 ];
204205+ # Starting the userspace daemon should also enable audit in the kernel
206 security.audit.enable = lib.mkDefault true;
00207208 # setting this to anything other than /etc/audit/plugins.d will break, so we pin it here
209 security.auditd.settings.plugin_dir = "/etc/audit/plugins.d";