# Template file for 'vaultwarden'
pkgname=vaultwarden
version=1.33.2
revision=1
build_style=cargo
configure_args="--features sqlite,mysql,postgresql"
hostmakedepends="pkg-config"
makedepends="openssl-devel libmysqlclient-devel postgresql-libs-devel
 sqlite-devel zlib-devel"
short_desc="Unofficial Bitwarden compatible server written in Rust"
maintainer="Joel Beckmeyer <joel@beckmeyer.us>"
license="AGPL-3.0-only"
homepage="https://github.com/dani-garcia/vaultwarden"
changelog="https://github.com/dani-garcia/vaultwarden/releases"
distfiles="https://github.com/dani-garcia/vaultwarden/archive/${version}.tar.gz"
checksum=b0a412bd5fa857a82dd12fe7ccaad5ac647c4ac932d873218c6eb2408e705682

system_accounts="_vaultwarden"
_vaultwarden_homedir="/var/lib/vaultwarden"

make_dirs="/var/lib/vaultwarden 0750 _vaultwarden _vaultwarden"

# fails to build on i686 with default release profile, see
# https://github.com/dani-garcia/vaultwarden/issues/4320
if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
	export CARGO_PROFILE_RELEASE_LTO=thin
	export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16
	disable_parallel_build=yes
fi

post_install() {
	vsconf .env.template vaultwarden.conf
	vsv vaultwarden
	vlicense LICENSE.txt
}
