6. Run Gnome 40 using JHBuild on Debian / Ubuntu

You will need following files.

6.1 Create /usr/local/bin/gnome-session-jhbuild file [root]

All credits to Florian Müllner. Add following content to /usr/local/bin/gnome-session-jhbuild

#!/bin/sh
# 
# All credit to fmuellner!
# https://gitlab.gnome.org/fmuellner/silverblue-stuff/-/blob/master/sb-session-setup.sh
set -x

jhbuild() {
  /home/inttf/.local/bin/jhbuild "$@"
}

export $(jhbuild run env | grep JHBUILD_PREFIX= | sed 's:\r::')

USER_UNIT_DIR=$XDG_RUNTIME_DIR/systemd/user.control

if [ ! -e $USER_UNIT_DIR ]
then
  # Pick up systemd units defined in jhbuild
  ln -s $JHBUILD_PREFIX/lib/systemd/user $USER_UNIT_DIR
  systemctl --user daemon-reload
fi

DBUS_SERVICE_DIR=$XDG_RUNTIME_DIR/dbus-1
rm -rf $DBUS_SERVICE_DIR

if [ ! -e $DBUS_SERVICE_DIR ]
then
  ln -s $JHBUILD_PREFIX/share/dbus-1 $DBUS_SERVICE_DIR
fi

# $PATH and a few other things are likely overriden by your distro on your
# ~/.profile file (see /etc/skel/.profile) -- this might cause .desktop files
# to be seen as "broken" (because TryExec/Exec can't confirm there's a valid
# binary to use)
jhbuild run gnome-session

rm $DBUS_SERVICE_DIR
rm $USER_UNIT_DIR
systemctl --user daemon-reload

And make it executable:

chmod +x /usr/local/bin/gnome-session-jhbuild

6.2 Create /usr/share/wayland-sessions/jhbuild.desktop for Wayland session [root]

cat  /usr/share/wayland-sessions/jhbuild.desktop
[Desktop Entry]
Name=jhbuild GNOME Wayland
Comment=This session logs you into a development GNOME
Exec=/usr/local/bin/gnome-session-jhbuild
TryExec=/usr/local/bin/gnome-session-jhbuild
Type=Application
DesktopNames=GNOME
X-GDM-SessionRegisters=true
EOF

6.3 Create /usr/share/xsessions/jhbuild.desktop for Xorg session [root]

cat  /usr/share/xsessions/jhbuild.desktop
[Desktop Entry]
Name=jhbuild GNOME Xorg
Comment=This session logs you into a development GNOME
Exec=/usr/local/bin/gnome-session-jhbuild
TryExec=/usr/local/bin/gnome-session-jhbuild
Type=Application
DesktopNames=GNOME
X-GDM-SessionRegisters=true
EOF

6.4 Add following to ~/.profile [normal user]

# add jhbuild to PATH
if [ -n "$UNDER_JHBUILD" ]; then
    PATH="$JHBUILD_PREFIX/bin:$PATH"
fi

6.5 Logout and then login using jhbuild GNOME Wayland or jhbuild GNOME Xorg session

Ubuntu Login JHBuild GNOME Environment

6.6 GNOME 40.2 running on Ubuntu 21.04

Ubuntu 21.04 running JHBuild GNOME 40.2