From 897933fc9eacb221f3b0ec0f469ab199b4bb9d1d Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Sun, 20 Jul 2025 11:05:51 +0200 Subject: [PATCH] nixos/systemd: move systemd.managerEnvironment to systemd.settings.Manager.ManagerEnvironment --- nixos/modules/system/boot/systemd.nix | 54 ++++++++++++++------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index fbdf963ead18..e8d4edc44397 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -386,26 +386,6 @@ in ''; }; - managerEnvironment = mkOption { - type = - with types; - attrsOf ( - nullOr (oneOf [ - str - path - package - ]) - ); - default = { }; - example = { - SYSTEMD_LOG_LEVEL = "debug"; - }; - description = '' - Environment variables of PID 1. These variables are - *not* passed to started units. - ''; - }; - enableCgroupAccounting = mkOption { default = true; type = types.bool; @@ -424,6 +404,29 @@ in ''; type = lib.types.submodule { freeformType = types.attrsOf unitOption; + options = { + ManagerEnvironment = mkOption { + type = + with types; + attrsOf ( + nullOr (oneOf [ + str + path + package + ]) + ); + default = { }; + example = { + SYSTEMD_LOG_LEVEL = "debug"; + }; + description = '' + Environment variables of PID 1. These variables are + *not* passed to started units. + ''; + apply = + env: lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${lib.escapeShellArg v}") env); + }; + }; }; example = { WatchdogDevice = "/dev/watchdog"; @@ -652,11 +655,6 @@ in "systemd/system.conf".text = '' [Manager] - ManagerEnvironment=${ - lib.concatStringsSep " " ( - lib.mapAttrsToList (n: v: "${n}=${lib.escapeShellArg v}") cfg.managerEnvironment - ) - } ${optionalString cfg.enableCgroupAccounting '' DefaultCPUAccounting=yes DefaultIOAccounting=yes @@ -747,7 +745,7 @@ in // listToAttrs (map (withName automountToUnit) cfg.automounts); # Environment of PID 1 - systemd.managerEnvironment = { + systemd.settings.Manager.ManagerEnvironment = { # Doesn't contain systemd itself - everything works so it seems to use the compiled-in value for its tools # util-linux is needed for the main fsck utility wrapping the fs-specific ones PATH = lib.makeBinPath ( @@ -873,5 +871,9 @@ in NixOS does not officially support this configuration and might cause your system to be unbootable in future versions. You are on your own. '') (mkRemovedOptionModule [ "systemd" "extraConfig" ] "Use systemd.settings.Manager instead.") + (lib.mkRenamedOptionModule + [ "systemd" "managerEnvironment" ] + [ "systemd" "settings.Manager" "ManagerEnvironment" ] + ) ]; }