From db5b08cfaf88568e815af6c8a9a3e60122a5f3d8 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Mon, 2 Mar 2015 20:58:35 +0300 Subject: [PATCH] nixos/sddm: add display manager --- nixos/modules/misc/ids.nix | 2 + nixos/modules/module-list.nix | 1 + .../services/x11/display-managers/sddm.nix | 108 ++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 nixos/modules/services/x11/display-managers/sddm.nix diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index bd0c0bef8b62..158609dcf793 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -180,6 +180,7 @@ panamax = 170; marathon = 171; exim = 172; + sddm = 175; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! @@ -322,6 +323,7 @@ exim = 172; fleet = 173; input = 174; + sddm = 175; # When adding a gid, make sure it doesn't match an existing # uid. Users and groups with the same name should have equal diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 516d35137c58..ef1e9d450c86 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -359,6 +359,7 @@ ./services/x11/display-managers/gdm.nix ./services/x11/display-managers/kdm.nix ./services/x11/display-managers/lightdm.nix + ./services/x11/display-managers/sddm.nix ./services/x11/display-managers/slim.nix ./services/x11/hardware/multitouch.nix ./services/x11/hardware/synaptics.nix diff --git a/nixos/modules/services/x11/display-managers/sddm.nix b/nixos/modules/services/x11/display-managers/sddm.nix new file mode 100644 index 000000000000..020e87950455 --- /dev/null +++ b/nixos/modules/services/x11/display-managers/sddm.nix @@ -0,0 +1,108 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + xcfg = config.services.xserver; + dmcfg = xcfg.displayManager; + cfg = dmcfg.sddm; + xEnv = config.systemd.services."display-manager".environment; + + xserverWrapper = pkgs.writeScript "xserver-wrapper" '' + #!/bin/sh + ${concatMapStrings (n: "export ${n}=\"${getAttr n xEnv}\"\n") (attrNames xEnv)} + exec ${dmcfg.xserverBin} ${dmcfg.xserverArgs} "$@" + ''; + + cfgFile = pkgs.writeText "sddm.conf" '' + [General] + HaltCommand=${pkgs.systemd}/bin/systemctl poweroff + RebootCommand=${pkgs.systemd}/bin/systemctl reboot + + [Theme] + Current=${cfg.theme} + + [Users] + MaximumUid=${toString config.ids.uids.nixbld} + + [XDisplay] + MinimumVT=${toString xcfg.tty} + ServerPath=${xserverWrapper} + XephyrPath=${pkgs.xorg.xorgserver}/bin/Xephyr + SessionCommand=${dmcfg.session.script} + SessionDir=${dmcfg.session.desktops} + XauthPath=${pkgs.xorg.xauth}/bin/xauth + ''; + +in +{ + options = { + + services.xserver.displayManager.sddm = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable sddm as the display manager. + ''; + }; + + theme = mkOption { + type = types.str; + default = "maui"; + description = '' + Greeter theme to use. + ''; + }; + }; + + }; + + config = mkIf cfg.enable { + + services.xserver.displayManager.slim.enable = false; + + services.xserver.displayManager.job = { + logsXsession = true; + + #execCmd = "${pkgs.sddm}/bin/sddm"; + execCmd = "exec ${pkgs.sddm}/bin/sddm"; + }; + + security.pam.services = { + sddm = { + allowNullPassword = true; + startSession = true; + }; + + sddm-greeter.text = '' + auth required pam_succeed_if.so audit quiet_success user = sddm + auth optional pam_permit.so + + account required pam_succeed_if.so audit quiet_success user = sddm + account sufficient pam_unix.so + + password required pam_deny.so + + session required pam_succeed_if.so audit quiet_success user = sddm + session required pam_env.so envfile=${config.system.build.pamEnvironment} + session optional ${pkgs.systemd}/lib/security/pam_systemd.so + session optional pam_keyinit.so force revoke + session optional pam_permit.so + ''; + }; + + users.extraUsers.sddm = { + createHome = true; + home = "/var/lib/sddm"; + group = "sddm"; + uid = config.ids.uids.sddm; + }; + + environment.etc."sddm.conf".source = cfgFile; + + users.extraGroups.sddm.gid = config.ids.gids.sddm; + + }; +}