# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=greetd-tuigreet
_projname=tuigreet
pkgver=0.9.1
pkgrel=0
pkgdesc="Graphical console greeter for greetd"
url="https://github.com/apognu/tuigreet"
# riscv64: blocked by cargo
# s390x: no desktop on this arch
# loongarch64: fail to build nix
arch="all !riscv64 !s390x !loongarch64"
license="GPL-3.0"
depends="greetd"
makedepends="cargo scdoc cargo-auditable"
pkgusers="greetd"
subpackages="$pkgname-doc"
source="https://github.com/apognu/tuigreet/archive/$pkgver/tuigreet-$pkgver.tar.gz"
builddir="$srcdir/$_projname-$pkgver"
options="!check"  # no tests provided

export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen

	scdoc < contrib/man/tuigreet-1.scd > contrib/man/tuigreet.1
}

check() {
	cargo test --frozen
}

package() {
	install -D -m755 target/release/tuigreet -t "$pkgdir"/usr/bin/
	install -D -m644 contrib/man/tuigreet.1 -t "$pkgdir"/usr/share/man/man1/

	install -d -m700 -o greetd -g root "$pkgdir"/var/cache/tuigreet
}

sha512sums="
f63017c5ec93596efe78a1e313848d0a0ba376eac891037e60ddee3da0367038b8d487e07fdd8d536bbc251e6065141bd1314817769ef4cbeabb7f3fedd99d12  tuigreet-0.9.1.tar.gz
"
