lol

nixos/displayManager: make autoLogin options independent of DM type

Co-authored-by: volth <volth@volth.com>

+145 -155
+1 -2
nixos/doc/manual/configuration/profiles/demo.xml
··· 9 9 This profile just enables a <systemitem class="username">demo</systemitem> 10 10 user, with password <literal>demo</literal>, uid <literal>1000</literal>, 11 11 <systemitem class="groupname">wheel</systemitem> group and 12 - <link linkend="opt-services.xserver.displayManager.sddm.autoLogin"> autologin 13 - in the SDDM display manager</link>. 12 + <link linkend="opt-services.xserver.displayManager.autoLogin">autologin in the SDDM display manager</link>. 14 13 </para> 15 14 </section>
+2 -3
nixos/doc/manual/configuration/x-windows.xml
··· 90 90 using lightdm for a user <literal>alice</literal>: 91 91 <programlisting> 92 92 <xref linkend="opt-services.xserver.displayManager.lightdm.enable"/> = true; 93 - <xref linkend="opt-services.xserver.displayManager.lightdm.autoLogin.enable"/> = true; 94 - <xref linkend="opt-services.xserver.displayManager.lightdm.autoLogin.user"/> = "alice"; 93 + <xref linkend="opt-services.xserver.displayManager.autoLogin.enable"/> = true; 94 + <xref linkend="opt-services.xserver.displayManager.autoLogin.user"/> = "alice"; 95 95 </programlisting> 96 - The options are named identically for all other display managers. 97 96 </para> 98 97 </simplesect> 99 98 <simplesect xml:id="sec-x11--graphics-cards-intel">
+1 -1
nixos/doc/manual/release-notes/rl-2003.xml
··· 792 792 The <option>services.xserver.displayManager.auto</option> module has been removed. 793 793 It was only intended for use in internal NixOS tests, and gave the false impression 794 794 of it being a special display manager when it's actually LightDM. 795 - Please use the <xref linkend="opt-services.xserver.displayManager.lightdm.autoLogin"/> options instead, 795 + Please use the <option>services.xserver.displayManager.lightdm.autoLogin</option> options instead, 796 796 or any other display manager in NixOS as they all support auto-login. If you used this module specifically 797 797 because it permitted root auto-login you can override the lightdm-autologin pam module like: 798 798 <programlisting>
+6
nixos/doc/manual/release-notes/rl-2009.xml
··· 514 514 automatically if <literal>stateVersion</literal> is 20.09 or higher. 515 515 </para> 516 516 </listitem> 517 + <listitem> 518 + <para> 519 + We now have a unified <xref linkend="opt-services.xserver.displayManager.autoLogin"/> option interface 520 + to be used for every display-manager in NixOS. 521 + </para> 522 + </listitem> 517 523 </itemizedlist> 518 524 </section> 519 525
+11 -9
nixos/modules/installer/cd-dvd/installation-cd-graphical-gnome.nix
··· 11 11 12 12 services.xserver.desktopManager.gnome3.enable = true; 13 13 14 - services.xserver.displayManager.gdm = { 15 - enable = true; 16 - # autoSuspend makes the machine automatically suspend after inactivity. 17 - # It's possible someone could/try to ssh'd into the machine and obviously 18 - # have issues because it's inactive. 19 - # See: 20 - # * https://github.com/NixOS/nixpkgs/pull/63790 21 - # * https://gitlab.gnome.org/GNOME/gnome-control-center/issues/22 22 - autoSuspend = false; 14 + services.xserver.displayManager = { 15 + gdm = { 16 + enable = true; 17 + # autoSuspend makes the machine automatically suspend after inactivity. 18 + # It's possible someone could/try to ssh'd into the machine and obviously 19 + # have issues because it's inactive. 20 + # See: 21 + # * https://github.com/NixOS/nixpkgs/pull/63790 22 + # * https://gitlab.gnome.org/GNOME/gnome-control-center/issues/22 23 + autoSuspend = false; 24 + }; 23 25 autoLogin = { 24 26 enable = true; 25 27 user = "nixos";
+2 -2
nixos/modules/installer/cd-dvd/installation-cd-graphical-plasma5.nix
··· 16 16 }; 17 17 18 18 # Automatically login as nixos. 19 - displayManager.sddm = { 20 - enable = true; 19 + displayManager = { 20 + sddm.enable = true; 21 21 autoLogin = { 22 22 enable = true; 23 23 user = "nixos";
+6 -4
nixos/modules/profiles/demo.nix
··· 11 11 uid = 1000; 12 12 }; 13 13 14 - services.xserver.displayManager.sddm.autoLogin = { 15 - enable = true; 16 - relogin = true; 17 - user = "demo"; 14 + services.xserver.displayManager = { 15 + autoLogin = { 16 + enable = true; 17 + user = "demo"; 18 + }; 19 + sddm.autoLogin.relogin = true; 18 20 }; 19 21 }
+1 -1
nixos/modules/rename.nix
··· 39 39 The services.xserver.displayManager.auto module has been removed 40 40 because it was only intended for use in internal NixOS tests, and gave the 41 41 false impression of it being a special display manager when it's actually 42 - LightDM. Please use the services.xserver.displayManager.lightdm.autoLogin options 42 + LightDM. Please use the services.xserver.displayManager.autoLogin options 43 43 instead, or any other display manager in NixOS as they all support auto-login. 44 44 '') 45 45 (mkRemovedOptionModule [ "services" "dnscrypt-proxy" ] "Use services.dnscrypt-proxy2 instead")
+33
nixos/modules/services/x11/display-managers/default.nix
··· 332 332 333 333 }; 334 334 335 + # Configuration for automatic login. Common for all DM. 336 + autoLogin = mkOption { 337 + type = types.submodule { 338 + options = { 339 + enable = mkOption { 340 + type = types.bool; 341 + default = cfg.displayManager.autoLogin.user != null; 342 + description = '' 343 + Automatically log in as <option>autoLogin.user</option>. 344 + ''; 345 + }; 346 + 347 + user = mkOption { 348 + type = types.nullOr types.str; 349 + default = null; 350 + description = '' 351 + User to be used for the automatic login. 352 + ''; 353 + }; 354 + }; 355 + }; 356 + 357 + default = {}; 358 + description = '' 359 + Auto login configuration attrset. 360 + ''; 361 + }; 362 + 335 363 }; 336 364 337 365 }; 338 366 339 367 config = { 340 368 assertions = [ 369 + { assertion = cfg.displayManager.autoLogin.enable -> cfg.displayManager.autoLogin.user != null; 370 + message = '' 371 + services.xserver.displayManager.autoLogin.enable requires services.xserver.displayManager.autoLogin.user to be set 372 + ''; 373 + } 341 374 { 342 375 assertion = cfg.desktopManager.default != null || cfg.windowManager.default != null -> cfg.displayManager.defaultSession == defaultSessionFromLegacyOptions; 343 376 message = "You cannot use both services.xserver.displayManager.defaultSession option and legacy options (services.xserver.desktopManager.default and services.xserver.windowManager.default).";
+24 -41
nixos/modules/services/x11/display-managers/gdm.nix
··· 37 37 in 38 38 39 39 { 40 + imports = [ 41 + (mkRenamedOptionModule [ "services" "xserver" "displayManager" "gdm" "autoLogin" "enable" ] [ 42 + "services" 43 + "xserver" 44 + "displayManager" 45 + "autoLogin" 46 + "enable" 47 + ]) 48 + (mkRenamedOptionModule [ "services" "xserver" "displayManager" "gdm" "autoLogin" "user" ] [ 49 + "services" 50 + "xserver" 51 + "displayManager" 52 + "autoLogin" 53 + "user" 54 + ]) 55 + ]; 40 56 41 57 meta = { 42 58 maintainers = teams.gnome.members; ··· 56 72 debugging messages in GDM 57 73 ''; 58 74 59 - autoLogin = mkOption { 60 - default = {}; 75 + # Auto login options specific to GDM 76 + autoLogin.delay = mkOption { 77 + type = types.int; 78 + default = 0; 61 79 description = '' 62 - Auto login configuration attrset. 80 + Seconds of inactivity after which the autologin will be performed. 63 81 ''; 64 - 65 - type = types.submodule { 66 - options = { 67 - enable = mkOption { 68 - type = types.bool; 69 - default = false; 70 - description = '' 71 - Automatically log in as the sepecified <option>autoLogin.user</option>. 72 - ''; 73 - }; 74 - 75 - user = mkOption { 76 - type = types.nullOr types.str; 77 - default = null; 78 - description = '' 79 - User to be used for the autologin. 80 - ''; 81 - }; 82 - 83 - delay = mkOption { 84 - type = types.int; 85 - default = 0; 86 - description = '' 87 - Seconds of inactivity after which the autologin will be performed. 88 - ''; 89 - }; 90 - 91 - }; 92 - }; 93 82 }; 94 83 95 84 wayland = mkOption { ··· 127 116 ###### implementation 128 117 129 118 config = mkIf cfg.gdm.enable { 130 - 131 - assertions = [ 132 - { assertion = cfg.gdm.autoLogin.enable -> cfg.gdm.autoLogin.user != null; 133 - message = "GDM auto-login requires services.xserver.displayManager.gdm.autoLogin.user to be set"; 134 - } 135 - ]; 136 119 137 120 services.xserver.displayManager.lightdm.enable = false; 138 121 ··· 287 270 environment.etc."gdm/custom.conf".text = '' 288 271 [daemon] 289 272 WaylandEnable=${if cfg.gdm.wayland then "true" else "false"} 290 - ${optionalString cfg.gdm.autoLogin.enable ( 273 + ${optionalString cfg.autoLogin.enable ( 291 274 if cfg.gdm.autoLogin.delay > 0 then '' 292 275 TimedLoginEnable=true 293 - TimedLogin=${cfg.gdm.autoLogin.user} 276 + TimedLogin=${cfg.autoLogin.user} 294 277 TimedLoginDelay=${toString cfg.gdm.autoLogin.delay} 295 278 '' else '' 296 279 AutomaticLoginEnable=true 297 - AutomaticLogin=${cfg.gdm.autoLogin.user} 280 + AutomaticLogin=${cfg.autoLogin.user} 298 281 '') 299 282 } 300 283
+24 -41
nixos/modules/services/x11/display-managers/lightdm.nix
··· 53 53 ${optionalString cfg.greeter.enable '' 54 54 greeter-session = ${cfg.greeter.name} 55 55 ''} 56 - ${optionalString cfg.autoLogin.enable '' 57 - autologin-user = ${cfg.autoLogin.user} 56 + ${optionalString dmcfg.autoLogin.enable '' 57 + autologin-user = ${dmcfg.autoLogin.user} 58 58 autologin-user-timeout = ${toString cfg.autoLogin.timeout} 59 59 autologin-session = ${sessionData.autologinSession} 60 60 ''} ··· 82 82 ./lightdm-greeters/enso-os.nix 83 83 ./lightdm-greeters/pantheon.nix 84 84 ./lightdm-greeters/tiny.nix 85 + (mkRenamedOptionModule [ "services" "xserver" "displayManager" "lightdm" "autoLogin" "enable" ] [ 86 + "services" 87 + "xserver" 88 + "displayManager" 89 + "autoLogin" 90 + "enable" 91 + ]) 92 + (mkRenamedOptionModule [ "services" "xserver" "displayManager" "lightdm" "autoLogin" "user" ] [ 93 + "services" 94 + "xserver" 95 + "displayManager" 96 + "autoLogin" 97 + "user" 98 + ]) 85 99 ]; 86 100 87 101 options = { ··· 149 163 description = "Extra lines to append to SeatDefaults section."; 150 164 }; 151 165 152 - autoLogin = mkOption { 153 - default = {}; 166 + # Configuration for automatic login specific to LightDM 167 + autoLogin.timeout = mkOption { 168 + type = types.int; 169 + default = 0; 154 170 description = '' 155 - Configuration for automatic login. 171 + Show the greeter for this many seconds before automatic login occurs. 156 172 ''; 157 - 158 - type = types.submodule { 159 - options = { 160 - enable = mkOption { 161 - type = types.bool; 162 - default = false; 163 - description = '' 164 - Automatically log in as the specified <option>autoLogin.user</option>. 165 - ''; 166 - }; 167 - 168 - user = mkOption { 169 - type = types.nullOr types.str; 170 - default = null; 171 - description = '' 172 - User to be used for the automatic login. 173 - ''; 174 - }; 175 - 176 - timeout = mkOption { 177 - type = types.int; 178 - default = 0; 179 - description = '' 180 - Show the greeter for this many seconds before automatic login occurs. 181 - ''; 182 - }; 183 - }; 184 - }; 185 173 }; 186 174 187 175 }; ··· 195 183 LightDM requires services.xserver.enable to be true 196 184 ''; 197 185 } 198 - { assertion = cfg.autoLogin.enable -> cfg.autoLogin.user != null; 199 - message = '' 200 - LightDM auto-login requires services.xserver.displayManager.lightdm.autoLogin.user to be set 201 - ''; 202 - } 203 - { assertion = cfg.autoLogin.enable -> sessionData.autologinSession != null; 186 + { assertion = dmcfg.autoLogin.enable -> sessionData.autologinSession != null; 204 187 message = '' 205 188 LightDM auto-login requires that services.xserver.displayManager.defaultSession is set. 206 189 ''; 207 190 } 208 - { assertion = !cfg.greeter.enable -> (cfg.autoLogin.enable && cfg.autoLogin.timeout == 0); 191 + { assertion = !cfg.greeter.enable -> (dmcfg.autoLogin.enable && cfg.autoLogin.timeout == 0); 209 192 message = '' 210 193 LightDM can only run without greeter if automatic login is enabled and the timeout for it 211 194 is set to zero. ··· 218 201 219 202 # Set default session in session chooser to a specified values – basically ignore session history. 220 203 # Auto-login is already covered by a config value. 221 - services.xserver.displayManager.job.preStart = optionalString (!cfg.autoLogin.enable && dmcfg.defaultSession != null) '' 204 + services.xserver.displayManager.job.preStart = optionalString (!dmcfg.autoLogin.enable && dmcfg.defaultSession != null) '' 222 205 ${setSessionScript}/bin/set-session ${dmcfg.defaultSession} 223 206 ''; 224 207
+23 -40
nixos/modules/services/x11/display-managers/sddm.nix
··· 61 61 EnableHidpi=${if cfg.enableHidpi then "true" else "false"} 62 62 SessionDir=${dmcfg.sessionData.desktops}/share/wayland-sessions 63 63 64 - ${optionalString cfg.autoLogin.enable '' 64 + ${optionalString dmcfg.autoLogin.enable '' 65 65 [Autologin] 66 - User=${cfg.autoLogin.user} 66 + User=${dmcfg.autoLogin.user} 67 67 Session=${autoLoginSessionName}.desktop 68 68 Relogin=${boolToString cfg.autoLogin.relogin} 69 69 ''} ··· 78 78 imports = [ 79 79 (mkRemovedOptionModule [ "services" "xserver" "displayManager" "sddm" "themes" ] 80 80 "Set the option `services.xserver.displayManager.sddm.package' instead.") 81 + (mkRenamedOptionModule [ "services" "xserver" "displayManager" "sddm" "autoLogin" "enable" ] [ 82 + "services" 83 + "xserver" 84 + "displayManager" 85 + "autoLogin" 86 + "enable" 87 + ]) 88 + (mkRenamedOptionModule [ "services" "xserver" "displayManager" "sddm" "autoLogin" "user" ] [ 89 + "services" 90 + "xserver" 91 + "displayManager" 92 + "autoLogin" 93 + "user" 94 + ]) 81 95 ]; 82 96 83 97 options = { ··· 153 167 ''; 154 168 }; 155 169 156 - autoLogin = mkOption { 157 - default = {}; 170 + # Configuration for automatic login specific to SDDM 171 + autoLogin.relogin = mkOption { 172 + type = types.bool; 173 + default = false; 158 174 description = '' 159 - Configuration for automatic login. 175 + If true automatic login will kick in again on session exit (logout), otherwise it 176 + will only log in automatically when the display-manager is started. 160 177 ''; 161 - 162 - type = types.submodule { 163 - options = { 164 - enable = mkOption { 165 - type = types.bool; 166 - default = false; 167 - description = '' 168 - Automatically log in as <option>autoLogin.user</option>. 169 - ''; 170 - }; 171 - 172 - user = mkOption { 173 - type = types.nullOr types.str; 174 - default = null; 175 - description = '' 176 - User to be used for the automatic login. 177 - ''; 178 - }; 179 - 180 - relogin = mkOption { 181 - type = types.bool; 182 - default = false; 183 - description = '' 184 - If true automatic login will kick in again on session exit (logout), otherwise it 185 - will only log in automatically when the display-manager is started. 186 - ''; 187 - }; 188 - }; 189 - }; 190 178 }; 191 179 192 180 }; ··· 201 189 SDDM requires services.xserver.enable to be true 202 190 ''; 203 191 } 204 - { assertion = cfg.autoLogin.enable -> cfg.autoLogin.user != null; 205 - message = '' 206 - SDDM auto-login requires services.xserver.displayManager.sddm.autoLogin.user to be set 207 - ''; 208 - } 209 - { assertion = cfg.autoLogin.enable -> autoLoginSessionName != null; 192 + { assertion = dmcfg.autoLogin.enable -> autoLoginSessionName != null; 210 193 message = '' 211 194 SDDM auto-login requires that services.xserver.displayManager.defaultSession is set. 212 195 '';
+2 -2
nixos/tests/common/auto.nix
··· 41 41 42 42 config = mkIf cfg.enable { 43 43 44 - services.xserver.displayManager.lightdm = { 45 - enable = true; 44 + services.xserver.displayManager = { 45 + lightdm.enable = true; 46 46 autoLogin = { 47 47 enable = true; 48 48 user = cfg.user;
+2 -2
nixos/tests/gnome3-xorg.nix
··· 12 12 13 13 services.xserver.enable = true; 14 14 15 - services.xserver.displayManager.gdm = { 16 - enable = true; 15 + services.xserver.displayManager = { 16 + gdm.enable = true; 17 17 autoLogin = { 18 18 enable = true; 19 19 user = user.name;
+2 -2
nixos/tests/gnome3.nix
··· 11 11 12 12 services.xserver.enable = true; 13 13 14 - services.xserver.displayManager.gdm = { 15 - enable = true; 14 + services.xserver.displayManager = { 15 + gdm.enable = true; 16 16 autoLogin = { 17 17 enable = true; 18 18 user = "alice";
+1 -1
nixos/tests/plasma5.nix
··· 14 14 services.xserver.displayManager.sddm.enable = true; 15 15 services.xserver.displayManager.defaultSession = "plasma5"; 16 16 services.xserver.desktopManager.plasma5.enable = true; 17 - services.xserver.displayManager.sddm.autoLogin = { 17 + services.xserver.displayManager.autoLogin = { 18 18 enable = true; 19 19 user = "alice"; 20 20 };
+2 -2
nixos/tests/sddm.nix
··· 44 44 machine = { ... }: { 45 45 imports = [ ./common/user-account.nix ]; 46 46 services.xserver.enable = true; 47 - services.xserver.displayManager.sddm = { 48 - enable = true; 47 + services.xserver.displayManager = { 48 + sddm.enable = true; 49 49 autoLogin = { 50 50 enable = true; 51 51 user = "alice";
+2 -2
nixos/tests/xfce.nix
··· 11 11 12 12 services.xserver.enable = true; 13 13 14 - services.xserver.displayManager.lightdm = { 15 - enable = true; 14 + services.xserver.displayManager = { 15 + lightdm.enable = true; 16 16 autoLogin = { 17 17 enable = true; 18 18 user = "alice";