diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml index 6f06838833eb..97e993e83ff0 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml @@ -2526,10 +2526,9 @@ sudo cp /var/lib/redis/dump.rdb /var/lib/redis-peertube/dump.rdb The logrotate module also has been updated to freeform syntax: - services.logrotate.paths - and - services.logrotate.extraConfig - will work, but issue deprecation warnings and + services.logrotate.paths and + services.logrotate.extraConfig will work, + but issue deprecation warnings and services.logrotate.settings should now be used instead. diff --git a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml index f36b2cda538c..b731b8b72a3d 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml @@ -507,6 +507,15 @@ [ "all" ]. + + + Deprecated settings logrotate.paths and + logrotate.extraConfig have been removed. + Please convert any uses to + services.logrotate.settings + instead. + + The isPowerPC predicate, found on diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md index 6fe5eba212f3..217aa6056cad 100644 --- a/nixos/doc/manual/release-notes/rl-2205.section.md +++ b/nixos/doc/manual/release-notes/rl-2205.section.md @@ -906,8 +906,8 @@ In addition to numerous new and upgraded packages, this release has the followin - [services.logrotate.enable](#opt-services.logrotate.enable) now defaults to true if any rotate path has been defined, and some paths have been added by default. -- The logrotate module also has been updated to freeform syntax: [services.logrotate.paths](#opt-services.logrotate.paths) - and [services.logrotate.extraConfig](#opt-services.logrotate.extraConfig) will work, but issue deprecation +- The logrotate module also has been updated to freeform syntax: `services.logrotate.paths` + and `services.logrotate.extraConfig` will work, but issue deprecation warnings and [services.logrotate.settings](#opt-services.logrotate.settings) should now be used instead. - `security.pam.ussh` has been added, which allows authorizing PAM sessions based on SSH _certificates_ held within an SSH agent, using [pam-ussh](https://github.com/uber/pam-ussh). diff --git a/nixos/doc/manual/release-notes/rl-2211.section.md b/nixos/doc/manual/release-notes/rl-2211.section.md index 8b24a6146270..0f0e3c7a2e55 100644 --- a/nixos/doc/manual/release-notes/rl-2211.section.md +++ b/nixos/doc/manual/release-notes/rl-2211.section.md @@ -171,6 +171,10 @@ Available as [services.patroni](options.html#opt-services.patroni.enable). This got partially copied over from the minimal profile and reduces the final system size by up to 200MB. If you require all locales installed set the option to ``[ "all" ]``. +- Deprecated settings `logrotate.paths` and `logrotate.extraConfig` have + been removed. Please convert any uses to + [services.logrotate.settings](#opt-services.logrotate.settings) instead. + - The `isPowerPC` predicate, found on `platform` attrsets (`hostPlatform`, `buildPlatform`, `targetPlatform`, etc) has been removed in order to reduce confusion. The predicate was was defined such that it matches only the 32-bit big-endian members of the POWER/PowerPC family, despite having a name which would imply a broader set of systems. If you were using this predicate, you can replace `foo.isPowerPC` with `(with foo; isPower && is32bit && isBigEndian)`. - The `fetchgit` fetcher now uses [cone mode](https://www.git-scm.com/docs/git-sparse-checkout/2.37.0#_internalscone_mode_handling) by default for sparse checkouts. [Non-cone mode](https://www.git-scm.com/docs/git-sparse-checkout/2.37.0#_internalsnon_cone_problems) can be enabled by passing `nonConeMode = true`, but note that non-cone mode is deprecated and this option may be removed alongside a future Git update without notice. diff --git a/nixos/modules/services/logging/logrotate.nix b/nixos/modules/services/logging/logrotate.nix index 5ea54a4cf921..b597ff9f5299 100644 --- a/nixos/modules/services/logging/logrotate.nix +++ b/nixos/modules/services/logging/logrotate.nix @@ -5,93 +5,9 @@ with lib; let cfg = config.services.logrotate; - # deprecated legacy compat settings - # these options will be removed before 22.11 in the following PR: - # https://github.com/NixOS/nixpkgs/pull/164169 - pathOpts = { name, ... }: { - options = { - enable = mkOption { - type = types.bool; - default = true; - description = lib.mdDoc '' - Whether to enable log rotation for this path. This can be used to explicitly disable - logging that has been configured by NixOS. - ''; - }; - - name = mkOption { - type = types.str; - internal = true; - }; - - path = mkOption { - type = with types; either str (listOf str); - default = name; - defaultText = "attribute name"; - description = lib.mdDoc '' - The path to log files to be rotated. - Spaces are allowed and normal shell quoting rules apply, - with ', ", and \ characters supported. - ''; - }; - - user = mkOption { - type = with types; nullOr str; - default = null; - description = lib.mdDoc '' - The user account to use for rotation. - ''; - }; - - group = mkOption { - type = with types; nullOr str; - default = null; - description = lib.mdDoc '' - The group to use for rotation. - ''; - }; - - frequency = mkOption { - type = types.enum [ "hourly" "daily" "weekly" "monthly" "yearly" ]; - default = "daily"; - description = lib.mdDoc '' - How often to rotate the logs. - ''; - }; - - keep = mkOption { - type = types.int; - default = 20; - description = lib.mdDoc '' - How many rotations to keep. - ''; - }; - - extraConfig = mkOption { - type = types.lines; - default = ""; - description = lib.mdDoc '' - Extra logrotate config options for this path. Refer to - for details. - ''; - }; - - priority = mkOption { - type = types.int; - default = 1000; - description = lib.mdDoc '' - Order of this logrotate block in relation to the others. The semantics are - the same as with `lib.mkOrder`. Smaller values have a greater priority. - ''; - }; - }; - - config.name = name; - }; - generateLine = n: v: if builtins.elem n [ "files" "priority" "enable" "global" ] || v == null then null - else if builtins.elem n [ "extraConfig" "frequency" ] then "${v}\n" + else if builtins.elem n [ "frequency" ] then "${v}\n" else if builtins.elem n [ "firstaction" "lastaction" "prerotate" "postrotate" "preremove" ] then "${n}\n ${v}\n endscript\n" else if isInt v then "${n} ${toString v}\n" @@ -110,25 +26,6 @@ let ${generateSection 2 settings}} ''; - # below two mapPaths are compat functions - mapPathOptToSetting = n: v: - if n == "keep" then nameValuePair "rotate" v - else if n == "path" then nameValuePair "files" v - else nameValuePair n v; - - mapPathsToSettings = path: pathOpts: - nameValuePair path ( - filterAttrs (n: v: ! builtins.elem n [ "user" "group" "name" ] && v != "") ( - (mapAttrs' mapPathOptToSetting pathOpts) // - { - su = - if pathOpts.user != null - then "${pathOpts.user} ${pathOpts.group}" - else null; - } - ) - ); - settings = sortProperties (attrValues (filterAttrs (_: settings: settings.enable) ( foldAttrs recursiveUpdate { } [ { @@ -139,15 +36,7 @@ let frequency = "weekly"; rotate = 4; }; - # compat section - extraConfig = { - enable = (cfg.extraConfig != ""); - global = true; - extraConfig = cfg.extraConfig; - priority = 101; - }; } - (mapAttrs' mapPathsToSettings cfg.paths) cfg.settings { header = { global = true; priority = 100; }; } ] @@ -200,7 +89,9 @@ let in { imports = [ - (mkRenamedOptionModule [ "services" "logrotate" "config" ] [ "services" "logrotate" "extraConfig" ]) + (mkRemovedOptionModule [ "services" "logrotate" "config" ] "Modify services.logrotate.settings.header instead") + (mkRemovedOptionModule [ "services" "logrotate" "extraConfig" ] "Modify services.logrotate.settings.header instead") + (mkRemovedOptionModule [ "services" "logrotate" "paths" ] "Add attributes to services.logrotate.settings instead") ]; options = { @@ -311,76 +202,10 @@ in in this case you can disable the failing check with this option. ''; }; - - # deprecated legacy compat settings - paths = mkOption { - type = with types; attrsOf (submodule pathOpts); - default = { }; - description = lib.mdDoc '' - Attribute set of paths to rotate. The order each block appears in the generated configuration file - can be controlled by the [priority](#opt-services.logrotate.paths._name_.priority) option - using the same semantics as `lib.mkOrder`. Smaller values have a greater priority. - This setting has been deprecated in favor of [logrotate settings](#opt-services.logrotate.settings). - ''; - example = literalExpression '' - { - httpd = { - path = "/var/log/httpd/*.log"; - user = config.services.httpd.user; - group = config.services.httpd.group; - keep = 7; - }; - - myapp = { - path = "/var/log/myapp/*.log"; - user = "myuser"; - group = "mygroup"; - frequency = "weekly"; - keep = 5; - priority = 1; - }; - } - ''; - }; - - extraConfig = mkOption { - default = ""; - type = types.lines; - description = lib.mdDoc '' - Extra contents to append to the logrotate configuration file. Refer to - for details. - This setting has been deprecated in favor of - [logrotate settings](#opt-services.logrotate.settings). - ''; - }; }; }; config = mkIf cfg.enable { - assertions = - mapAttrsToList - (name: pathOpts: - { - assertion = (pathOpts.user != null) == (pathOpts.group != null); - message = '' - If either of `services.logrotate.paths.${name}.user` or `services.logrotate.paths.${name}.group` are specified then *both* must be specified. - ''; - }) - cfg.paths; - - warnings = - (mapAttrsToList - (name: pathOpts: '' - Using config.services.logrotate.paths.${name} is deprecated and will become unsupported in a future release. - Please use services.logrotate.settings instead. - '') - cfg.paths - ) ++ - (optional (cfg.extraConfig != "") '' - Using config.services.logrotate.extraConfig is deprecated and will become unsupported in a future release. - Please use services.logrotate.settings with globals=true instead. - ''); - systemd.services.logrotate = { description = "Logrotate Service"; startAt = "hourly"; diff --git a/nixos/modules/services/misc/gitlab.nix b/nixos/modules/services/misc/gitlab.nix index 4988517a9b66..13453d9cc785 100644 --- a/nixos/modules/services/misc/gitlab.nix +++ b/nixos/modules/services/misc/gitlab.nix @@ -260,6 +260,7 @@ in { (mkRenamedOptionModule [ "services" "gitlab" "stateDir" ] [ "services" "gitlab" "statePath" ]) (mkRenamedOptionModule [ "services" "gitlab" "backupPath" ] [ "services" "gitlab" "backup" "path" ]) (mkRemovedOptionModule [ "services" "gitlab" "satelliteDir" ] "") + (mkRemovedOptionModule [ "services" "gitlab" "logrotate" "extraConfig" ] "Modify services.logrotate.settings.gitlab directly instead") ]; options = { @@ -871,15 +872,6 @@ in { default = 30; description = lib.mdDoc "How many rotations to keep."; }; - - extraConfig = mkOption { - type = types.lines; - default = ""; - description = lib.mdDoc '' - Extra logrotate config options for this path. Refer to - for details. - ''; - }; }; workhorse.config = mkOption { @@ -1042,7 +1034,6 @@ in { rotate = cfg.logrotate.keep; copytruncate = true; compress = true; - extraConfig = cfg.logrotate.extraConfig; }; }; }; diff --git a/nixos/tests/logrotate.nix b/nixos/tests/logrotate.nix index b0685f3af9ff..94f6ad5103fb 100644 --- a/nixos/tests/logrotate.nix +++ b/nixos/tests/logrotate.nix @@ -64,29 +64,6 @@ import ./make-test-python.nix ({ pkgs, ... }: rec { notifempty = true; }; }; - # extraConfig compatibility - should be added to top level, early. - services.logrotate.extraConfig = '' - nomail - ''; - # paths compatibility - services.logrotate.paths = { - compat_path = { - path = "compat_test_path"; - }; - # user/group should be grouped as 'su user group' - compat_user = { - user = config.users.users.root.name; - group = "root"; - }; - # extraConfig in path should be added to block - compat_extraConfig = { - extraConfig = "dateext"; - }; - # keep -> rotate - compat_keep = { - keep = 1; - }; - }; }; }; @@ -127,12 +104,6 @@ import ./make-test-python.nix ({ pkgs, ... }: rec { "sed -ne '/\"postrotate\" {/,/}/p' /tmp/logrotate.conf | grep endscript", "grep '\"file1\"\n\"file2\" {' /tmp/logrotate.conf", "sed -ne '/\"import\" {/,/}/p' /tmp/logrotate.conf | grep noolddir", - "sed -ne '1,/^\"/p' /tmp/logrotate.conf | grep nomail", - "grep '\"compat_test_path\" {' /tmp/logrotate.conf", - "sed -ne '/\"compat_user\" {/,/}/p' /tmp/logrotate.conf | grep 'su root root'", - "sed -ne '/\"compat_extraConfig\" {/,/}/p' /tmp/logrotate.conf | grep dateext", - "[[ $(sed -ne '/\"compat_keep\" {/,/}/p' /tmp/logrotate.conf | grep -w rotate) = \" rotate 1\" ]]", - "! sed -ne '/\"compat_keep\" {/,/}/p' /tmp/logrotate.conf | grep -w keep", ) # also check configFile option failingMachine.succeed(