summary refs log tree commit diff
path: root/nixos/modules/services/x11/display-managers/sddm.nix
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2015-03-02 20:58:35 +0300
committerNikolay Amiantov <ab@fmap.me>2015-03-05 20:49:26 +0300
commitdb5b08cfaf88568e815af6c8a9a3e60122a5f3d8 (patch)
tree9b8d91c7ff372c181f8359db08a1543262889341 /nixos/modules/services/x11/display-managers/sddm.nix
parentc532beeb0d0515610b824abd9a1dd995086e8a20 (diff)
downloadnixpkgs-db5b08cfaf88568e815af6c8a9a3e60122a5f3d8.tar
nixpkgs-db5b08cfaf88568e815af6c8a9a3e60122a5f3d8.tar.gz
nixpkgs-db5b08cfaf88568e815af6c8a9a3e60122a5f3d8.tar.bz2
nixpkgs-db5b08cfaf88568e815af6c8a9a3e60122a5f3d8.tar.lz
nixpkgs-db5b08cfaf88568e815af6c8a9a3e60122a5f3d8.tar.xz
nixpkgs-db5b08cfaf88568e815af6c8a9a3e60122a5f3d8.tar.zst
nixpkgs-db5b08cfaf88568e815af6c8a9a3e60122a5f3d8.zip
nixos/sddm: add display manager
Diffstat (limited to 'nixos/modules/services/x11/display-managers/sddm.nix')
-rw-r--r--nixos/modules/services/x11/display-managers/sddm.nix108
1 files changed, 108 insertions, 0 deletions
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 00000000000..020e8795045
--- /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;
+
+  };
+}