nixos/displayManager: replace ad-hoc type // { check } overrides (#525738)

This commit is contained in:
Matt Sturgeon
2026-06-02 17:03:59 +00:00
committed by GitHub

View File

@@ -101,16 +101,7 @@ in
};
defaultSession = lib.mkOption {
type = lib.types.nullOr lib.types.str // {
description = "session name";
check =
d:
lib.assertMsg (d != null -> (lib.types.str.check d && lib.elem d cfg.sessionData.sessionNames)) ''
Default graphical session, '${d}', not found.
Valid names for 'services.displayManager.defaultSession' are:
${lib.concatStringsSep "\n " cfg.sessionData.sessionNames}
'';
};
type = lib.types.nullOr (lib.types.str // { description = "session name"; });
default = null;
example = "gnome";
description = ''
@@ -130,26 +121,12 @@ in
sessionPackages = lib.mkOption {
type = lib.types.listOf (
lib.types.package
lib.types.addCheck lib.types.package (
p: p ? providedSessions && p.providedSessions != [ ] && lib.all lib.isString p.providedSessions
)
// {
description = "package with provided sessions";
check =
p:
lib.assertMsg
(
lib.types.package.check p
&& p ? providedSessions
&& p.providedSessions != [ ]
&& lib.all lib.isString p.providedSessions
)
''
Package, '${p.name}', did not specify any session names, as strings, in
'passthru.providedSessions'. This is required when used as a session package.
The session names can be looked up in:
${p}/share/xsessions
${p}/share/wayland-sessions
'';
descriptionClass = "composite";
}
);
default = [ ];
@@ -211,6 +188,14 @@ in
services.displayManager.autoLogin.enable requires services.displayManager.autoLogin.user to be set
'';
}
{
assertion = cfg.defaultSession == null || lib.elem cfg.defaultSession cfg.sessionData.sessionNames;
message = ''
Default graphical session, '${toString cfg.defaultSession}', not found.
Valid names for 'services.displayManager.defaultSession' are:
${lib.concatStringsSep "\n " cfg.sessionData.sessionNames}
'';
}
];
# Make xsessions and wayland sessions available in XDG_DATA_DIRS