Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/sddm: add support for kwin_wayland #295839

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nixos/modules/services/desktop-managers/plasma6.nix
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ in {
services.xserver.displayManager.sddm = {
package = kdePackages.sddm;
theme = mkDefault "breeze";
wayland.compositor = "kwin";
extraPackages = with kdePackages; [
breeze-icons
kirigami
Expand Down
131 changes: 87 additions & 44 deletions nixos/modules/services/x11/display-managers/sddm.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
{ config, lib, pkgs, ... }:

with lib;
let
xcfg = config.services.xserver;
dmcfg = xcfg.displayManager;
cfg = dmcfg.sddm;
xEnv = config.systemd.services.display-manager.environment;

sddm = cfg.package.override(old: {
sddm = cfg.package.override (old: {
withWayland = cfg.wayland.enable;
extraPackages = old.extraPackages or [] ++ cfg.extraPackages;
extraPackages = old.extraPackages or [ ] ++ cfg.extraPackages;
});

iniFmt = pkgs.formats.ini { };

inherit (lib)
concatMapStrings concatStringsSep getExe
attrNames getAttr optionalAttrs optionalString
mkRemovedOptionModule mkRenamedOptionModule mkIf mkEnableOption mkOption mkPackageOption types
;

xserverWrapper = pkgs.writeShellScript "xserver-wrapper" ''
${concatMapStrings (n: "export ${n}=\"${getAttr n xEnv}\"\n") (attrNames xEnv)}
exec systemd-cat -t xserver-wrapper ${dmcfg.xserverBin} ${toString dmcfg.xserverArgs} "$@"
Expand All @@ -38,12 +43,21 @@ let
DefaultSession = optionalString (dmcfg.defaultSession != null) "${dmcfg.defaultSession}.desktop";

DisplayServer = if cfg.wayland.enable then "wayland" else "x11";
} // optionalAttrs (cfg.wayland.compositor == "kwin") {
GreeterEnvironment = concatStringsSep " " [
"LANG=C.UTF-8"
"QT_WAYLAND_SHELL_INTEGRATION=layer-shell"
];
InputMethod = ""; # needed if we are using --inputmethod with kwin
};

Theme = {
Current = cfg.theme;
ThemeDir = "/run/current-system/sw/share/sddm/themes";
FacesDir = "/run/current-system/sw/share/sddm/faces";
} // optionalAttrs (cfg.theme == "breeze") {
CursorTheme = "breeze_cursors";
CursorSize = 24;
};

Users = {
Expand All @@ -69,7 +83,7 @@ let
SessionDir = "${dmcfg.sessionData.desktops}/share/wayland-sessions";
CompositorCommand = lib.optionalString cfg.wayland.enable cfg.wayland.compositorCommand;
};
} // lib.optionalAttrs dmcfg.autoLogin.enable {
} // optionalAttrs dmcfg.autoLogin.enable {
Autologin = {
User = dmcfg.autoLogin.user;
Session = autoLoginSessionName;
Expand All @@ -83,6 +97,34 @@ let
autoLoginSessionName =
"${dmcfg.sessionData.autologinSession}.desktop";

compositorCmds = {
kwin = concatStringsSep " " [
"${lib.getBin pkgs.kdePackages.kwin}/bin/kwin_wayland"
"--no-global-shortcuts"
"--no-kactivities"
"--no-lockscreen"
"--locale1"
];
# This is basically the upstream default, but with Weston referenced by full path
# and the configuration generated from NixOS options.
weston =
let
westonIni = (pkgs.formats.ini { }).generate "weston.ini" {
libinput = {
enable-tap = xcfg.libinput.mouse.tapping;
left-handed = xcfg.libinput.mouse.leftHanded;
};
keyboard = {
keymap_model = xcfg.xkb.model;
keymap_layout = xcfg.xkb.layout;
keymap_variant = xcfg.xkb.variant;
keymap_options = xcfg.xkb.options;
};
};
in
"${getExe pkgs.weston} --shell=kiosk -c ${westonIni}";
};

in
{
imports = [
Expand Down Expand Up @@ -111,7 +153,7 @@ in
'';
};

package = mkPackageOption pkgs [ "plasma5Packages" "sddm" ] {};
package = mkPackageOption pkgs [ "plasma5Packages" "sddm" ] { };

enableHidpi = mkOption {
type = types.bool;
Expand Down Expand Up @@ -145,7 +187,7 @@ in

extraPackages = mkOption {
type = types.listOf types.package;
default = [];
default = [ ];
defaultText = "[]";
description = lib.mdDoc ''
Extra Qt plugins / QML libraries to add to the environment.
Expand Down Expand Up @@ -206,24 +248,16 @@ in
wayland = {
enable = mkEnableOption "experimental Wayland support";

compositor = mkOption {
description = lib.mdDoc "The compositor to use: ${lib.concatStringsSep ", " (builtins.attrNames compositorCmds)}";
type = types.enum (builtins.attrNames compositorCmds);
default = "weston";
};

compositorCommand = mkOption {
type = types.str;
internal = true;

# This is basically the upstream default, but with Weston referenced by full path
# and the configuration generated from NixOS options.
default = let westonIni = (pkgs.formats.ini {}).generate "weston.ini" {
libinput = {
enable-tap = xcfg.libinput.mouse.tapping;
left-handed = xcfg.libinput.mouse.leftHanded;
};
keyboard = {
keymap_model = xcfg.xkb.model;
keymap_layout = xcfg.xkb.layout;
keymap_variant = xcfg.xkb.variant;
keymap_options = xcfg.xkb.options;
};
}; in "${pkgs.weston}/bin/weston --shell=kiosk -c ${westonIni}";
default = compositorCmds.${cfg.wayland.compositor};
description = lib.mdDoc "Command used to start the selected compositor";
};
};
Expand All @@ -247,8 +281,6 @@ in
}
];

services.xserver.displayManager.job.execCmd = "exec /run/current-system/sw/bin/sddm";

security.pam.services = {
sddm.text = ''
auth substack login
Expand Down Expand Up @@ -293,30 +325,41 @@ in
uid = config.ids.uids.sddm;
};

environment.etc."sddm.conf".source = cfgFile;
environment.pathsToLink = [
"/share/sddm"
];
environment = {
etc."sddm.conf".source = cfgFile;
pathsToLink = [
"/share/sddm"
];
systemPackages = [ sddm ];
};

users.groups.sddm.gid = config.ids.gids.sddm;

environment.systemPackages = [ sddm ];
services.dbus.packages = [ sddm ];
systemd.tmpfiles.packages = [ sddm ];

# We're not using the upstream unit, so copy these: https://github.com/sddm/sddm/blob/develop/services/sddm.service.in
systemd.services.display-manager.after = [
"systemd-user-sessions.service"
"getty@tty7.service"
"plymouth-quit.service"
"systemd-logind.service"
];
systemd.services.display-manager.conflicts = [
"getty@tty7.service"
];
services = {
dbus.packages = [ sddm ];
xserver = {
displayManager.job.execCmd = "exec /run/current-system/sw/bin/sddm";
# To enable user switching, allow sddm to allocate TTYs/displays dynamically.
tty = null;
display = null;
};
};

# To enable user switching, allow sddm to allocate TTYs/displays dynamically.
services.xserver.tty = null;
services.xserver.display = null;
systemd = {
tmpfiles.packages = [ sddm ];

# We're not using the upstream unit, so copy these: https://github.com/sddm/sddm/blob/develop/services/sddm.service.in
services.display-manager = {
after = [
"systemd-user-sessions.service"
"getty@tty7.service"
"plymouth-quit.service"
"systemd-logind.service"
];
conflicts = [
"getty@tty7.service"
];
};
};
};
}