View Raw Ebuild
EAPI=8
inherit cargo
DESCRIPTION="High Performance Matrix Homeserver in Rust"
HOMEPAGE="https://github.com/matrix-construct/tuwunel"
SRC_URI="
https://github.com/matrix-construct/tuwunel/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
https://lmkra.dev/gentoo/${P}-deps.tar.xz
"
S="${WORKDIR}/${P}/src/main"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64"
IUSE="+brotli +element +gzip +io-uring jemalloc systemd +zstd debug"
RDEPEND="
acct-user/matrix
!net-im/conduit
!net-im/conduwuit
"
BDEPEND="
llvm-core/clang
>=dev-lang/rust-1.88.0:*
"
# rust does not use *FLAGS from make.conf, silence portage warning
# update with proper path to binaries this crate installs, omit leading /
QA_FLAGS_IGNORED="usr/bin/${PN}"
src_prepare() {
ln -s "${WORKDIR}/vendor/" "${WORKDIR}/${PN}-${PV}/vendor" || die
sed -i "${ECARGO_HOME}/config.toml" -e '/source.crates-io/d' || die
sed -i "${ECARGO_HOME}/config.toml" -e '/replace-with = "gentoo"/d' || die
sed -i "${ECARGO_HOME}/config.toml" -e '/local-registry = "\/nonexistent"/d' || die
cat "${WORKDIR}/vendor/vendor-config.toml" >> "${ECARGO_HOME}/config.toml" || die
eapply_user
}
src_configure() {
local myfeatures=(
media_thumbnail
url_preview
$(usev jemalloc)
$(usev systemd)
$(usev brotli brotli_compression)
$(usev element element_hacks)
$(usev gzip gzip_compression)
$(usev io-uring io_uring)
$(usev !debug release_max_log_level)
$(usev zstd zstd_compression)
)
rust_pkg_setup
cargo_src_configure --no-default-features --frozen
}
src_install() {
cargo_src_install
keepdir /var/{lib,log}/tuwunel
fowners matrix:matrix /var/{lib,log}/tuwunel
fperms 700 /var/{lib,log}/tuwunel
newconfd "${FILESDIR}"/tuwunel.conf-r1 tuwunel
newinitd "${FILESDIR}"/tuwunel.init-r1 tuwunel
insinto /etc/tuwunel
newins "${WORKDIR}/${P}"/tuwunel-example.toml tuwunel.toml
insinto /etc/logrotate.d
newins "${FILESDIR}"/tuwunel.logrotate-r1 tuwunel
}