diff --git a/www-apps/vaultwarden/Manifest b/www-apps/vaultwarden/Manifest new file mode 100644 index 0000000..32e073c --- /dev/null +++ b/www-apps/vaultwarden/Manifest @@ -0,0 +1,2 @@ +DIST vaultwarden-1.37.4-deps.tar.xz 50934576 BLAKE2B 0a3b9248ace7731e70519d48d2c4d3a32ceae50727dfefdcf65ef8acc82259de735430cf7c82c09dc9277e87dca10f6917215259f7ce1cb092f75506b297806c SHA512 c444f1f8d8e23602d75a9738319c533d81a3e66ce3fe695a8ee9b1fb583d5fb9dfe5bf3802a7db8f68658812b73bb19d817a870820d61361521af1c0d2160efd +DIST vaultwarden-1.37.4.tar.gz 693022 BLAKE2B 9fcb9c5f869171c0fa0cbb1cc2b8a216ccf37cb58854462210ff9fc64229738b99248fd28e6ccd7fc68af83edebc3be0323fc48417c846d3599708df6b431b1b SHA512 4b78d01c58c8b70eb60624cbb0881ca4d3ea11db0bcccf8ed2791ae144d7bdabfecd20ba41adc22ee1b7306787c5f7fadd0797287a922145e576f4a0242bb3e8 diff --git a/www-apps/vaultwarden/files/vaultwarden-1.33.2.confd b/www-apps/vaultwarden/files/vaultwarden-1.33.2.confd new file mode 100644 index 0000000..c06312e --- /dev/null +++ b/www-apps/vaultwarden/files/vaultwarden-1.33.2.confd @@ -0,0 +1,9 @@ +# Location of config file +#CONF_FILE=/etc/vaultwarden/vaultwarden.conf + +# User & group to start daemon as +#VW_USER=vaultwarden +#VW_GROUP=vaultwarden + +# Directory to store data in +#DATA_FOLDER=/var/lib/vaultwarden diff --git a/www-apps/vaultwarden/files/vaultwarden-1.33.2.initd b/www-apps/vaultwarden/files/vaultwarden-1.33.2.initd new file mode 100644 index 0000000..0be466c --- /dev/null +++ b/www-apps/vaultwarden/files/vaultwarden-1.33.2.initd @@ -0,0 +1,18 @@ +#!/sbin/openrc-run +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +export ENV_FILE="${CONF_FILE:-/etc/${RC_SVCNAME}/${RC_SVCNAME}.conf}" + +name="Vaultwarden" +description="Unofficial Bitwarden compatible password manager" +command="/usr/bin/${RC_SVCNAME}" +command_user="${VW_USER:-vaultwarden}:${VW_GROUP:-vaultwarden}" +command_background="true" +pidfile="/run/${RC_SVCNAME}.pid" +directory="${DATA_FOLDER:-/var/lib/${RC_SVCNAME}}" +umask=0027 + +depend() { + after net +} diff --git a/www-apps/vaultwarden/files/vaultwarden-1.33.2.logrotated b/www-apps/vaultwarden/files/vaultwarden-1.33.2.logrotated new file mode 100644 index 0000000..e1993a4 --- /dev/null +++ b/www-apps/vaultwarden/files/vaultwarden-1.33.2.logrotated @@ -0,0 +1,9 @@ +/var/log/vaultwarden/vaultwarden.log { + su vaultwarden vaultwarden + size 5M + compress + rotate 4 + copytruncate + missingok + notifempty +} diff --git a/www-apps/vaultwarden/files/vaultwarden-1.33.2.service b/www-apps/vaultwarden/files/vaultwarden-1.33.2.service new file mode 100644 index 0000000..a1d0bba --- /dev/null +++ b/www-apps/vaultwarden/files/vaultwarden-1.33.2.service @@ -0,0 +1,45 @@ +[Unit] +Description=Vaultwarden, unofficial Bitwarden compatible password manager +Documentation=https://github.com/dani-garcia/vaultwarden + +After=network.target +Wants=network.target + +[Service] +Environment=ENV_FILE=/etc/%N/%N.conf +ExecStart=/usr/bin/%N +WorkingDirectory=/var/lib/%N + +User=%N +Group=%N +UMask=0027 + +# Sandboxing and hardening systemd.exec(5) +PrivateUsers=yes +ProtectClock=yes +ProtectHostname=yes +ProtectKernelTunables=yes +ProtectKernelModules=yes +ProtectKernelLogs=yes +ProtectControlGroups=yes +RestrictNamespaces=yes +LockPersonality=yes +MemoryDenyWriteExecute=yes +RestrictSUIDSGID=yes +RemoveIPC=yes +RestrictRealtime=yes +PrivateTmp=true +PrivateDevices=true +ProtectHome=true + +# set entire file system to read only except following paths +ProtectSystem=strict +ReadWritePaths=/var/lib/%N -/var/log/%N/%N.log +CacheDirectory=%N + +# Set reasonable connection and process limits +LimitNOFILE=1048576 +LimitNPROC=64 + +[Install] +WantedBy=multi-user.target diff --git a/www-apps/vaultwarden/files/vaultwarden-envfile-1.34.1.patch b/www-apps/vaultwarden/files/vaultwarden-envfile-1.34.1.patch new file mode 100644 index 0000000..dc98a7c --- /dev/null +++ b/www-apps/vaultwarden/files/vaultwarden-envfile-1.34.1.patch @@ -0,0 +1,53 @@ +As upstream defaults create directories where binary is executed (/usr/bin/), this patch is needed to change paths to Gentoo specific locations +--- a/.env.template ++++ b/.env.template +@@ -5,10 +5,6 @@ + ## Be aware that most of these settings will be overridden if they were changed + ## in the admin interface. Those overrides are stored within DATA_FOLDER/config.json . + ## +-## By default, Vaultwarden expects for this file to be named ".env" and located +-## in the current working directory. If this is not the case, the environment +-## variable ENV_FILE can be set to the location of this file prior to starting +-## Vaultwarden. + + #################### + ### Data folders ### +@@ -23,17 +19,17 @@ + ## When using an external location, make sure to set TMP_FOLDER, + ## TEMPLATES_FOLDER, and DATABASE_URL to local paths and/or a remote database + ## location. +-# DATA_FOLDER=data ++DATA_FOLDER=/var/lib/vaultwarden + + ## Individual folders, these override %DATA_FOLDER% + # RSA_KEY_FILENAME=data/rsa_key +-# ICON_CACHE_FOLDER=data/icon_cache ++ICON_CACHE_FOLDER=/var/cache/vaultwarden/icon_cache + # ATTACHMENTS_FOLDER=data/attachments + # SENDS_FOLDER=data/sends + + ## Temporary folder used for storing temporary file uploads + ## Must be a local path. +-# TMP_FOLDER=data/tmp ++TMP_FOLDER=/tmp/vaultwarden + + ## HTML template overrides data folder + ## Must be a local path. +@@ -42,7 +38,7 @@ + # RELOAD_TEMPLATES=false + + ## Web vault settings +-# WEB_VAULT_FOLDER=web-vault/ ++WEB_VAULT_FOLDER=/usr/share/webapps/vaultwarden-web + # WEB_VAULT_ENABLED=true + + ######################### +@@ -386,7 +382,7 @@ + # USE_SYSLOG=false + + ## Logging to file +-# LOG_FILE=/path/to/log ++LOG_FILE=/var/log/vaultwarden/vaultwarden.log + + ## Log level + ## Change the verbosity of the log output diff --git a/www-apps/vaultwarden/files/vaultwarden-tmpfiles-1.33.2.conf b/www-apps/vaultwarden/files/vaultwarden-tmpfiles-1.33.2.conf new file mode 100644 index 0000000..59326b8 --- /dev/null +++ b/www-apps/vaultwarden/files/vaultwarden-tmpfiles-1.33.2.conf @@ -0,0 +1,5 @@ +# Fields: type; path; mode; uid; gid; age; argument +# tmpfiled.d(5) +d /var/cache/vaultwarden 0750 vaultwarden vaultwarden +d /tmp/vaultwarden 0750 vaultwarden vaultwarden 1d +f /var/log/vaultwarden/vaultwarden.log 0640 vaultwarden vaultwarden diff --git a/www-apps/vaultwarden/vaultwarden-1.37.4.ebuild b/www-apps/vaultwarden/vaultwarden-1.37.4.ebuild new file mode 100644 index 0000000..605d2fe --- /dev/null +++ b/www-apps/vaultwarden/vaultwarden-1.37.4.ebuild @@ -0,0 +1,153 @@ +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit cargo check-reqs readme.gentoo-r1 systemd tmpfiles + +DESCRIPTION="Unofficial Bitwarden compatible password manager" +HOMEPAGE="https://github.com/dani-garcia/vaultwarden" + +if [[ ${PV} == 9999* ]]; then + inherit git-r3 + EGIT_REPO_URI="https://github.com/dani-garcia/vaultwarden.git" +else + SRC_URI=" + https://github.com/dani-garcia/${PN}/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz + https://github.com/gentoo-crate-dist/${PN}/releases/download/${PV}/${P}-crates.tar.xz -> ${P}-deps.tar.xz +" + KEYWORDS="~amd64 ~arm64" +fi + +LICENSE="AGPL-3" +# Dependent crate licenses +LICENSE+=" 0BSD Apache-2.0 BSD ISC MIT MPL-2.0 Unicode-3.0" + +SLOT="0" +IUSE="cli mysql postgres +sqlite +web" +REQUIRED_USE="|| ( mysql postgres sqlite )" + +RDEPEND=" + acct-user/vaultwarden + acct-group/vaultwarden + dev-libs/openssl:= + cli? ( app-admin/bitwarden-cli-bin ) + mysql? ( dev-db/mysql-connector-c:= ) + postgres? ( dev-db/postgresql:* ) + sqlite? ( dev-db/sqlite:3 ) + web? ( www-apps/vaultwarden-web ) +" + +DEPEND="${RDEPEND}" +BDEPEND="virtual/pkgconfig" + +RUST_MIN_VER="1.95.0" +QA_FLAGS_IGNORED="usr/bin/${PN}" +QA_PRESTRIPPED="usr/bin/${PN}" + +PATCHES=( + "${FILESDIR}"/vaultwarden-envfile-1.34.1.patch +) + +CHECKREQS_MEMORY=3G +CHECKREQS_DISK_BUILD=2G + +DOC_CONTENTS="\n + Configuration file: /etc/${PN}/${PN}.conf\n + Data directory: /var/lib/${PN}\n + Log file: /var/log/${PN}/${PN}.log\n + Default endpoint: http://127.0.0.1:8000\n + Admin endpoint: http://127.0.0.1:8000/admin\n + \n + MySQL & PostgreSQL users must set DATABASE_URL in config\n + \n + Please find the documentation at https://github.com/dani-garcia/vaultwarden/wiki\n +" + +pkg_setup() { + check-reqs_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() { + default + if use !web; then + sed -i \ + -e 's|^# WEB_VAULT_ENABLED=true|WEB_VAULT_ENABLED=false|g;' \ + .env.template || die + fi + + if use mysql || use postgres; then + declare -a DB_UNIT + use mysql && DB_UNIT+=( + mariadb.service + mysqld.service + ) + use postgres && DB_UNIT+=( + postgresql-{14..19}.service + ) + cat <<-EOF > "${T}/${PN}-db.conf" + [Unit] + After=${DB_UNIT[@]} + Wants=${DB_UNIT[@]} + EOF + fi + +} + +src_configure() { + local myfeatures=( + $(usev sqlite sqlite_system) + $(usev mysql) + $(usev postgres postgresql ) + ) + cargo_src_configure +} + +src_compile() { + # https://github.com/dani-garcia/vaultwarden/blob/main/build.rs + [[ ${PV} != 9999* ]] && export VW_VERSION="${PV}" + cargo_src_compile +} + +src_install() { + dobin "$(cargo_target_dir)/${PN}" + systemd_newunit "${FILESDIR}"/vaultwarden-1.33.2.service "${PN}".service + if [[ -f "${T}/${PN}-db.conf" ]]; then + local UNIT_DIR="$(systemd_get_systemunitdir)" + insinto "${UNIT_DIR#"${EPREFIX}"}/${PN}".service.d + doins "${T}/${PN}-db.conf" + fi + newinitd "${FILESDIR}"/vaultwarden-1.33.2.initd "${PN}" + newconfd "${FILESDIR}"/vaultwarden-1.33.2.confd "${PN}" + newtmpfiles "${FILESDIR}"/vaultwarden-tmpfiles-1.33.2.conf "${PN}".conf + insinto /etc/logrotate.d + newins "${FILESDIR}/"vaultwarden-1.33.2.logrotated "${PN}" + keepdir /var/lib/"${PN}" + fowners "${PN}":"${PN}" /var/lib/"${PN}" + fperms 750 /var/lib/"${PN}" + keepdir /var/log/"${PN}" + fowners "${PN}":"${PN}" /var/log/"${PN}" + fperms 750 /var/log/"${PN}" + # Do last due to insopts modifications + insopts -m0640 -g "${PN}" + insinto /etc/"${PN}" + newins .env.template "${PN}".conf + + readme.gentoo_create_doc + einstalldocs +} + +pkg_postinst() { + tmpfiles_process "${PN}".conf + readme.gentoo_print_elog +}