anchor.diff:  
     sddm = pkgs.libsForQt5.sddm;
   
  -  xserverWrapper = pkgs.writeScript "xserver-wrapper" ''
  -    #!/bin/sh
  +  iniFmt = pkgs.formats.ini { };
  +
  +  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} "$@"
     '';
   
  -  Xsetup = pkgs.writeScript "Xsetup" ''
  -    #!/bin/sh
  +  Xsetup = pkgs.writeShellScript "Xsetup" ''
       ${cfg.setupScript}
       ${dmcfg.setupCommands}
     '';
   
  -  Xstop = pkgs.writeScript "Xstop" ''
  -    #!/bin/sh
  +  Xstop = pkgs.writeShellScript "Xstop" ''
       ${cfg.stopScript}
     '';
   
  -  cfgFile = pkgs.writeText "sddm.conf" ''
  -    [General]
  -    HaltCommand=/run/current-system/systemd/bin/systemctl poweroff
  -    RebootCommand=/run/current-system/systemd/bin/systemctl reboot
  -    ${optionalString cfg.autoNumlock ''
  -    Numlock=on
  -    ''}
  -
  -    [Theme]
  -    Current=${cfg.theme}
  -    ThemeDir=/run/current-system/sw/share/sddm/themes
  -    FacesDir=/run/current-system/sw/share/sddm/faces
  -
  -    [Users]
  -    MaximumUid=${toString config.ids.uids.nixbld}
  -    HideUsers=${concatStringsSep "," dmcfg.hiddenUsers}
  -    HideShells=/run/current-system/sw/bin/nologin
  -
  -    [X11]
  -    MinimumVT=${toString (if xcfg.tty != null then xcfg.tty else 7)}
  -    ServerPath=${xserverWrapper}
  -    XephyrPath=${pkgs.xorg.xorgserver.out}/bin/Xephyr
  -    SessionCommand=${dmcfg.sessionData.wrapper}
  -    SessionDir=${dmcfg.sessionData.desktops}/share/xsessions
  -    XauthPath=${pkgs.xorg.xauth}/bin/xauth
  -    DisplayCommand=${Xsetup}
  -    DisplayStopCommand=${Xstop}
  -    EnableHidpi=${boolToString cfg.enableHidpi}
  -
  -    [Wayland]
  -    EnableHidpi=${boolToString cfg.enableHidpi}
  -    SessionDir=${dmcfg.sessionData.desktops}/share/wayland-sessions
  -
  -    ${optionalString dmcfg.autoLogin.enable ''
  -    [Autologin]
  -    User=${dmcfg.autoLogin.user}
  -    Session=${autoLoginSessionName}.desktop
  -    Relogin=${boolToString cfg.autoLogin.relogin}
  -    ''}
  -
  -    ${cfg.extraConfig}
  -  '';
  -
  -  autoLoginSessionName = dmcfg.sessionData.autologinSession;
  +  defaultConfig = {
  +    General = {
  +      HaltCommand = "/run/current-system/systemd/bin/systemctl poweroff";
  +      RebootCommand = "/run/current-system/systemd/bin/systemctl reboot";
  +      Numlock = if cfg.autoNumlock then "on" else "none"; # on, off none
  +    };
  +
  +    Theme = {
  +      Current = cfg.theme;
  +      ThemeDir = "/run/current-system/sw/share/sddm/themes";
  +      FacesDir = "/run/current-system/sw/share/sddm/faces";
  +    };
  +
  +    Users = {
  +      MaximumUid = config.ids.uids.nixbld;
  +      HideUsers = concatStringsSep "," dmcfg.hiddenUsers;
  +      HideShells = "/run/current-system/sw/bin/nologin";
  +    };
  +
  +    X11 = {
  +      MinimumVT = if xcfg.tty != null then xcfg.tty else 7;
  +      ServerPath = toString xserverWrapper;
  +      XephyrPath = "${pkgs.xorg.xorgserver.out}/bin/Xephyr";
  +      SessionCommand = toString dmcfg.sessionData.wrapper;
  +      SessionDir = "${dmcfg.sessionData.desktops}/share/xsessions";
  +      XauthPath = "${pkgs.xorg.xauth}/bin/xauth";
  +      DisplayCommand = toString Xsetup;
  +      DisplayStopCommand = toString Xstop;
  +      EnableHiDPI = cfg.enableHidpi;
  +    };
  +
  +    Wayland = {
  +      EnableHiDPI = cfg.enableHidpi;
  +      SessionDir = "${dmcfg.sessionData.desktops}/share/wayland-sessions";
  +    };
  +  } // lib.optionalAttrs dmcfg.autoLogin.enable {
  +    Autologin = {
  +      User = dmcfg.autoLogin.user;
  +      Session = autoLoginSessionName;
  +      Relogin = cfg.autoLogin.relogin;
  +    };
  +  };
  +
  +  cfgFile =
  +    iniFmt.generate "sddm.conf" (lib.recursiveUpdate defaultConfig cfg.settings);
  +
  +  autoLoginSessionName =
  +    "${dmcfg.sessionData.autologinSession}.desktop";
   
   in
   {
     imports = [
  -    (mkRemovedOptionModule [ "services" "xserver" "displayManager" "sddm" "themes" ]
  +    (mkRemovedOptionModule
  +      [ "services" "xserver" "displayManager" "sddm" "themes" ]
         "Set the option `services.xserver.displayManager.sddm.package' instead.")
  -    (mkRenamedOptionModule [ "services" "xserver" "displayManager" "sddm" "autoLogin" "enable" ] [
  -      "services"
  -      "xserver"
  -      "displayManager"
  -      "autoLogin"
  -      "enable"
  -    ])
  -    (mkRenamedOptionModule [ "services" "xserver" "displayManager" "sddm" "autoLogin" "user" ] [
  -      "services"
  -      "xserver"
  -      "displayManager"
  -      "autoLogin"
  -      "user"
  -    ])
  +    (mkRenamedOptionModule
  +      [ "services" "xserver" "displayManager" "sddm" "autoLogin" "enable" ]
  +      [ "services" "xserver" "displayManager" "autoLogin" "enable" ])
  +    (mkRenamedOptionModule
  +      [ "services" "xserver" "displayManager" "sddm" "autoLogin" "user" ]
  +      [ "services" "xserver" "displayManager" "autoLogin" "user" ])
  +    (mkRemovedOptionModule
  +      [ "services" "xserver" "displayManager" "sddm" "extraConfig" ]
  +      "Set the option `services.xserver.displayManager.sddm.settings' instead.")
     ];
   
     options = {
  
positive.code:       };
  
        # Configuration for automatic login specific to SDDM
        autoLogin.relogin = mkOption {
          type = types.bool;
          default = false;
          description = ''
            If true automatic login will kick in again on session exit (logout), otherwise it
            will only log in automatically when the display-manager is started.
          '';
        };
  
      };
  
    };
  
    config = mkIf cfg.enable {
  
      assertions = [
        { assertion = xcfg.enable;
          message = ''
            SDDM requires services.xserver.enable to be true
          '';
        }
        { assertion = dmcfg.autoLogin.enable -> autoLoginSessionName != null;
          message = ''
            SDDM auto-login requires that services.xserver.displayManager.defaultSession is set.
          '';
  
negative.code: { config, lib, pkgs, ... }:
  
  with lib;
  let
    xcfg = config.services.xserver;
    dmcfg = xcfg.displayManager;
    cfg = dmcfg.sddm;
  