Skip to content

Commit

Permalink
nixos/gdm: switch to dconf settings
Browse files Browse the repository at this point in the history
  • Loading branch information
linsui committed Jun 14, 2023
1 parent 0dff765 commit fe57bd4
Showing 1 changed file with 7 additions and 33 deletions.
40 changes: 7 additions & 33 deletions nixos/modules/services/x11/display-managers/gdm.nix
Expand Up @@ -229,40 +229,14 @@ in

systemd.user.services.dbus.wantedBy = [ "default.target" ];

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.dconf}/bin/dconf compile $out ${customDconf}/dconf
'';
programs.dconf.profiles.gdm.databases = lib.optionals (!cfg.gdm.autoSuspend) [{
settings.org.gnome.settings-daemon.plugins.power = {
sleep-inactive-ac-type = "nothing";
sleep-inactive-battery-type = "nothing";
sleep-inactive-ac-timeout = lib.gvariant.mkInt32 0;
sleep-inactive-battery-timeout = lib.gvariant.mkInt32 0;
};
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
'';
};
}] ++ [ "${gdm}/share/gdm/greeter-dconf-defaults" ];

# Use AutomaticLogin if delay is zero, because it's immediate.
# Otherwise with TimedLogin with zero seconds the prompt is still
Expand Down

0 comments on commit fe57bd4

Please sign in to comment.