commit 0bdd689020c42e47a693b3377cda3af2b26bc2f0
parent f71984a15904d184470517aabbbc74847c6e08c5
Author: Leah (ctucx) <git@ctu.cx>
Date: Thu, 7 Nov 2024 08:38:24 +0100
parent f71984a15904d184470517aabbbc74847c6e08c5
Author: Leah (ctucx) <git@ctu.cx>
Date: Thu, 7 Nov 2024 08:38:24 +0100
pkgs: add `gdm` (patched to not support/include x11/xwayland)
4 files changed, 270 insertions(+), 0 deletions(-)
A
|
178
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A
|
77
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/pkgs/gdm/default.nix b/pkgs/gdm/default.nix @@ -0,0 +1,178 @@ +{ + lib, + stdenv, + fetchurl, + fetchpatch, + substituteAll, + meson, + ninja, + pkg-config, + glib, + json-glib, + itstool, + accountsservice, + gnome, + systemd, + dconf, + gtk3, + pam, + libgudev, + libselinux, + keyutils, + audit, + gobject-introspection, + plymouth, + coreutils, + dbus, + nixos-icons, + runCommand, +}: + +let + override = substituteAll { + src = ./org.gnome.login-screen.gschema.override; + icon = "${nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake-white.svg"; + }; + +in + +stdenv.mkDerivation (finalAttrs: { + pname = "gdm"; + version = "47.0"; + + outputs = [ + "out" + "dev" + ]; + + src = fetchurl { + url = "mirror://gnome/sources/gdm/${lib.versions.major finalAttrs.version}/gdm-${finalAttrs.version}.tar.xz"; + hash = "sha256-xYWDJr+8yKzlgTUuK+RGItwOnlwoAchpD9Lu1QJgf4Q="; + }; + + mesonFlags = [ + "-Dgdm-xsession=false" + "-Dx11-support=false" + # TODO: Setup a default-path? https://gitlab.gnome.org/GNOME/gdm/-/blob/6fc40ac6aa37c8ad87c32f0b1a5d813d34bf7770/meson_options.txt#L6 + "-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" + "--sysconfdir=/etc" + "--localstatedir=/var" + ]; + + nativeBuildInputs = [ + dconf + glib # for glib-compile-schemas + itstool + meson + ninja + pkg-config + gobject-introspection + ]; + + buildInputs = [ + accountsservice + audit + glib + json-glib + gtk3 + keyutils + libgudev + libselinux + pam + plymouth + systemd + ]; + + patches = [ + # GDM fails to find g-s with the following error in the journal. + # gdm-x-session[976]: dbus-run-session: failed to exec 'gnome-session': No such file or directory + # https://gitlab.gnome.org/GNOME/gdm/-/merge_requests/92 + (fetchpatch { + url = "https://gitlab.gnome.org/GNOME/gdm/-/commit/ccecd9c975d04da80db4cd547b67a1a94fa83292.patch"; + hash = "sha256-5hKS9wjjhuSAYwXct5vS0dPbmPRIINJoLC0Zm1naz6Q="; + revert = true; + }) + + ./fix-wayland.patch + + # Change hardcoded paths to nix store paths. + (substituteAll { + src = ./fix-paths.patch; + inherit coreutils plymouth dbus; + }) + ]; + + postPatch = '' + # Reverts https://gitlab.gnome.org/GNOME/gdm/-/commit/b0f802e36ff948a415bfd2bccaa268b6990515b7 + # The gdm-auth-config tool is probably not too useful for NixOS, but we still want the dconf profile + # installed (mostly just because .passthru.tests can make use of it). + substituteInPlace meson.build \ + --replace-fail "dconf_prefix = dconf_dep.get_variable(pkgconfig: 'prefix')" "dconf_prefix = gdm_prefix" + ''; + + preInstall = '' + install -D ${override} "$DESTDIR/$out/share/glib-2.0/schemas/org.gnome.login-screen.gschema.override" + ''; + + postInstall = '' + # Move stuff from DESTDIR to proper location. + for o in $(getAllOutputNames); do + # debug is created later by _separateDebugInfo hook. + if [[ "$o" = "debug" ]]; then continue; fi + mv "$DESTDIR''${!o}" "$(dirname "''${!o}")" + done + + mv "$DESTDIR/etc" "$out" + + # Ensure we did not forget to install anything. + rmdir --parents --ignore-fail-on-non-empty "$DESTDIR${builtins.storeDir}" + [ ! -e "$DESTDIR" ] || (echo "Some files are still left in a temporary DESTDIR and aren't properly installed."; exit 1) + + # We are setting DESTDIR so the post-install script does not compile the schemas. + glib-compile-schemas "$out/share/glib-2.0/schemas" + ''; + + env = { + # HACK: We want to install configuration files to $out/etc + # but GDM should read them from /etc on a NixOS system. + # With autotools, it was possible to override Make variables + # at install time but Meson does not support this + # so we need to convince it to install all files to a temporary + # location using DESTDIR and then move it to proper one in postInstall. + DESTDIR = "dest"; + }; + + separateDebugInfo = true; + + passthru = { + updateScript = gnome.updateScript { packageName = "gdm"; }; + + # 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; { + description = "Program that manages graphical display servers and handles graphical user logins"; + homepage = "https://gitlab.gnome.org/GNOME/gdm"; + changelog = "https://gitlab.gnome.org/GNOME/gdm/-/blob/${finalAttrs.version}/NEWS?ref_type=tags"; + license = licenses.gpl2Plus; + maintainers = teams.gnome.members; + platforms = platforms.linux; + }; +})
diff --git a/pkgs/gdm/fix-paths.patch b/pkgs/gdm/fix-paths.patch @@ -0,0 +1,77 @@ +diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c +index fc5aef6ac..c61e0046b 100644 +--- a/daemon/gdm-manager.c ++++ b/daemon/gdm-manager.c +@@ -151,7 +151,7 @@ plymouth_is_running (void) + GError *error; + + error = NULL; +- res = g_spawn_command_line_sync ("plymouth --ping", ++ res = g_spawn_command_line_sync ("@plymouth@/bin/plymouth --ping", + NULL, NULL, &status, &error); + if (! res) { + g_debug ("Could not ping plymouth: %s", error->message); +@@ -169,7 +169,7 @@ plymouth_prepare_for_transition (void) + GError *error; + + error = NULL; +- res = g_spawn_command_line_sync ("plymouth deactivate", ++ res = g_spawn_command_line_sync ("@plymouth@/bin/plymouth deactivate", + NULL, NULL, NULL, &error); + if (! res) { + g_warning ("Could not deactivate plymouth: %s", error->message); +@@ -184,7 +184,7 @@ plymouth_quit_with_transition (void) + GError *error; + + error = NULL; +- res = g_spawn_command_line_async ("plymouth quit --retain-splash", &error); ++ res = g_spawn_command_line_async ("@plymouth@/bin/plymouth quit --retain-splash", &error); + if (! res) { + g_warning ("Could not quit plymouth: %s", error->message); + g_error_free (error); +@@ -200,7 +200,7 @@ plymouth_quit_without_transition (void) + GError *error; + + error = NULL; +- res = g_spawn_command_line_async ("plymouth quit", &error); ++ res = g_spawn_command_line_async ("@plymouth@/bin/plymouth quit", &error); + if (! res) { + g_warning ("Could not quit plymouth: %s", error->message); + g_error_free (error); +diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c +index a4c4b2dcf..67416b204 100644 +--- a/daemon/gdm-session.c ++++ b/daemon/gdm-session.c +@@ -3193,16 +3193,16 @@ gdm_session_start_session (GdmSession *self, + */ + if (run_launcher) { + if (is_x11) { +- program = g_strdup_printf (LIBEXECDIR "/gdm-x-session %s\"dbus-run-session -- %s\"", ++ program = g_strdup_printf (LIBEXECDIR "/gdm-x-session %s\"@dbus@/bin/dbus-run-session --dbus-daemon=@dbus@/bin/dbus-daemon -- %s\"", + register_session ? "--register-session " : "", + self->selected_program); + } else { +- program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session %s\"dbus-run-session -- %s\"", ++ program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session %s\"@dbus@/bin/dbus-run-session --dbus-daemon=@dbus@/bin/dbus-daemon -- %s\"", + register_session ? "--register-session " : "", + self->selected_program); + } + } else { +- program = g_strdup_printf ("dbus-run-session -- %s", ++ program = g_strdup_printf ("@dbus@/bin/dbus-run-session --dbus-daemon=@dbus@/bin/dbus-daemon -- %s", + self->selected_program); + } + } +diff --git a/data/gdm.service.in b/data/gdm.service.in +index 17e8a8de8..afc709778 100644 +--- a/data/gdm.service.in ++++ b/data/gdm.service.in +@@ -26,7 +26,7 @@ Restart=always + IgnoreSIGPIPE=no + BusName=org.gnome.DisplayManager + EnvironmentFile=-${LANG_CONFIG_FILE} +-ExecReload=/bin/kill -SIGHUP $MAINPID ++ExecReload=@coreutils@/bin/kill -SIGHUP $MAINPID + KeyringMode=shared + + [Install]
diff --git a/pkgs/gdm/fix-wayland.patch b/pkgs/gdm/fix-wayland.patch @@ -0,0 +1,13 @@ +--- a/daemon/gdm-local-display-factory.c 2024-11-05 19:24:43.441435388 +0100 ++++ b/daemon/gdm-local-display-factory.c 2024-11-05 19:26:39.455865220 +0100 +@@ -289,8 +289,10 @@ + return FALSE; + #endif + ++#ifdef ENABLE_X11_SUPPORT + if (!g_file_test (binary, G_FILE_TEST_IS_EXECUTABLE)) + return FALSE; ++#endif + + return TRUE; + }
diff --git a/pkgs/gdm/org.gnome.login-screen.gschema.override b/pkgs/gdm/org.gnome.login-screen.gschema.override @@ -0,0 +1,2 @@ +[org.gnome.login-screen] +logo='@icon@'