summary refs log tree commit diff
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
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.
-rw-r--r--nixos/modules/services/logging/logrotate.nix20
-rw-r--r--nixos/modules/system/boot/systemd.nix17
2 files changed, 17 insertions, 20 deletions
diff --git a/nixos/modules/services/logging/logrotate.nix b/nixos/modules/services/logging/logrotate.nix
index 8cef4e8c083..26d22d90175 100644
--- a/nixos/modules/services/logging/logrotate.nix
+++ b/nixos/modules/services/logging/logrotate.nix
@@ -4,7 +4,6 @@ with lib;
 
 let
   cfg = config.services.logrotate;
-  inherit (config.users) groups;
 
   pathOpts = { name, ... }:  {
     options = {
@@ -163,25 +162,6 @@ in
       }
     ) cfg.paths;
 
-    services.logrotate = {
-      paths = {
-        "/var/log/btmp" = {
-          frequency = mkDefault "monthly";
-          keep = mkDefault 1;
-          extraConfig = ''
-            create 0660 root ${groups.utmp.name}
-          '';
-        };
-        "/var/log/wtmp" = {
-          frequency = mkDefault "monthly";
-          keep = mkDefault 1;
-          extraConfig = ''
-            create 0664 root ${groups.utmp.name}
-          '';
-        };
-      };
-    };
-
     systemd.services.logrotate = {
       description = "Logrotate Service";
       wantedBy = [ "multi-user.target" ];
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.