# Copyright 2026 Nadeŭka <me+oss@nadevko.cc>
# Distributed under the terms of the GNU General Public License v2
EAPI=8

CRATES='
	allocator-api2@0.2.21
	android_system_properties@0.1.5
	ansi-to-tui@7.0.0
	anyhow@1.0.102
	arc-swap@1.9.1
	async-trait@0.1.89
	autocfg@1.5.0
	basic-toml@0.1.10
	bitflags@1.3.2
	bitflags@2.11.1
	block-buffer@0.10.4
	bumpalo@3.20.2
	byteorder@1.5.0
	bytes@1.11.1
	cassowary@0.3.0
	castaway@0.2.4
	cc@1.2.60
	cfg_aliases@0.2.1
	cfg-if@1.0.4
	chacha20@0.10.0
	chrono@0.4.44
	codespan-reporting@0.13.1
	compact_str@0.8.1
	const-random-macro@0.1.16
	const-random@0.1.18
	convert_case@0.10.0
	core-foundation-sys@0.8.7
	cpufeatures@0.2.17
	cpufeatures@0.3.0
	crossbeam-channel@0.5.15
	crossbeam-utils@0.8.21
	crossterm_winapi@0.9.1
	crossterm@0.28.1
	crossterm@0.29.0
	crunchy@0.2.4
	crypto-common@0.1.7
	darling_core@0.23.0
	darling_macro@0.23.0
	darling@0.23.0
	deranged@0.5.8
	derive_more-impl@2.1.1
	derive_more@2.1.1
	digest@0.10.7
	dirs-sys@0.5.0
	dirs@6.0.0
	displaydoc@0.2.5
	dlv-list@0.5.2
	document-features@0.2.12
	either@1.15.0
	equivalent@1.0.2
	errno@0.3.14
	fastrand@2.4.1
	find-crate@0.6.3
	find-msvc-tools@0.1.9
	fluent-bundle@0.16.0
	fluent-langneg@0.13.1
	fluent-syntax@0.12.0
	fluent@0.17.0
	foldhash@0.1.5
	fsevent-sys@4.1.0
	futures-channel@0.3.32
	futures-core@0.3.32
	futures-executor@0.3.32
	futures-io@0.3.32
	futures-macro@0.3.32
	futures-sink@0.3.32
	futures-task@0.3.32
	futures-util@0.3.32
	futures@0.3.32
	generic-array@0.14.7
	getopts@0.2.24
	getrandom@0.2.17
	getrandom@0.4.2
	greetd_ipc@0.10.3
	greetd-stub@0.3.0
	hashbrown@0.14.5
	hashbrown@0.15.5
	hashbrown@0.17.0
	heck@0.5.0
	i18n-config@0.4.8
	i18n-embed-fl@0.10.0
	i18n-embed-impl@0.8.4
	i18n-embed@0.16.0
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.65
	id-arena@2.3.0
	ident_case@1.0.1
	indexmap@2.14.0
	indoc@2.0.7
	inotify-sys@0.1.5
	inotify@0.11.1
	instability@0.3.12
	intl_pluralrules@7.0.2
	intl-memoizer@0.5.3
	itertools@0.13.0
	itoa@1.0.18
	js-sys@0.3.95
	kqueue-sys@1.0.4
	kqueue@1.1.1
	lazy_static@1.5.0
	leb128fmt@0.1.0
	libc@0.2.186
	libredox@0.1.16
	linux-raw-sys@0.12.1
	linux-raw-sys@0.4.15
	litrs@1.0.0
	lock_api@0.4.14
	log@0.4.29
	lru@0.12.5
	memchr@2.8.0
	minimal-lexical@0.2.1
	mio@1.2.0
	nix@0.31.3
	nom@7.1.3
	notify-types@2.1.0
	notify@8.2.0
	nu-ansi-term@0.50.3
	num-conv@0.2.1
	num-traits@0.2.19
	once_cell@1.21.4
	option-ext@0.2.0
	ordered-multimap@0.7.3
	parking_lot_core@0.9.12
	parking_lot@0.12.5
	paste@1.0.15
	pin-project-lite@0.2.17
	powerfmt@0.2.0
	prettyplease@0.2.37
	proc-macro-error-attr2@2.0.0
	proc-macro-error2@2.0.1
	proc-macro2@1.0.106
	pure-rust-locales@0.8.2
	quote@1.0.45
	r-efi@6.0.0
	rand_core@0.10.1
	rand@0.10.1
	ratatui@0.29.0
	redox_syscall@0.5.18
	redox_users@0.5.2
	rust-embed-impl@8.11.0
	rust-embed-utils@8.11.0
	rust-embed@8.11.0
	rust-ini@0.21.3
	rustc_version@0.4.1
	rustc-hash@2.1.2
	rustix@0.38.44
	rustix@1.1.4
	rustversion@1.0.22
	ryu@1.0.23
	same-file@1.0.6
	scopeguard@1.2.0
	self_cell@1.2.2
	semver@1.0.28
	serde_core@1.0.228
	serde_derive@1.0.228
	serde_json@1.0.149
	serde_spanned@1.1.1
	serde@1.0.228
	sha2@0.10.9
	sharded-slab@0.1.7
	shlex@1.3.0
	signal-hook-mio@0.2.5
	signal-hook-registry@1.4.8
	signal-hook@0.3.18
	simdutf8@0.1.5
	slab@0.4.12
	smallvec@1.15.1
	socket2@0.6.3
	static_assertions@1.1.0
	strsim@0.11.1
	strum_macros@0.26.4
	strum@0.26.3
	symlink@0.1.0
	syn@2.0.117
	sys-locale@0.3.2
	tempfile@3.27.0
	termcolor@1.4.1
	thiserror-impl@1.0.69
	thiserror-impl@2.0.18
	thiserror@1.0.69
	thiserror@2.0.18
	thread_local@1.1.9
	time-core@0.1.8
	time-macros@0.2.27
	time@0.3.47
	tiny-keccak@2.0.2
	tinystr@0.8.3
	tokio-macros@2.7.0
	tokio@1.52.3
	toml_datetime@1.1.1+spec-1.1.0
	toml_parser@1.1.2+spec-1.1.0
	toml_writer@1.1.1+spec-1.1.0
	toml@0.5.11
	toml@1.1.2+spec-1.1.0
	tracing-appender@0.2.5
	tracing-attributes@0.1.31
	tracing-core@0.1.36
	tracing-log@0.2.0
	tracing-subscriber@0.3.23
	tracing@0.1.44
	type-map@0.5.1
	typenum@1.20.0
	unic-langid-impl@0.9.6
	unic-langid@0.9.6
	unicode-ident@1.0.24
	unicode-segmentation@1.13.2
	unicode-truncate@1.1.0
	unicode-width@0.1.14
	unicode-width@0.2.0
	unicode-xid@0.2.6
	utmp-raw@0.4.0
	utmp-rs@0.4.0
	uzers@0.12.2
	valuable@0.1.1
	version_check@0.9.5
	walkdir@2.5.0
	wasi@0.11.1+wasi-snapshot-preview1
	wasip2@1.0.3+wasi-0.2.9
	wasip3@0.4.0+wasi-0.3.0-rc-2026-01-06
	wasm-bindgen-macro-support@0.2.118
	wasm-bindgen-macro@0.2.118
	wasm-bindgen-shared@0.2.118
	wasm-bindgen@0.2.118
	wasm-encoder@0.244.0
	wasm-metadata@0.244.0
	wasmparser@0.244.0
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.11
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_gnullvm@0.53.1
	windows_aarch64_msvc@0.52.6
	windows_aarch64_msvc@0.53.1
	windows_i686_gnu@0.52.6
	windows_i686_gnu@0.53.1
	windows_i686_gnullvm@0.52.6
	windows_i686_gnullvm@0.53.1
	windows_i686_msvc@0.52.6
	windows_i686_msvc@0.53.1
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnu@0.53.1
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_gnullvm@0.53.1
	windows_x86_64_msvc@0.52.6
	windows_x86_64_msvc@0.53.1
	windows-core@0.62.2
	windows-implement@0.60.2
	windows-interface@0.59.3
	windows-link@0.2.1
	windows-result@0.4.1
	windows-strings@0.5.1
	windows-sys@0.59.0
	windows-sys@0.60.2
	windows-sys@0.61.2
	windows-targets@0.52.6
	windows-targets@0.53.5
	winnow@1.0.1
	wit-bindgen-core@0.51.0
	wit-bindgen-rust-macro@0.51.0
	wit-bindgen-rust@0.51.0
	wit-bindgen@0.51.0
	wit-bindgen@0.57.1
	wit-component@0.244.0
	wit-parser@0.244.0
	zerocopy-derive@0.7.35
	zerocopy@0.7.35
	zerofrom@0.1.7
	zeroize@1.8.2
	zerovec@0.11.6
	zmij@1.0.21
'
RUST_MIN_VER=1.91.0
inherit cargo tmpfiles

DESCRIPTION='Stylish graphical console greeter for greetd'
HOMEPAGE=https://github.com/tuigreet/tuigreet
SRC_URI="
	https://github.com/${PN}/${PN}/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"

LICENSE='Apache-2.0 CC0-1.0 GPL-3 GPL-3+ ISC MIT MPL-2.0 Unicode-3.0 ZLIB'
SLOT=0
KEYWORDS=~amd64

IUSE='+man'

DEPEND='
	acct-group/greetd
	acct-user/greetd
	gui-libs/greetd
'
RDEPEND="${DEPEND}"
BDEPEND='
	virtual/pkgconfig
	man? ( app-text/scdoc )
'

src_compile() {
	cargo_src_compile -p tuigreet

	if use man; then
		scdoc < contrib/man/tuigreet-1.scd > tuigreet.1 ||
			die 'Failed to generate man page with scdoc'
	fi
}

src_install() {
	# bins & wrappers
	cargo_src_install --path crates/tuigreet

	# man pages
	use man && doman tuigreet.1

	# configs
	insinto /etc/tuigreet
	newins contrib/example.config.toml config.toml

	# docs
	einstalldocs

	# permissions & security
	newtmpfiles - ${PN}.conf <<-EOF
		d /var/cache/tuigreet 0755 greetd greetd -
	EOF
}

pkg_postinst() {
	tmpfiles_process ${PN}.conf
}