mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-22 21:18:28 +03:00
Merge pull request #63790 from chpatrick/gdm-autosuspend-option
nixos/gdm: add autoSuspend option
This commit is contained in:
commit
a4c6a7b336
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user