about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorworldofpeace <worldofpeace@protonmail.ch>2019-08-06 18:09:20 -0400
committerGitHub <noreply@github.com>2019-08-06 18:09:20 -0400
commita4c6a7b336bc859fab81a3fe926b7468cc46a911 (patch)
tree400417859dbf8d393b62593d9d07b1abb640088e /nixos
parent2ea8d578e069f571365a6acd26cb099bef85a0e6 (diff)
parent7c854aa974670b5ff1f707ad80ff0ccaf1d54b9f (diff)
downloadnixlib-a4c6a7b336bc859fab81a3fe926b7468cc46a911.tar
nixlib-a4c6a7b336bc859fab81a3fe926b7468cc46a911.tar.gz
nixlib-a4c6a7b336bc859fab81a3fe926b7468cc46a911.tar.bz2
nixlib-a4c6a7b336bc859fab81a3fe926b7468cc46a911.tar.lz
nixlib-a4c6a7b336bc859fab81a3fe926b7468cc46a911.tar.xz
nixlib-a4c6a7b336bc859fab81a3fe926b7468cc46a911.tar.zst
nixlib-a4c6a7b336bc859fab81a3fe926b7468cc46a911.zip
Merge pull request #63790 from chpatrick/gdm-autosuspend-option
nixos/gdm: add autoSuspend option
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/x11/display-managers/gdm.nix46
1 files changed, 42 insertions, 4 deletions
diff --git a/nixos/modules/services/x11/display-managers/gdm.nix b/nixos/modules/services/x11/display-managers/gdm.nix
index ff4b91923e02..3f1669d08516 100644
--- a/nixos/modules/services/x11/display-managers/gdm.nix
+++ b/nixos/modules/services/x11/display-managers/gdm.nix
@@ -96,6 +96,14 @@ in
         type = types.bool;
       };
 
+      autoSuspend = mkOption {
+        default = true;
+        description = ''
+          Suspend the machine after inactivity.
+        '';
+        type = types.bool;
+      };
+
     };
 
   };
@@ -176,10 +184,40 @@ in
 
     systemd.user.services.dbus.wantedBy = [ "default.target" ];
 
-    programs.dconf.profiles.gdm = pkgs.writeText "dconf-gdm-profile" ''
-      system-db:local
-      ${gdm}/share/dconf/profile/gdm
-    '';
+    programs.dconf.profiles.gdm =
+    let
+      customDconf = pkgs.writeTextFile {
+        name = "gdm-dconf";
+        destination = "/dconf/gdm-custom";
+        text = ''
+          ${optionalString (!cfg.gdm.autoSuspend) ''
+            [org/gnome/settings-daemon/plugins/power]
+            sleep-inactive-ac-type='nothing'
+            sleep-inactive-battery-type='nothing'
+            sleep-inactive-ac-timeout=0
+            sleep-inactive-battery-timeout=0
+          ''}
+        '';
+      };
+
+      customDconfDb = pkgs.stdenv.mkDerivation {
+        name = "gdm-dconf-db";
+        buildCommand = ''
+          ${pkgs.gnome3.dconf}/bin/dconf compile $out ${customDconf}/dconf
+        '';
+      };
+    in pkgs.stdenv.mkDerivation {
+      name = "dconf-gdm-profile";
+      buildCommand = ''
+        # Check that the GDM profile starts with what we expect.
+        if [ $(head -n 1 ${gdm}/share/dconf/profile/gdm) != "user-db:user" ]; then
+          echo "GDM dconf profile changed, please update gdm.nix"
+          exit 1
+        fi
+        # Insert our custom DB behind it.
+        sed '2ifile-db:${customDconfDb}' ${gdm}/share/dconf/profile/gdm > $out
+      '';
+    };
 
     # Use AutomaticLogin if delay is zero, because it's immediate.
     # Otherwise with TimedLogin with zero seconds the prompt is still