# Contributor: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
# Maintainer: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
pkgname=niri
pkgver=25.05
pkgrel=0
pkgdesc="A scrollable-tiling Wayland compositor"
url="https://github.com/YaLTeR/niri"
arch="x86_64 ppc64le aarch64"
license="GPL-3.0-only"
makedepends="
	cargo
	cargo-auditable
	clang-libclang
	clang-libs
	eudev-dev
	glib-dev
	libdisplay-info-dev
	libinput-dev
	libseat-dev
	libxkbcommon-dev
	mesa-dev
	pango-dev
	pipewire-dev
	rust
	"
subpackages="
	$pkgname-portalsconf
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/YaLTeR/niri/archive/refs/tags/v$pkgver.tar.gz
	niri-session.patch
	"
options="net" # rust crates

build() {
	cargo auditable build \
		--release \
		--no-default-features \
		--features dbus,xdp-gnome-screencast
}

check() {
	ulimit -n 4096 # Fails otherwise due to lack of file descriptors
	cargo test \
		--release \
		--no-default-features \
		--features dbus,xdp-gnome-screencast
}

package() {
	install -Dm755 target/release/niri -t "$pkgdir"/usr/bin/
	install -Dm644 resources/niri.desktop -t "$pkgdir"/usr/share/wayland-sessions/
	install -Dm644 resources/niri-portals.conf -t "$pkgdir"/usr/share/xdg-desktop-portal/
}

portalsconf() {
	pkgdesc="xdg-desktop-portal configuration of compatible portals for Niri"
	install_if="$pkgname=$pkgver-r$pkgrel"
	depends="xdg-desktop-portal xdg-desktop-portal-gnome"
	amove usr/share/xdg-desktop-portal/niri-portals.conf
}


sha512sums="
4609a218bfe1650e0b59517b9cd2a8139385098be0900c8e467629a6462415d2f660c2cb2dcdfdcb5ed687dda1e1d9081c0713d7d2875622d3ba07dea5c40a14  niri-25.05.tar.gz
f488ed2f316e96902c737a1104c425f2281349d519825c02a39205957ee65607730a69b4857d5a5803f43b74180ab4efef7fcb4eb8bfb75e042d09a3e22d1dff  niri-session.patch
"
