nixos/systemd: make systemd.managerEnvironment affect systemd.settings.Manager

This commit is contained in:
Grimmauld
2025-07-20 16:56:38 +02:00
parent 897933fc9e
commit 4d3ab0e8d3

View File

@@ -386,6 +386,26 @@ 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;
@@ -404,29 +424,6 @@ 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";
@@ -745,7 +742,7 @@ in
// listToAttrs (map (withName automountToUnit) cfg.automounts);
# Environment of PID 1
systemd.settings.Manager.ManagerEnvironment = {
systemd.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 (
@@ -761,6 +758,9 @@ in
config.boot.extraSystemdUnitPaths != [ ]
) "${builtins.concatStringsSep ":" config.boot.extraSystemdUnitPaths}:";
};
systemd.settings.Manager.ManagerEnvironment = lib.concatStringsSep " " (
lib.mapAttrsToList (n: v: "${n}=${lib.escapeShellArg v}") cfg.managerEnvironment
);
system.requiredKernelConfig = map config.lib.kernelConfig.isEnabled [
"DEVTMPFS"
@@ -871,9 +871,5 @@ 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" ]
)
];
}