# Template file for 'niri'
pkgname=niri
version=26.04
revision=1
build_style=cargo
build_helper="qemu"
configure_args="--no-default-features --features dbus,xdp-gnome-screencast"
hostmakedepends="pkg-config clang19-devel"
makedepends="eudev-libudev-devel libxkbcommon-devel libinput-devel libgbm-devel
 libdisplay-info-devel pipewire-devel pango-devel libseat-devel clang19-devel
gdk-pixbuf-devel graphene-devel gtk4-devel libadwaita-devel"
depends="wayland"
checkdepends="wayland"
short_desc="Scrollable-tiling Wayland compositor"
maintainer="Andrew J. Hesford <ajh@sideband.org>"
license="GPL-3.0-or-later"
homepage="https://niri-wm.github.io/niri/"
changelog="https://github.com/niri-wm/niri/releases"
distfiles="https://github.com/niri-wm/niri/archive/refs/tags/v${version}.tar.gz"
checksum=134c602d8e0d53413a52d6cd58f9ce7e79a07d03288ee0a51ba1abd5db1b1ad9

pre_check() {
	export XDG_RUNTIME_DIR=$(mktemp -d "$wrksrc/runtime.XXXXXX")
	ulimit -n 4096
}

do_check() {
	# skip tests on musl - tests try to use libc::close_range, but only actually used with certain features
	# https://github.com/YaLTeR/niri/issues/1954
	# skip egl tests - requires surfaceless EGL to be available at test time
	if [ "$XBPS_TARGET_LIBC" != "musl" ]; then
		cargo test --target ${RUST_TARGET} --workspace --locked -- --skip=::egl
	fi
}

post_install() {
	local sh

	vinstall resources/niri.desktop 644 usr/share/wayland-sessions
	vinstall resources/niri-portals.conf 644 usr/share/xdg-desktop-portal

	vsconf resources/default-config.kdl

	for sh in bash fish zsh; do
		vtargetrun "${DESTDIR}/usr/bin/niri" completions "${sh}" > "niri.${sh}"
		vcompletion "niri.${sh}" "${sh}"
	done
}
