nixos/systemd: introduce settingsToSections util, migrate existing rfc42 options to use settingsToSections, migrate oomd to rfc42 (#437477)
This commit is contained in:
@@ -24,7 +24,7 @@ let
|
||||
mountToUnit
|
||||
automountToUnit
|
||||
sliceToUnit
|
||||
attrsToSection
|
||||
settingsToSections
|
||||
;
|
||||
|
||||
upstreamSystemUnits = [
|
||||
@@ -599,10 +599,7 @@ in
|
||||
upstreamWants = upstreamSystemWants;
|
||||
};
|
||||
|
||||
"systemd/system.conf".text = ''
|
||||
[Manager]
|
||||
${attrsToSection cfg.settings.Manager}
|
||||
'';
|
||||
"systemd/system.conf".text = settingsToSections cfg.settings;
|
||||
|
||||
"systemd/sleep.conf".text = ''
|
||||
[Sleep]
|
||||
|
||||
@@ -22,7 +22,7 @@ let
|
||||
timerToUnit
|
||||
mountToUnit
|
||||
automountToUnit
|
||||
attrsToSection
|
||||
settingsToSections
|
||||
;
|
||||
|
||||
cfg = config.boot.initrd.systemd;
|
||||
@@ -484,10 +484,7 @@ in
|
||||
"/init".source = "${cfg.package}/lib/systemd/systemd";
|
||||
"/etc/systemd/system".source = stage1Units;
|
||||
|
||||
"/etc/systemd/system.conf".text = ''
|
||||
[Manager]
|
||||
${attrsToSection cfg.settings.Manager}
|
||||
'';
|
||||
"/etc/systemd/system.conf".text = settingsToSections cfg.settings;
|
||||
|
||||
# We can use either ! or * to lock the root account in the
|
||||
# console, but some software like OpenSSH won't even allow you
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
utils,
|
||||
...
|
||||
}:
|
||||
@@ -62,10 +61,8 @@
|
||||
"user-runtime-dir@.service"
|
||||
];
|
||||
|
||||
environment.etc."systemd/logind.conf".text = ''
|
||||
[Login]
|
||||
${utils.systemdUtils.lib.attrsToSection config.services.logind.settings.Login}
|
||||
'';
|
||||
environment.etc."systemd/logind.conf".text =
|
||||
utils.systemdUtils.lib.settingsToSections config.services.logind.settings;
|
||||
|
||||
# Restarting systemd-logind breaks X11
|
||||
# - upstream commit: https://cgit.freedesktop.org/xorg/xserver/commit/?id=dc48bd653c7e101
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
{ config, lib, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
utils,
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
||||
cfg = config.systemd.oomd;
|
||||
@@ -10,6 +15,7 @@ in
|
||||
[ "systemd" "oomd" "enableUserServices" ]
|
||||
[ "systemd" "oomd" "enableUserSlices" ]
|
||||
)
|
||||
(lib.mkRenamedOptionModule [ "systemd" "oomd" "extraConfig" ] [ "systemd" "oomd" "settings" "OOM" ])
|
||||
];
|
||||
|
||||
options.systemd.oomd = {
|
||||
@@ -23,20 +29,18 @@ in
|
||||
enableSystemSlice = lib.mkEnableOption "oomd on the system slice (`system.slice`)";
|
||||
enableUserSlices = lib.mkEnableOption "oomd on all user slices (`user@.slice`) and all user owned slices";
|
||||
|
||||
extraConfig = lib.mkOption {
|
||||
type =
|
||||
with lib.types;
|
||||
attrsOf (oneOf [
|
||||
str
|
||||
int
|
||||
bool
|
||||
]);
|
||||
default = { };
|
||||
example = lib.literalExpression ''{ DefaultMemoryPressureDurationSec = "20s"; }'';
|
||||
settings.OOM = lib.mkOption {
|
||||
description = ''
|
||||
Extra config options for `systemd-oomd`. See {command}`man oomd.conf`
|
||||
for available options.
|
||||
Settings option for systemd-oomd.
|
||||
See {manpage}`oomd.conf(5)` for available options.
|
||||
'';
|
||||
type = lib.types.submodule {
|
||||
freeformType = lib.types.attrsOf utils.systemdUtils.unitOptions.unitOption;
|
||||
};
|
||||
default = { };
|
||||
example = {
|
||||
DefaultMemoryPressureLimit = "60%";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -52,11 +56,7 @@ in
|
||||
];
|
||||
systemd.services.systemd-oomd.wantedBy = [ "multi-user.target" ];
|
||||
|
||||
environment.etc."systemd/oomd.conf".text = lib.generators.toINI { } {
|
||||
OOM = cfg.extraConfig;
|
||||
};
|
||||
|
||||
systemd.oomd.extraConfig.DefaultMemoryPressureDurationSec = lib.mkDefault "20s"; # Fedora default
|
||||
environment.etc."systemd/oomd.conf".text = utils.systemdUtils.lib.settingsToSections cfg.settings;
|
||||
|
||||
users.users.systemd-oom = {
|
||||
description = "systemd-oomd service user";
|
||||
|
||||
Reference in New Issue
Block a user