anchor.diff:        };
   
         # 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.
  -        '';
  -      };
  -
  -    };
  -
  +      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.
  +          '';
  +        };
  +
  +        minimumUid = mkOption {
  +          type = types.ints.u16;
  +          default = 1000;
  +          description = ''
  +            Minimum user ID for auto-login user.
  +          '';
  +        };
  +      };
  +    };
     };
   
     config = mkIf cfg.enable {
   
       assertions = [
  -      { assertion = xcfg.enable;
  +      {
  +        assertion = xcfg.enable;
           message = ''
             SDDM requires services.xserver.enable to be true
           '';
         }
  -      { assertion = dmcfg.autoLogin.enable -> autoLoginSessionName != null;
  +      {
  +        assertion = dmcfg.autoLogin.enable -> autoLoginSessionName != null;
           message = ''
             SDDM auto-login requires that services.xserver.displayManager.defaultSession is set.
           '';
  
positive.code: { config, lib, pkgs, ... }:
  
  with lib;
  
  let
  
    xcfg = config.services.xserver;
    dmcfg = xcfg.displayManager;
    cfg = dmcfg.sddm;
  
negative.code: 
    sddm = pkgs.libsForQt5.sddm;
  
    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.writeShellScript "Xsetup" ''
      ${cfg.setupScript}
      ${dmcfg.setupCommands}
    '';
  
    Xstop = pkgs.writeShellScript "Xstop" ''
      ${cfg.stopScript}
    '';
  
    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" ]
        "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" ])
      (mkRemovedOptionModule
        [ "services" "xserver" "displayManager" "sddm" "extraConfig" ]
        "Set the option `services.xserver.displayManager.sddm.settings' instead.")
    ];
  
    options = {
  