summary refs log tree commit diff
diff options
context:
space:
mode:
authorArtturin <Artturin@artturin.com>2021-10-01 02:40:54 +0300
committerArtturin <Artturin@artturin.com>2021-10-01 20:53:49 +0300
commit33b7bd2675b8f336224f737fb84e03316ae32e01 (patch)
treea31b619fd0e6bf0ae3e79341ab5d97ee50039e3d
parent786b429ace50ce4c65c42646a57d9ff1589ba76f (diff)
downloadnixpkgs-33b7bd2675b8f336224f737fb84e03316ae32e01.tar
nixpkgs-33b7bd2675b8f336224f737fb84e03316ae32e01.tar.gz
nixpkgs-33b7bd2675b8f336224f737fb84e03316ae32e01.tar.bz2
nixpkgs-33b7bd2675b8f336224f737fb84e03316ae32e01.tar.lz
nixpkgs-33b7bd2675b8f336224f737fb84e03316ae32e01.tar.xz
nixpkgs-33b7bd2675b8f336224f737fb84e03316ae32e01.tar.zst
nixpkgs-33b7bd2675b8f336224f737fb84e03316ae32e01.zip
nixos/gdm: switch to rfc42 style settings
-rw-r--r--nixos/modules/services/x11/display-managers/gdm.nix59
1 files changed, 34 insertions, 25 deletions
diff --git a/nixos/modules/services/x11/display-managers/gdm.nix b/nixos/modules/services/x11/display-managers/gdm.nix
index 3df576038a9..4f57f9abd06 100644
--- a/nixos/modules/services/x11/display-managers/gdm.nix
+++ b/nixos/modules/services/x11/display-managers/gdm.nix
@@ -6,6 +6,8 @@ let
 
   cfg = config.services.xserver.displayManager;
   gdm = pkgs.gnome.gdm;
+  settingsFormat = pkgs.formats.ini { };
+  configFile = settingsFormat.generate "custom.conf" cfg.gdm.settings;
 
   xSessionWrapper = if (cfg.setupCommands == "") then null else
     pkgs.writeScript "gdm-x-session-wrapper" ''
@@ -105,6 +107,18 @@ in
         type = types.bool;
       };
 
+      settings = mkOption {
+        type = settingsFormat.type;
+        default = { };
+        example = {
+          debug.enable = true;
+        };
+        description = ''
+          Options passed to the gdm daemon.
+          See <link xlink:href="https://help.gnome.org/admin/gdm/stable/configuration.html.en#daemonconfig">here</link> for supported options.
+        '';
+      };
+
     };
 
   };
@@ -270,31 +284,26 @@ in
     # Use AutomaticLogin if delay is zero, because it's immediate.
     # Otherwise with TimedLogin with zero seconds the prompt is still
     # presented and there's a little delay.
-    environment.etc."gdm/custom.conf".text = ''
-      [daemon]
-      WaylandEnable=${boolToString cfg.gdm.wayland}
-      ${optionalString cfg.autoLogin.enable (
-        if cfg.gdm.autoLogin.delay > 0 then ''
-          TimedLoginEnable=true
-          TimedLogin=${cfg.autoLogin.user}
-          TimedLoginDelay=${toString cfg.gdm.autoLogin.delay}
-        '' else ''
-          AutomaticLoginEnable=true
-          AutomaticLogin=${cfg.autoLogin.user}
-        '')
-      }
-
-      [security]
-
-      [xdmcp]
-
-      [greeter]
-
-      [chooser]
-
-      [debug]
-      ${optionalString cfg.gdm.debug "Enable=true"}
-    '';
+    services.xserver.displayManager.gdm.settings = {
+      daemon = mkMerge [
+        { WaylandEnable = cfg.gdm.wayland; }
+        # nested if else didn't work
+        (mkIf (cfg.autoLogin.enable && cfg.gdm.autoLogin.delay != 0 ) {
+          TimedLoginEnable = true;
+          TimedLogin = cfg.autoLogin.user;
+          TimedLoginDelay = cfg.gdm.autoLogin.delay;
+        })
+        (mkIf (cfg.autoLogin.enable && cfg.gdm.autoLogin.delay == 0 ) {
+          AutomaticLoginEnable = true;
+          AutomaticLogin = cfg.autoLogin.user;
+        })
+      ];
+      debug = mkIf cfg.gdm.debug {
+        Enable = true;
+      };
+    };
+
+    environment.etc."gdm/custom.conf".source = configFile;
 
     environment.etc."gdm/Xsession".source = config.services.xserver.displayManager.sessionData.wrapper;