summary refs log tree commit diff
path: root/nixos/modules/system/boot/systemd.nix
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2022-02-11 17:09:52 +0900
committerDominique Martinet <asmadeus@codewreck.org>2022-02-11 20:52:40 +0900
commit9917af7fe0e394d854a8e9548ac0a040cfc44621 (patch)
tree253435120fd4ac33c025c1b66531024f99da54ae /nixos/modules/system/boot/systemd.nix
parent4521b84d495d51815fa07017ca3a82cf8004891e (diff)
downloadnixpkgs-9917af7fe0e394d854a8e9548ac0a040cfc44621.tar
nixpkgs-9917af7fe0e394d854a8e9548ac0a040cfc44621.tar.gz
nixpkgs-9917af7fe0e394d854a8e9548ac0a040cfc44621.tar.bz2
nixpkgs-9917af7fe0e394d854a8e9548ac0a040cfc44621.tar.lz
nixpkgs-9917af7fe0e394d854a8e9548ac0a040cfc44621.tar.xz
nixpkgs-9917af7fe0e394d854a8e9548ac0a040cfc44621.tar.zst
nixpkgs-9917af7fe0e394d854a8e9548ac0a040cfc44621.zip
logrotate: move wtmp/btmp rules to systemd
wtmp and btmp are created by systemd, so the rules are more appropriate there.

They can be disabled explicitly with something like
  services.ogrotate.paths = {
    "/var/log/btmp".enable = false;
    "/var/log/wtmp".enable = false;
  };
if required.
Diffstat (limited to 'nixos/modules/system/boot/systemd.nix')
-rw-r--r--nixos/modules/system/boot/systemd.nix17
1 files changed, 17 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 9dcf9eb769f..4edaf405fbf 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -1212,6 +1212,23 @@ in
     boot.kernel.sysctl."kernel.pid_max" = mkIf pkgs.stdenv.is64bit (lib.mkDefault 4194304);
 
     boot.kernelParams = optional (!cfg.enableUnifiedCgroupHierarchy) "systemd.unified_cgroup_hierarchy=0";
+
+    services.logrotate.paths = {
+      "/var/log/btmp" = mapAttrs (_: mkDefault) {
+        frequency = "monthly";
+        keep = 1;
+        extraConfig = ''
+          create 0660 root ${config.users.groups.utmp.name}
+        '';
+      };
+      "/var/log/wtmp" = mapAttrs (_: mkDefault) {
+        frequency = "monthly";
+        keep = 1;
+        extraConfig = ''
+          create 0664 root ${config.users.groups.utmp.name}
+        '';
+      };
+    };
   };
 
   # FIXME: Remove these eventually.