commit 6a6aba9c4c653c2b78c2f2745727225c3387900f
parent 15bce4e7237b9b6c5513f3b40d65c43f11a3392f
Author: Leah (ctucx) <git@ctu.cx>
Date: Wed, 20 Nov 2024 11:23:02 +0100
parent 15bce4e7237b9b6c5513f3b40d65c43f11a3392f
Author: Leah (ctucx) <git@ctu.cx>
Date: Wed, 20 Nov 2024 11:23:02 +0100
configurations/linux/programs/gnome: patch out xorg without having a full copy of the packages
8 files changed, 82 insertions(+), 543 deletions(-)
M
|
86
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
D
|
178
-------------------------------------------------------------------------------
D
|
142
-------------------------------------------------------------------------------
diff --git a/configurations/linux/programs/gnome.nix b/configurations/linux/programs/gnome.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, lib, utils, ... }: let cfg = config.ctucxConfig.wm.gnome; @@ -57,9 +57,87 @@ in { # patched to remove xorg and xwayland completely nixpkgs.overlays = [(final: prev: { - mutter = final.callPackage ../../../pkgs/mutter.nix {}; - gdm = final.callPackage ../../../pkgs/gdm {}; - gnome-session = final.callPackage ../../../pkgs/gnome-session {}; + + mutter = prev.mutter.overrideAttrs( prevAttrs: { + mesonFlags = [ + "-Dinstalled_tests=false" "-Dtests=disabled" "-Ddocs=true" + "-Degl_device=true" + "-Dwayland_eglstream=true" + "-Dprofiler=true" + "-Dsm=false" + "-Dx11=false" + "-Dxwayland=false" + "-Dwayland=true" + ]; + buildInputs = (utils.removePackagesByName prevAttrs.buildInputs [ + prev.xorg.libSM + prev.xwayland + prev.gtk4 + prev.xorg.libICE + prev.xorg.libX11 + prev.xorg.libXcomposite + prev.xorg.libXcursor + prev.xorg.libXdamage + prev.xorg.libXext + prev.xorg.libXfixes + prev.xorg.libXi + prev.xorg.libXtst + prev.xorg.libxkbfile + prev.xkeyboard_config + prev.xorg.libxcb + prev.xorg.libXrandr + prev.xorg.libXinerama + prev.xorg.libXau + ]) ++ [ prev.libGL ]; + nativeBuildInputs = utils.removePackagesByName prevAttrs.nativeBuildInputs [ + prev.xorg.xorgserver + ]; + }); + + gdm = prev.gdm.overrideAttrs( prevAttrs: { + mesonFlags = prev.lib.lists.remove "--Dgdm-xsession=true" (prevAttrs.mesonFlags ++ [ "-Dgdm-xsession=false" "-Dx11-support=false" ]); + 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 + (prev.fetchpatch { + url = "https://gitlab.gnome.org/GNOME/gdm/-/commit/ccecd9c975d04da80db4cd547b67a1a94fa83292.patch"; + hash = "sha256-5hKS9wjjhuSAYwXct5vS0dPbmPRIINJoLC0Zm1naz6Q="; + revert = true; + }) + + ../../../pkgs/gdm-fix-wayland.patch + + # Change hardcoded paths to nix store paths. + (prev.substituteAll { + src = ../../../pkgs/gdm-fix-paths.patch; + coreutils = prev.coreutils; + plymouth = prev.plymouth; + dbus = prev.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" + ''; + buildInputs = utils.removePackagesByName prevAttrs.buildInputs [ + prev.xorg.libX11 + prev.xorg.libXdmcp + prev.xorg.libxcb + ]; + }); + + gnome-session = prev.gnome-session.overrideAttrs( prevAttrs: { + mesonFlags = [ "-Dx11=false" ]; + buildInputs = utils.removePackagesByName prevAttrs.buildInputs [ + prev.xorg.libICE + prev.xorg.xtrans + ]; + }); + })]; users.groups.gdm.gid = config.ids.gids.gdm;
diff --git a/pkgs/gdm/default.nix b/pkgs/gdm/default.nix @@ -1,178 +0,0 @@ -{ - 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/org.gnome.login-screen.gschema.override b/pkgs/gdm/org.gnome.login-screen.gschema.override @@ -1,2 +0,0 @@ -[org.gnome.login-screen] -logo='@icon@'
diff --git a/pkgs/gnome-session/default.nix b/pkgs/gnome-session/default.nix @@ -1,141 +0,0 @@ -{ - fetchurl, - fetchpatch, - lib, - stdenv, - substituteAll, - meson, - ninja, - pkg-config, - gnome, - adwaita-icon-theme, - glib, - gtk3, - gsettings-desktop-schemas, - gnome-desktop, - gnome-settings-daemon, - gnome-shell, - dbus, - json-glib, - xmlto, - docbook_xsl, - docbook_xml_dtd_412, - python3, - libxslt, - gettext, - makeWrapper, - systemd, - libepoxy, - bash, - gnome-session-ctl, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "gnome-session"; - version = "47.0.1"; - - outputs = [ - "out" - "sessions" - ]; - - src = fetchurl { - url = "mirror://gnome/sources/gnome-session/${lib.versions.major finalAttrs.version}/gnome-session-${finalAttrs.version}.tar.xz"; - hash = "sha256-Vq6caOSZlXk+sglrzcRTOxEWaeHlTItuCx2VL2peinA="; - }; - - patches = [ - (substituteAll { - src = ./fix-paths.patch; - gsettings = "${glib.bin}/bin/gsettings"; - dbusLaunch = "${dbus.lib}/bin/dbus-launch"; - bash = "${bash}/bin/bash"; - }) - ]; - - nativeBuildInputs = [ - meson - ninja - pkg-config - gettext - makeWrapper - xmlto - libxslt - docbook_xsl - docbook_xml_dtd_412 - python3 - dbus # for DTD - ]; - - buildInputs = [ - glib - gtk3 - gnome-desktop - json-glib - adwaita-icon-theme - gnome-settings-daemon - gsettings-desktop-schemas - systemd - libepoxy - ]; - - mesonFlags = [ - "-Dx11=false" - ]; - - postPatch = '' - chmod +x meson_post_install.py # patchShebangs requires executable file - patchShebangs meson_post_install.py - - # Use our provided `gnome-session-ctl` - original="@libexecdir@/gnome-session-ctl" - replacement="${gnome-session-ctl}/libexec/gnome-session-ctl" - - find data/ -type f -name "*.service.in" -exec sed -i \ - -e s,$original,$replacement,g \ - {} + - ''; - - # We move the GNOME sessions to another output since gnome-session is a dependency of - # GDM itself. If we do not hide them, it will show broken GNOME sessions when GDM is - # enabled without proper GNOME installation. - postInstall = '' - mkdir $sessions - moveToOutput share/wayland-sessions "$sessions" - moveToOutput share/xsessions "$sessions" - - # Our provided one is being used - rm -rf $out/libexec/gnome-session-ctl - ''; - - # `bin/gnome-session` will reset the environment when run in wayland, we - # therefor wrap `libexec/gnome-session-binary` instead which is the actual - # binary needing wrapping - preFixup = '' - wrapProgram "$out/libexec/gnome-session-binary" \ - --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \ - --suffix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH" \ - --suffix XDG_DATA_DIRS : "${gnome-shell}/share" \ - --suffix XDG_CONFIG_DIRS : "${gnome-settings-daemon}/etc/xdg" - ''; - - separateDebugInfo = true; - - passthru = { - updateScript = gnome.updateScript { - packageName = "gnome-session"; - }; - providedSessions = [ - "gnome" - ]; - }; - - meta = with lib; { - description = "GNOME session manager"; - homepage = "https://gitlab.gnome.org/GNOME/gnome-session"; - changelog = "https://gitlab.gnome.org/GNOME/gnome-session/-/blob/${finalAttrs.version}/NEWS?ref_type=tags"; - license = licenses.gpl2Plus; - maintainers = teams.gnome.members; - platforms = platforms.linux; - }; -})- \ No newline at end of file
diff --git a/pkgs/gnome-session/fix-paths.patch b/pkgs/gnome-session/fix-paths.patch @@ -1,35 +0,0 @@ -diff --git a/gnome-session/gnome-session.in b/gnome-session/gnome-session.in -index b4b1f8fa..99d52cba 100755 ---- a/gnome-session/gnome-session.in -+++ b/gnome-session/gnome-session.in -@@ -4,13 +4,15 @@ if [ "x$XDG_SESSION_TYPE" = "xwayland" ] && - [ "x$XDG_SESSION_CLASS" != "xgreeter" ] && - [ -n "$SHELL" ]; then - if [ "$1" != '-l' ]; then -- exec bash -c "exec -l '$SHELL' -c '$0 -l $*'" -+ # Make sure the shell actually sets up the environment. -+ unset __NIXOS_SET_ENVIRONMENT_DONE -+ exec @bash@ -c "exec -l '$SHELL' -c '$0 -l $*'" - else - shift - fi - fi - --SETTING=$(G_MESSAGES_DEBUG='' gsettings get org.gnome.system.locale region) -+SETTING=$(G_MESSAGES_DEBUG='' @gsettings@ get org.gnome.system.locale region) - REGION=${SETTING#\'} - REGION=${REGION%\'} - -diff --git a/gnome-session/main.c b/gnome-session/main.c -index a460a849..9d07898f 100644 ---- a/gnome-session/main.c -+++ b/gnome-session/main.c -@@ -215,7 +215,7 @@ require_dbus_session (int argc, - } - new_argv[i + 2] = NULL; - -- if (!execvp ("dbus-launch", new_argv)) { -+ if (!execvp ("@dbusLaunch@", new_argv)) { - g_set_error (error, - G_SPAWN_ERROR, - G_SPAWN_ERROR_FAILED,
diff --git a/pkgs/mutter.nix b/pkgs/mutter.nix @@ -1,182 +0,0 @@ -{ - fetchurl, - runCommand, - lib, - stdenv, - pkg-config, - gnome, - gettext, - gobject-introspection, - cairo, - colord, - lcms2, - pango, - libstartup_notification, - libcanberra, - ninja, - xvfb-run, - libadwaita, - libxcvt, - libxkbcommon, - libinput, - libdrm, - libei, - libdisplay-info, - gsettings-desktop-schemas, - glib, - atk, - fribidi, - harfbuzz, - gnome-desktop, - pipewire, - libgudev, - libwacom, - libSM, - mesa, - meson, - gnome-settings-daemon, - python3, - wayland-scanner, - wrapGAppsHook4, - gi-docgen, - sysprof, - libsysprof-capture, - desktop-file-utils, - libGL, - egl-wayland, - graphene, - wayland, - wayland-protocols, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "mutter"; - version = "47.0"; - - outputs = [ - "out" - "dev" - "man" - "devdoc" - ]; - - src = fetchurl { - url = "mirror://gnome/sources/mutter/${lib.versions.major finalAttrs.version}/mutter-${finalAttrs.version}.tar.xz"; - hash = "sha256-LQ6pAVCsbNAhnQB42wXW4VFNauIb+fP3QNT7A5EpAWs="; - }; - - mesonFlags = [ - "-Degl_device=true" - "-Dinstalled_tests=false" # TODO: enable these - "-Dtests=disabled" - "-Dwayland_eglstream=true" - "-Dprofiler=true" - "-Dsm=false" - "-Dx11=false" - "-Dxwayland=false" - "-Dwayland=true" - "-Ddocs=true" - ]; - - propagatedBuildInputs = [ - # required for pkg-config to detect mutter-mtk - graphene - ]; - - nativeBuildInputs = [ - desktop-file-utils - gettext - libxcvt - mesa # needed for gbm - meson - ninja - xvfb-run - pkg-config - python3 - wayland-scanner - wrapGAppsHook4 - gi-docgen - gobject-introspection - ]; - - buildInputs = [ - cairo - egl-wayland - glib - gnome-desktop - gnome-settings-daemon - gsettings-desktop-schemas - atk - fribidi - harfbuzz - libGL - libcanberra - libdrm - libei - libdisplay-info - libgudev - libxkbcommon - libinput - libstartup_notification - libwacom - colord - lcms2 - pango - pipewire - sysprof # for D-Bus interfaces - libsysprof-capture - wayland - wayland-protocols - ]; - - postPatch = '' - patchShebangs src/backends/native/gen-default-modes.py - - # https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3981 - substituteInPlace src/frames/main.c \ - --replace-fail "libadwaita-1.so.0" "${libadwaita}/lib/libadwaita-1.so.0" - ''; - - postInstall = '' - ${glib.dev}/bin/glib-compile-schemas "$out/share/glib-2.0/schemas" - ''; - - postFixup = '' - # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back. - # TODO: Move this into a directory devhelp can find. - moveToOutput "share/mutter-15/doc" "$devdoc" - ''; - - # Install udev files into our own tree. - PKG_CONFIG_UDEV_UDEVDIR = "${placeholder "out"}/lib/udev"; - - separateDebugInfo = true; - - passthru = { - libdir = "${finalAttrs.finalPackage}/lib/mutter-15"; - - tests = { - libdirExists = runCommand "mutter-libdir-exists" { } '' - if [[ ! -d ${finalAttrs.finalPackage.libdir} ]]; then - echo "passthru.libdir should contain a directory, “${finalAttrs.finalPackage.libdir}” is not one." - exit 1 - fi - touch $out - ''; - }; - - updateScript = gnome.updateScript { - packageName = "mutter"; - }; - }; - - meta = with lib; { - description = "Window manager for GNOME"; - mainProgram = "mutter"; - homepage = "https://gitlab.gnome.org/GNOME/mutter"; - changelog = "https://gitlab.gnome.org/GNOME/mutter/-/blob/${finalAttrs.version}/NEWS?ref_type=tags"; - license = licenses.gpl2Plus; - maintainers = teams.gnome.members; - platforms = platforms.linux; - }; -})