summaryrefslogtreecommitdiff
path: root/app-misc/yazi/yazi-9999.ebuild
blob: 8cb428c7838f4187a3f23d16a35c361fbc0e3550 (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
# Copyright 2024-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES=" "

RUST_MIN_VER="1.95.0"

inherit cargo desktop optfeature shell-completion xdg

DESCRIPTION="Blazing fast terminal file manager written in Rust, based on async I/O"
HOMEPAGE="https://yazi-rs.github.io"
if [[ "${PV}" == 9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/sxyazi/yazi.git"
else
	SRC_URI="https://github.com/sxyazi/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/gentoo-crate-dist/${PN}/releases/download/v${PV}/${P}-crates.tar.xz
	${CARGO_CRATE_URIS}
"
	KEYWORDS="~amd64 ~arm64"
fi

# both the LICENSE file and LICENSE-ICONS are MIT
LICENSE="MIT"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD Boost-1.0 BlueOak-1.0.0 CC0-1.0 CDLA-Permissive-2.0
	ISC MIT MPL-2.0 Unicode-3.0 ZLIB
"
SLOT="0"

IUSE="+cli"

DEPEND="
	dev-libs/oniguruma:=
"
# apply-crates-fixes start
DEPEND+="
	>=dev-libs/jemalloc-5.3.1:=
"
BDEPEND="
	virtual/pkgconfig
"
# apply-crates-fixes end

RDEPEND="
	${DEPEND}
	cli? ( dev-vcs/git )
"

DOCS=(
	"CHANGELOG.md"
	"README.md"
	yazi-config/preset/
)

QA_FLAGS_IGNORED="
	usr/bin/ya.*
"

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

src_prepare() {
	sed -i -r 's/strip\s+= true/strip = false/' Cargo.toml || die "Sed failed!"
	eapply_user
}

src_compile() {
	# apply-crates-fixes start
	# unvendoring for tikv-jemalloc-sys crate
	export JEMALLOC_OVERRIDE="${ESYSROOT}/usr/$(get_libdir)/libjemalloc.so"
	# https://github.com/tikv/jemallocator/issues/19
	export CARGO_FEATURE_UNPREFIXED_MALLOC_ON_SUPPORTED_PLATFORMS=1
	# apply-crates-fixes end

	# workaround for GCC 15 issues:
	# unvendor libonig from rust-onig. see bugs 943785, 945008
	export RUSTONIG_SYSTEM_LIBONIG=1
	# generate shell completions from the actual CLI definitions
	export YAZI_GEN_COMPLETIONS=true
	# silences vergen
	export YAZI_NO_GITCL=1

	local myargs=(
		--package yazi-fm
	)

	use cli && myargs+=( --package yazi-cli )

	cargo_src_compile "${myargs[@]}"
}

src_test() {
	export RUSTONIG_SYSTEM_LIBONIG=1
	cargo_src_test --workspace
}

src_install() {
	dobin "$(cargo_target_dir)/${PN}"
	use cli && dobin "$(cargo_target_dir)/ya"

	newbashcomp "${S}/yazi-boot/completions/${PN}.bash" "${PN}"
	dozshcomp "${S}/yazi-boot/completions/_${PN}"
	dofishcomp "${S}/yazi-boot/completions/${PN}.fish"

	if use cli; then
		newbashcomp "${S}/yazi-cli/completions/ya.bash" "ya"
		dozshcomp "${S}/yazi-cli/completions/_ya"
		dofishcomp "${S}/yazi-cli/completions/ya.fish"
	fi

	domenu "assets/${PN}.desktop"
	newicon assets/logo.png yazi.png
	einstalldocs
}

pkg_postinst() {
	xdg_pkg_postinst

	optfeature "Nerd Font icons" media-fonts/symbols-nerd-font
	optfeature "video thumbnails" media-video/ffmpeg
	optfeature "archive extraction and preview" app-arch/7zip
	optfeature "JSON preview" app-misc/jq
	optfeature "PDF preview" app-text/poppler
	optfeature "file searching" sys-apps/fd
	optfeature "file content searching" sys-apps/ripgrep
	optfeature "quick file subtree navigation" ">=app-shells/fzf-0.53.0"
	optfeature "historical directory navigation" "app-shells/zoxide >=app-shells/fzf-0.53.0"
	optfeature "Font, HEIC and JPEG XL preview" ">=media-gfx/imagemagick-7.1.1"

	optfeature_header "Install one of these for clipboard support:"
	optfeature "Wayland clipboard support" gui-apps/wl-clipboard
	optfeature "X11 clipboard support" x11-misc/xclip x11-misc/xsel
}