ctucx.git: nixfiles

ctucx' nixfiles

commit f71984a15904d184470517aabbbc74847c6e08c5
parent 13d5ecee64f2dc5367652411a3a918684f9ff123
Author: Leah (ctucx) <git@ctu.cx>
Date: Thu, 7 Nov 2024 08:37:27 +0100

pkgs: add `gnome-session` (patched to not include x11)
2 files changed, 177 insertions(+), 0 deletions(-)
A
pkgs/gnome-session/default.nix
|
142
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A
pkgs/gnome-session/fix-paths.patch
|
35
+++++++++++++++++++++++++++++++++++
diff --git a/pkgs/gnome-session/default.nix b/pkgs/gnome-session/default.nix
@@ -0,0 +1,141 @@
+{
+  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
@@ -0,0 +1,35 @@
+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,