nixos/gdm: switch to dconf settings

This commit is contained in:
linsui 2023-06-14 16:28:04 +08:00 committed by linsui
parent 038d78d4ce
commit 0e6827ed9c
2 changed files with 32 additions and 46 deletions

View File

@ -231,40 +231,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
''}
'';
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;
};
customDconfDb = pkgs.stdenv.mkDerivation {
name = "gdm-dconf-db";
buildCommand = ''
${pkgs.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
'';
};
}] ++ [ "${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

View File

@ -1,4 +1,5 @@
{ lib, stdenv
{ lib
, stdenv
, fetchurl
, fetchpatch
, substituteAll
@ -8,7 +9,6 @@
, pkg-config
, glib
, itstool
, libxml2
, xorg
, accountsservice
, libX11
@ -24,12 +24,12 @@
, audit
, gobject-introspection
, plymouth
, librsvg
, coreutils
, xorgserver
, xwayland
, dbus
, nixos-icons
, runCommand
}:
let
@ -41,21 +41,21 @@ let
in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "gdm";
version = "44.1";
outputs = [ "out" "dev" ];
src = fetchurl {
url = "mirror://gnome/sources/gdm/${lib.versions.major version}/${pname}-${version}.tar.xz";
url = "mirror://gnome/sources/gdm/${lib.versions.major finalAttrs.version}/${finalAttrs.pname}-${finalAttrs.version}.tar.xz";
sha256 = "aCZrOr59KPxGnQBnqsnF2rsMp5UswffCOKBJUfPcWw0=";
};
mesonFlags = [
"-Dgdm-xsession=true"
# TODO: Setup a default-path? https://gitlab.gnome.org/GNOME/gdm/-/blob/6fc40ac6aa37c8ad87c32f0b1a5d813d34bf7770/meson_options.txt#L6
"-Dinitial-vt=${passthru.initialVT}"
"-Dinitial-vt=${finalAttrs.passthru.initialVT}"
"-Dudev-dir=${placeholder "out"}/lib/udev/rules.d"
"-Dsystemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
"-Dsystemduserunitdir=${placeholder "out"}/lib/systemd/user"
@ -131,21 +131,21 @@ stdenv.mkDerivation rec {
'';
preInstall = ''
install -D ${override} ${DESTDIR}/$out/share/glib-2.0/schemas/org.gnome.login-screen.gschema.override
install -D ${override} $DESTDIR/$out/share/glib-2.0/schemas/org.gnome.login-screen.gschema.override
'';
postInstall = ''
# Move stuff from DESTDIR to proper location.
# We use rsync to merge the directories.
rsync --archive "${DESTDIR}/etc" "$out"
rm --recursive "${DESTDIR}/etc"
rsync --archive "$DESTDIR/etc" "$out"
rm --recursive "$DESTDIR/etc"
for o in $(getAllOutputNames); do
if [[ "$o" = "debug" ]]; then continue; fi
rsync --archive "${DESTDIR}/''${!o}" "$(dirname "''${!o}")"
rm --recursive "${DESTDIR}/''${!o}"
rsync --archive "$DESTDIR/''${!o}" "$(dirname "''${!o}")"
rm --recursive "$DESTDIR/''${!o}"
done
# Ensure the DESTDIR is removed.
rmdir "${DESTDIR}/nix/store" "${DESTDIR}/nix" "${DESTDIR}"
rmdir "$DESTDIR/nix/store" "$DESTDIR/nix" "$DESTDIR"
# We are setting DESTDIR so the post-install script does not compile the schemas.
glib-compile-schemas "$out/share/glib-2.0/schemas"
@ -170,6 +170,18 @@ stdenv.mkDerivation rec {
# Used in GDM NixOS module
# Don't remove.
initialVT = "7";
dconfDb = "${finalAttrs.finalPackage}/share/gdm/greeter-dconf-defaults";
dconfProfile = "user-db:user\nfile-db:${finalAttrs.passthru.dconfDb}";
tests = {
profile = runCommand "gdm-profile-test" { } ''
if test "${finalAttrs.passthru.dconfProfile}" != "$(cat ${finalAttrs.finalPackage}/share/dconf/profile/gdm)"; then
echo "GDM dconf profile changed, please update gdm.nix"
exit 1
fi
touch $out
'';
};
};
meta = with lib; {
@ -179,4 +191,4 @@ stdenv.mkDerivation rec {
maintainers = teams.gnome.members;
platforms = platforms.linux;
};
}
})