nixos/gdm: add autoSuspend option
This commit is contained in:
parent
c3cc7034e2
commit
7c854aa974
@ -96,6 +96,14 @@ in
|
|||||||
type = types.bool;
|
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" ];
|
systemd.user.services.dbus.wantedBy = [ "default.target" ];
|
||||||
|
|
||||||
programs.dconf.profiles.gdm = pkgs.writeText "dconf-gdm-profile" ''
|
programs.dconf.profiles.gdm =
|
||||||
system-db:local
|
let
|
||||||
${gdm}/share/dconf/profile/gdm
|
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.
|
# Use AutomaticLogin if delay is zero, because it's immediate.
|
||||||
# Otherwise with TimedLogin with zero seconds the prompt is still
|
# Otherwise with TimedLogin with zero seconds the prompt is still
|
||||||
|
Loading…
x
Reference in New Issue
Block a user