From fa6b7ec3d497e2d631b0b3aa52186348d7a94b23 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sat, 4 Oct 2025 11:32:14 +0900 Subject: [PATCH] pkgs-lib/formats/systemd: make format a function --- .../manual/release-notes/rl-2511.section.md | 2 ++ .../system/boot/systemd/journald-remote.nix | 2 +- .../system/boot/systemd/journald-upload.nix | 2 +- pkgs/pkgs-lib/formats.nix | 18 +++++++++++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2511.section.md b/nixos/doc/manual/release-notes/rl-2511.section.md index 7203addaa835..7432221c264c 100644 --- a/nixos/doc/manual/release-notes/rl-2511.section.md +++ b/nixos/doc/manual/release-notes/rl-2511.section.md @@ -253,6 +253,8 @@ - The `boot.readOnlyNixStore` has been removed. Control over bind mount options on `/nix/store` is now offered by the `boot.nixStoreMountOpts` option. +- Direct use of `pkgs.formats.systemd` has been deprecated, and should now be instantiated with `pkgs.formats.systemd { }` similarly to other items in `pkgs.formats`. + - The Postfix module has been updated and likely requires configuration changes: - The `services.postfix.sslCert` and `sslKey` options were removed and you now need to configure - [services.postfix.settings.main.smtpd_tls_chain_files](#opt-services.postfix.settings.main.smtpd_tls_chain_files) for server certificates, diff --git a/nixos/modules/system/boot/systemd/journald-remote.nix b/nixos/modules/system/boot/systemd/journald-remote.nix index 5aeb3c8f1597..89baf421f591 100644 --- a/nixos/modules/system/boot/systemd/journald-remote.nix +++ b/nixos/modules/system/boot/systemd/journald-remote.nix @@ -7,7 +7,7 @@ let cfg = config.services.journald.remote; - format = pkgs.formats.systemd; + format = pkgs.formats.systemd { }; cliArgs = lib.cli.toGNUCommandLineShell { } { inherit (cfg) output; diff --git a/nixos/modules/system/boot/systemd/journald-upload.nix b/nixos/modules/system/boot/systemd/journald-upload.nix index c2437e7aadf8..8cd67918f4f0 100644 --- a/nixos/modules/system/boot/systemd/journald-upload.nix +++ b/nixos/modules/system/boot/systemd/journald-upload.nix @@ -7,7 +7,7 @@ let cfg = config.services.journald.upload; - format = pkgs.formats.systemd; + format = pkgs.formats.systemd { }; in { meta.maintainers = [ lib.maintainers.raitobezarius ]; diff --git a/pkgs/pkgs-lib/formats.nix b/pkgs/pkgs-lib/formats.nix index 58eda45da319..eb1855797f3f 100644 --- a/pkgs/pkgs-lib/formats.nix +++ b/pkgs/pkgs-lib/formats.nix @@ -425,10 +425,22 @@ optionalAttrs allowAliases aliases let mkValueString = mkValueStringDefault { }; mkKeyValue = k: v: if v == null then "# ${k} is unset" else "${k} = ${mkValueString v}"; + + rawFormat = ini { + listsAsDuplicateKeys = true; + inherit mkKeyValue; + }; in - ini { - listsAsDuplicateKeys = true; - inherit mkKeyValue; + rawFormat + // { + generate = + name: value: + lib.warn + "Direct use of `pkgs.formats.systemd` has been deprecated, please use `pkgs.formats.systemd { }` instead." + rawFormat.generate + name + value; + __functor = self: { }: rawFormat; }; keyValue =