···
13
+
enableBlurhashing ? true,
14
+
# upstream tuwunel enables jemalloc by default, so we follow suit
15
+
enableJemalloc ? true,
17
+
enableLiburing ? stdenv.hostPlatform.isLinux,
22
+
rust-jemalloc-sys' = rust-jemalloc-sys.override {
23
+
unprefixed = !stdenv.hostPlatform.isDarwin;
25
+
# tuwunel uses a modified version of rocksdb. The following overrides take a lot from the
27
+
# https://github.com/matrix-construct/tuwunel/blob/main/flake.nix#L54
30
+
inherit enableLiburing;
31
+
# rocksdb does not support prefixed jemalloc, which is required on darwin
32
+
enableJemalloc = enableJemalloc && !stdenv.hostPlatform.isDarwin;
33
+
jemalloc = rust-jemalloc-sys';
37
+
src = fetchFromGitHub {
38
+
owner = "matrix-construct";
40
+
# The commit on the rocksdb fork, tuwunel-changes branch referenced by the upstream
41
+
# tuwunel flake.lock:
42
+
# https://github.com/matrix-construct/tuwunel/blob/main/flake.lock#L557C17-L557C57
43
+
rev = "cf7f65d0b377af019661c240f9165b3ef60640c3";
44
+
hash = "sha256-ZSjvAZBfZkJrBIpw8ANZMbJVb8AeuogvuAipGVE4Qe4=";
46
+
version = "tuwunel-changes";
51
+
# no real reason to have snappy or zlib, no one uses this
55
+
# we dont need to use ldb or sst_dump (core_tools)
56
+
"-DWITH_CORE_TOOLS=1"
57
+
# we dont need to build rocksdb tests
59
+
# we use rust-rocksdb via C interface and dont need C++ RTTI
61
+
# this doesn't exist in RocksDB, and USE_SSE is deprecated for
64
+
# PORTABLE will get set in main/default.nix
68
+
# no real reason to have snappy, no one uses this
72
+
# we dont need to use ldb or sst_dump (core_tools)
73
+
"-DWITH_CORE_TOOLS=0"
74
+
# we dont need trace tools
75
+
"-DWITH_TRACE_TOOLS=0"
76
+
# we dont need to build rocksdb tests
78
+
# we use rust-rocksdb via C interface and dont need C++ RTTI
81
+
outputs = [ "out" ];
86
+
rustPlatform.buildRustPackage (finalAttrs: {
87
+
pname = "matrix-tuwunel";
90
+
src = fetchFromGitHub {
91
+
owner = "matrix-construct";
93
+
tag = "v${finalAttrs.version}";
94
+
hash = "sha256-YiZuCdSs3f4Hlfdzhz/B/u8GLf8VPgaLN8KMPLjFoVk=";
97
+
useFetchCargoVendor = true;
98
+
cargoHash = "sha256-y3JXG/5a9x/KM1PxGW1qmpCeRFvWXWHHplCi+MdjhQ8=";
100
+
nativeBuildInputs = [
102
+
rustPlatform.bindgenHook
110
+
++ lib.optional enableJemalloc rust-jemalloc-sys'
111
+
++ lib.optional enableLiburing liburing;
114
+
ZSTD_SYS_USE_PKG_CONFIG = true;
115
+
ROCKSDB_INCLUDE_DIR = "${rocksdb'}/include";
116
+
ROCKSDB_LIB_DIR = "${rocksdb'}/lib";
119
+
buildNoDefaultFeatures = true;
120
+
# See https://github.com/matrix-construct/tuwunel/blob/main/src/main/Cargo.toml
121
+
# for available features.
122
+
# We enable all default features except jemalloc, blurhashing, and io_uring, which
123
+
# we guard behind our own (default-enabled) flags.
126
+
"brotli_compression"
131
+
"release_max_log_level"
136
+
++ lib.optional enableBlurhashing "blurhashing"
137
+
++ lib.optional enableJemalloc [
141
+
++ lib.optional enableLiburing "io_uring";
144
+
rocksdb = rocksdb'; # make used rocksdb version available (e.g., for backup scripts)
145
+
updateScript = nix-update-script { };
149
+
description = "Matrix homeserver written in Rust, official successor to conduwuit";
150
+
homepage = "https://github.com/matrix-construct/tuwunel";
151
+
changelog = "https://github.com/matrix-construct/tuwunel/releases/tag/v${finalAttrs.version}";
152
+
license = lib.licenses.asl20;
153
+
maintainers = with lib.maintainers; [
156
+
mainProgram = "tuwunel";