summaryrefslogtreecommitdiff
path: root/gui-wm/niri/niri-25.11-r1.ebuild
blob: 8033f22ad30fe2e64d6680fb456b915ba6e08ec2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Copyright 2024-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES="
"

LLVM_COMPAT=( {18..21} )
RUST_MIN_VER="1.82.0"

inherit cargo llvm-r2 optfeature shell-completion systemd

DESCRIPTION="Scrollable-tiling Wayland compositor"
HOMEPAGE="https://github.com/niri-wm/niri"

if [[ ${PV} == 9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/niri-wm/niri.git"
else
	SRC_URI="
		https://github.com/niri-wm/niri/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
		https://github.com/niri-wm/niri/releases/download/v${PV}/${P}-vendored-dependencies.tar.xz
		${CARGO_CRATE_URIS}
	"
	KEYWORDS="~amd64"

	# used for version string
	export NIRI_BUILD_COMMIT="b35bcae"
fi

LICENSE="GPL-3+"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD ISC MIT MPL-2.0
	Unicode-3.0 ZLIB
"
SLOT="0"
IUSE="+dbus screencast systemd"
REQUIRED_USE="
	screencast? ( dbus )
	systemd? ( dbus )
"

DEPEND="
	dev-libs/glib:2
	dev-libs/libinput:=
	dev-libs/wayland
	<media-libs/libdisplay-info-0.4.0:=
	media-libs/mesa
	sys-auth/seatd:=
	virtual/libudev:=
	x11-libs/cairo
	x11-libs/libxkbcommon
	x11-libs/pango
	x11-libs/pixman
	screencast? ( media-video/pipewire:= )
"
RDEPEND="
	${DEPEND}
	screencast? ( sys-apps/xdg-desktop-portal-gnome )
"
# libclang is required for bindgen
BDEPEND="
	screencast? ( $(llvm_gen_dep 'llvm-core/clang:${LLVM_SLOT}') )
"

ECARGO_VENDOR="${WORKDIR}/vendor"

QA_FLAGS_IGNORED="usr/bin/niri"

pkg_setup() {
	llvm-r2_pkg_setup
	rust_pkg_setup
}

src_unpack() {
	if [[ ${PV} == 9999 ]]; then
		git-r3_src_unpack
		cargo_live_src_unpack
	else
		cargo_src_unpack
	fi
}

src_prepare() {
	sed -i 's/git = "[^ ]*"/version = "*"/' Cargo.toml || die
	# niri-session doesn't work on OpenRC
	if ! use systemd; then
		local cmd="niri --session"
		use dbus && cmd="dbus-run-session $cmd"
		sed -i "s/niri-session/$cmd/" resources/niri.desktop || die
	fi
	default
}

src_configure() {
	local myfeatures=(
		$(usev dbus)
		$(usev screencast xdp-gnome-screencast)
		$(usev systemd)
	)
	cargo_src_configure --no-default-features
}

src_compile() {
	cargo_src_compile

	"$(cargo_target_dir)"/niri completions bash > niri  || die
	"$(cargo_target_dir)"/niri completions fish > niri.fish || die
	"$(cargo_target_dir)"/niri completions zsh > _niri || die
}

src_install() {
	cargo_src_install

	dobin resources/niri-session
	systemd_douserunit resources/niri{.service,-shutdown.target}

	insinto /usr/share/wayland-sessions
	doins resources/niri.desktop

	insinto /usr/share/xdg-desktop-portal
	doins resources/niri-portals.conf

	dobashcomp niri
	dofishcomp niri.fish
	dozshcomp _niri
}

src_test() {
	# tests create a wayland socket in the xdg runtime dir
	local -x XDG_RUNTIME_DIR="${T}/xdg"
	mkdir "${XDG_RUNTIME_DIR}" || die
	chmod 0700 "${XDG_RUNTIME_DIR}" || die

	# bug 950626
	# https://yalter.github.io/niri/Packaging-niri.html#running-tests
	local -x RAYON_NUM_THREADS=2
	local skip=(
		# requires surfacesless EGL to be available
		--skip=::egl
	)
	cargo_src_test -- --test-threads=2 "${skip[@]}"
}

pkg_postinst() {
	optfeature "Xwayland support" "gui-apps/xwayland-satellite"
	optfeature_header "Default applications"
	optfeature "Application launcher" "gui-apps/fuzzel"
	optfeature "Status bar" "gui-apps/waybar"
	optfeature "Terminal" "x11-terms/alacritty"
}