Skip to content

Commit

Permalink
feat(vine/desktop): more wayland support
Browse files Browse the repository at this point in the history
  • Loading branch information
HoKim98 committed Nov 13, 2024
1 parent b73f4ea commit 3e0f458
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 39 deletions.
25 changes: 9 additions & 16 deletions templates/kiss/assets/boot/cloud-init_ubuntu_24.04_post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ chmod 440 /etc/sudoers.d/10-wheel
# Bluetooth Configuration
systemctl enable bluetooth.service

# Graphics Configuration
add-apt-repository -y 'ppa:graphics-drivers/ppa'
dpkg --add-architecture i386
apt-get update

# Driver Configuration
## GPU - NVIDIA
if lspci | grep 'NVIDIA'; then
Expand All @@ -96,23 +101,11 @@ if lspci | grep 'NVIDIA'; then

if [ "x${_IS_NVIDIA_MANUAL}" == "xfalse" ]; then
if [ "x${_HAS_NVIDIA_GPU}" == "xtrue" ]; then
# TODO: NVIDIA Driver >=545 has breaking changes; not compatible with old (year < 2023) containers.
# Issue: https://github.com/NVIDIA/egl-wayland/issues/72#issuecomment-1819549040
apt-get install -y \
"libnvidia-cfg1-535" \
"libnvidia-common-535" \
"libnvidia-compute-535" \
"libnvidia-decode-535" \
"libnvidia-encode-535" \
"libnvidia-extra-535" \
"libnvidia-fbc1-535" \
"libnvidia-gl-535" \
"libnvidia-nscq-535" \
"nvidia-compute-utils-535" \
"nvidia-dkms-535" \
"nvidia-fabricmanager-535" \
"nvidia-utils-535" \
"xserver-xorg-video-nvidia-535"
"libnvidia-*-550" \
"libnvidia-egl-wayland1" \
"nvidia-*-550" \
"xserver-xorg-video-nvidia-550"
fi

# Enable NVIDIA FabricManager
Expand Down
4 changes: 1 addition & 3 deletions templates/kiss/assets/boot/rocky9.ks
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,8 @@ if lspci | grep 'NVIDIA'; then
if [ "x${_HAS_NVIDIA_GPU}" == "xtrue" ]; then
dnf install -y pulseaudio
dnf config-manager --add-repo "https://developer.download.nvidia.com/compute/cuda/repos/rhel$(rpm -E %rhel)/${ARCH_SBSA}/cuda-rhel$(rpm -E %rhel).repo"
# TODO: NVIDIA Driver >=545 has breaking changes; not compatible with old (year < 2023) containers.
# Issue: https://github.com/NVIDIA/egl-wayland/issues/72#issuecomment-1819549040
#dnf module install -y "nvidia-driver:latest-dkms"
dnf module install -y "nvidia-driver:535-dkms"
dnf module install -y "nvidia-driver:550-dkms"
# NOTE: use fixed cuda toolkit
dnf install -y \
cuda-toolkit \
Expand Down
67 changes: 52 additions & 15 deletions templates/vine/desktop/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ RUN apt-get update && apt-get install -y \
libtool \
just \
make \
meson \
mold \
nasm \
pkg-config \
Expand Down Expand Up @@ -347,6 +348,8 @@ RUN apt-get update && apt-get install -y \
mesa-utils \
vulkan-icd \
vulkan-tools \
# Core (NVIDIA)
libnvidia-egl-wayland1 \
# Core (Audio/PipeWire)
libldacbt-abr2 libldacbt-enc2 \
libpipewire-0.3-common \
Expand Down Expand Up @@ -489,19 +492,53 @@ RUN apt-get update && apt-get install -y \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*

# Install cutting-edge weston (>=14)
ARG WESTON_REPO="https://gitlab.freedesktop.org/wayland/weston.git"
RUN apt-get update && apt-get install -y \
freerdp2-dev \
freerdp3-dev \
gnutls-dev \
hwdata \
libdisplay-info-dev \
libgmp-dev \
libinput-dev \
liblcms2-dev \
libneatvnc-dev \
libpam-dev \
libpipewire-0.3-dev \
libseat-dev \
libturbojpeg-dev \
libva-dev \
libxcb-composite0-dev \
libxcb-cursor-dev \
libxcb-xkb-dev \
nettle-dev \
# Download
&& WESTON_SRC="/opt/weston" \
&& git clone "${WESTON_REPO}" "${WESTON_SRC}" \
&& cd "${WESTON_SRC}" \
# Build
&& meson build/ --prefix=/usr \
&& ninja -C build/ install \
# Cleanup
&& cd - \
&& rm -rf "${WESTON_SRC}" \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*

# Install cutting-edge ananicy
ARG ANANICY_REPO="https://github.com/kuche1/minq-ananicy.git"
RUN apt-get update \
# Download
&& ANANICY_TMP="/opt/ananicy" \
&& git clone "${ANANICY_REPO}" "${ANANICY_TMP}" \
&& cd "${ANANICY_TMP}" \
&& ANANICY_SRC="/opt/ananicy" \
&& git clone "${ANANICY_REPO}" "${ANANICY_SRC}" \
&& cd "${ANANICY_SRC}" \
# Build
&& ./package.sh debian \
&& apt-get install -y ./ananicy-*.deb \
# Cleanup
&& cd - \
&& rm -rf "${ANANICY_TMP}" \
&& rm -rf "${ANANICY_SRC}" \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -513,25 +550,25 @@ ARG PODMAN_VERSION="5.1"
RUN apt-mark hold crun podman \
# crun
## Download
&& CRUN_TMP="/opt/crun" \
&& git clone "${CRUN_REPO}" "${CRUN_TMP}" -b "${CRUN_VERSION}" \
&& cd "${CRUN_TMP}" \
&& CRUN_SRC="/opt/crun" \
&& git clone "${CRUN_REPO}" "${CRUN_SRC}" -b "${CRUN_VERSION}" \
&& cd "${CRUN_SRC}" \
## Build
&& ./autogen.sh \
&& ./configure --enable-shared --prefix=/usr \
&& make \
&& make install \
# podman
## Download
&& PODMAN_TMP="/opt/podman" \
&& git clone "${PODMAN_REPO}" "${PODMAN_TMP}" -b "v${PODMAN_VERSION}" \
&& cd "${PODMAN_TMP}" \
&& PODMAN_SRC="/opt/podman" \
&& git clone "${PODMAN_REPO}" "${PODMAN_SRC}" -b "v${PODMAN_VERSION}" \
&& cd "${PODMAN_SRC}" \
## Build
&& make BUILDTAGS='cni seccomp selinux systemd' PREFIX=/usr \
&& make install PREFIX=/usr \
# Cleanup
&& cd - \
&& rm -rf "${CRUN_TMP}" "${PODMAN_TMP}" \
&& rm -rf "${CRUN_SRC}" "${PODMAN_SRC}" \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -579,13 +616,13 @@ RUN apt-mark hold wine \
&& WINE_OBJ_NAME="wine-${WINE_VERSION}-staging-tkg-${WINE_ARCH}" \
&& WINE_OBJ_FILENAME="${WINE_OBJ_NAME}.tar.xz" \
&& WINE_OBJ_FILE="${WINE_OBJ_FILENAME}" \
&& WINE_TMP="/opt/${WINE_OBJ_NAME}" \
&& WINE_SRC="/opt/${WINE_OBJ_NAME}" \
&& curl -Lo "${WINE_OBJ_FILE}" "${WINE_REPO}/${WINE_VERSION}/${WINE_OBJ_FILENAME}" \
# Decompress the downloaded file
&& tar -x -C "$(dirname "${WINE_TMP}")" -f "${WINE_OBJ_FILE}" \
&& tar -cf - -C "${WINE_TMP}" . | tar -xf - -C '/usr' \
&& tar -x -C "$(dirname "${WINE_SRC}")" -f "${WINE_OBJ_FILE}" \
&& tar -cf - -C "${WINE_SRC}" . | tar -xf - -C '/usr' \
# Cleanup
&& rm -rf "${WINE_OBJ_FILE}" "${WINE_TMP}"
&& rm -rf "${WINE_OBJ_FILE}" "${WINE_SRC}"

# Install AI dev dependencies
RUN apt-get update && apt-get install -y \
Expand Down
Empty file modified templates/vine/desktop/scripts/init-desktop-apps.sh
100644 → 100755
Empty file.
18 changes: 13 additions & 5 deletions templates/vine/desktop/scripts/init-desktop-wayland.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ if [ ! -S "/tmp/.X11-unix/X$(echo "${DISPLAY}" | grep -Po '[0-9]+$')" ]; then
echo "export WAYLAND_DISPLAY=\"${WAYLAND_DISPLAY}\"" >>"${__ENV_HOME}"

# Configure wayland
WAYLAND_BACKEND_RDP='rdp-backend.so'
WAYLAND_BACKEND_VNC='vnc-backend.so'
WAYLAND_BACKEND_RDP='rdp'
WAYLAND_BACKEND_VNC='vnc'

WAYLAND_ARGS="${WAYLAND_ARGS} --socket=${WAYLAND_DISPLAY}"
WAYLAND_ARGS="${WAYLAND_ARGS} --xwayland"
WAYLAND_BACKEND="${WAYLAND_BACKEND:-$WAYLAND_BACKEND_VNC}"
WAYLAND_TLS_HOME="${HOME}/.rdp"

# Configure weston
WESTON_RENDERER='gl'

# Detect backend kind
if [ "x${WAYLAND_BACKEND}" == "x${WAYLAND_BACKEND_RDP}" ]; then
if echo "${WAYLAND_BACKEND}" | grep -Posq "(^|,)${WAYLAND_BACKEND_RDP}(,|$)"; then
WAYLAND_BACKEND_KIND='rdp'
elif [ "x${WAYLAND_BACKEND}" == "x${WAYLAND_BACKEND_VNC}" ]; then
elif echo "${WAYLAND_BACKEND}" | grep -Posq "(^|,)${WAYLAND_BACKEND_VNC}(,|$)"; then
WAYLAND_BACKEND_KIND='vnc'
else
WAYLAND_BACKEND_KIND=''
Expand All @@ -68,16 +71,21 @@ if [ ! -S "/tmp/.X11-unix/X$(echo "${DISPLAY}" | grep -Po '[0-9]+$')" ]; then
if nvidia-smi >/dev/null 2>/dev/null; then
export __GLX_VENDOR_LIBRARY_NAME="nvidia"
export __NV_PRIME_RENDER_OFFLOAD="1"
export GBM_BACKEND="nvidia-drm"

# Make these environment variables persistent
echo "export __GLX_VENDOR_LIBRARY_NAME=\"${__GLX_VENDOR_LIBRARY_NAME}\"" >>"${__ENV_HOME}"
echo "export __NV_PRIME_RENDER_OFFLOAD=\"${__NV_PRIME_RENDER_OFFLOAD}\"" >>"${__ENV_HOME}"
echo "export GBM_BACKEND=\"${GBM_BACKEND}\"" >>"${__ENV_HOME}"
fi

# Disable default weston terminal
if sudo whoami >/dev/null; then
sudo ln -sf /usr/bin/xfce4-terminal /usr/bin/weston-terminal
fi

weston --backend="${WAYLAND_BACKEND}" ${WAYLAND_ARGS} &
weston \
--backend="${WAYLAND_BACKEND}" \
--renderer="${WESTON_RENDERER}" \
${WAYLAND_ARGS} &
fi

0 comments on commit 3e0f458

Please sign in to comment.