···
+
enableBlurhashing ? true,
+
# upstream tuwunel enables jemalloc by default, so we follow suit
+
enableLiburing ? stdenv.hostPlatform.isLinux,
+
rust-jemalloc-sys' = rust-jemalloc-sys.override {
+
unprefixed = !stdenv.hostPlatform.isDarwin;
+
# tuwunel uses a modified version of rocksdb. The following overrides take a lot from the
+
# https://github.com/matrix-construct/tuwunel/blob/main/flake.nix#L54
+
inherit enableLiburing;
+
# rocksdb does not support prefixed jemalloc, which is required on darwin
+
enableJemalloc = enableJemalloc && !stdenv.hostPlatform.isDarwin;
+
jemalloc = rust-jemalloc-sys';
+
src = fetchFromGitHub {
+
owner = "matrix-construct";
+
# The commit on the rocksdb fork, tuwunel-changes branch referenced by the upstream
+
# https://github.com/matrix-construct/tuwunel/blob/main/flake.lock#L557C17-L557C57
+
rev = "cf7f65d0b377af019661c240f9165b3ef60640c3";
+
hash = "sha256-ZSjvAZBfZkJrBIpw8ANZMbJVb8AeuogvuAipGVE4Qe4=";
+
version = "tuwunel-changes";
+
# no real reason to have snappy or zlib, no one uses this
+
# we dont need to use ldb or sst_dump (core_tools)
+
# we dont need to build rocksdb tests
+
# we use rust-rocksdb via C interface and dont need C++ RTTI
+
# this doesn't exist in RocksDB, and USE_SSE is deprecated for
+
# PORTABLE will get set in main/default.nix
+
# no real reason to have snappy, no one uses this
+
# we dont need to use ldb or sst_dump (core_tools)
+
# we dont need trace tools
+
# we dont need to build rocksdb tests
+
# we use rust-rocksdb via C interface and dont need C++ RTTI
+
rustPlatform.buildRustPackage (finalAttrs: {
+
pname = "matrix-tuwunel";
+
src = fetchFromGitHub {
+
owner = "matrix-construct";
+
tag = "v${finalAttrs.version}";
+
hash = "sha256-YiZuCdSs3f4Hlfdzhz/B/u8GLf8VPgaLN8KMPLjFoVk=";
+
useFetchCargoVendor = true;
+
cargoHash = "sha256-y3JXG/5a9x/KM1PxGW1qmpCeRFvWXWHHplCi+MdjhQ8=";
+
rustPlatform.bindgenHook
+
++ lib.optional enableJemalloc rust-jemalloc-sys'
+
++ lib.optional enableLiburing liburing;
+
ZSTD_SYS_USE_PKG_CONFIG = true;
+
ROCKSDB_INCLUDE_DIR = "${rocksdb'}/include";
+
ROCKSDB_LIB_DIR = "${rocksdb'}/lib";
+
buildNoDefaultFeatures = true;
+
# See https://github.com/matrix-construct/tuwunel/blob/main/src/main/Cargo.toml
+
# for available features.
+
# We enable all default features except jemalloc, blurhashing, and io_uring, which
+
# we guard behind our own (default-enabled) flags.
+
"release_max_log_level"
+
++ lib.optional enableBlurhashing "blurhashing"
+
++ lib.optional enableJemalloc [
+
++ lib.optional enableLiburing "io_uring";
+
rocksdb = rocksdb'; # make used rocksdb version available (e.g., for backup scripts)
+
updateScript = nix-update-script { };
+
description = "Matrix homeserver written in Rust, official successor to conduwuit";
+
homepage = "https://github.com/matrix-construct/tuwunel";
+
changelog = "https://github.com/matrix-construct/tuwunel/releases/tag/v${finalAttrs.version}";
+
license = lib.licenses.asl20;
+
maintainers = with lib.maintainers; [
+
mainProgram = "tuwunel";