From 33983466f816a2d76d5cc714edcf8d93f10bacf7 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Sat, 20 Jun 2026 13:19:35 -0400 Subject: [PATCH] fix: dynamically link rocksdb on dynamic nix builds Fixes liburing error. --- nix/packages/continuwuity.nix | 22 ++++++++++++++++++++-- nix/packages/default.nix | 3 +++ nix/packages/rocksdb.nix | 12 +++++++----- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/nix/packages/continuwuity.nix b/nix/packages/continuwuity.nix index c10312947..51a34b849 100644 --- a/nix/packages/continuwuity.nix +++ b/nix/packages/continuwuity.nix @@ -2,9 +2,10 @@ lib, self, stdenv, - liburing, + rocksdb, craneLib, pkg-config, + liburing, rustPlatform, cargoExtraArgs ? "", rustflags ? "", @@ -36,12 +37,17 @@ let pkg-config rustPlatform.bindgenHook ]; + buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ liburing ]; - doCheck = false; + env = { CARGO_PROFILE = profile; RUSTFLAGS = rustflags; } + // (lib.optionalAttrs (rocksdb != null) { + ROCKSDB_INCLUDE_DIR = "${rocksdb}/include"; + ROCKSDB_LIB_DIR = "${rocksdb}/lib"; + }) // (lib.optionalAttrs (target_cpu != null) { TARGET_CPU = target_cpu; }); @@ -52,6 +58,18 @@ craneLib.buildPackage ( inherit cargoExtraArgs; cargoArtifacts = craneLib.buildDepsOnly attrs; + # Needed to make continuwuity link to rocksdb + postFixup = lib.optionalString (stdenv.hostPlatform.isLinux && rocksdb != null) '' + old_rpath="$(patchelf --print-rpath $out/bin/conduwuit)" + extra_rpath="${ + lib.makeLibraryPath [ + rocksdb + ] + }" + + patchelf --set-rpath "$old_rpath:$extra_rpath" $out/bin/conduwuit + ''; + meta = { description = "A community-driven Matrix homeserver in Rust"; mainProgram = "conduwuit"; diff --git a/nix/packages/default.nix b/nix/packages/default.nix index d73b4b022..37915b079 100644 --- a/nix/packages/default.nix +++ b/nix/packages/default.nix @@ -36,7 +36,10 @@ default = pkgs.callPackage ./continuwuity.nix { inherit self craneLib; + liburing = (if isStatic then pkgs.pkgsStatic else pkgs).liburing; + rocksdb = if isStatic then null else pkgs.callPackage ./rocksdb.nix { }; + # extra features via `cargoExtraArgs` cargoExtraArgs = "-F http3"; # extra RUSTFLAGS via `rustflags` diff --git a/nix/packages/rocksdb.nix b/nix/packages/rocksdb.nix index 4f5c9224b..b4427dbc4 100644 --- a/nix/packages/rocksdb.nix +++ b/nix/packages/rocksdb.nix @@ -1,5 +1,7 @@ { - stdenv, + # stdenv, + # enableJemalloc ? stdenv.hostPlatform.isLinux, + enableJemalloc ? false, rocksdb, fetchFromGitea, rust-jemalloc-sys-unprefixed, @@ -13,16 +15,16 @@ # # [1]: https://github.com/tikv/jemallocator/blob/ab0676d77e81268cd09b059260c75b38dbef2d51/jemalloc-sys/src/env.rs#L17 jemalloc = rust-jemalloc-sys-unprefixed; - enableJemalloc = stdenv.hostPlatform.isLinux; + inherit enableJemalloc; }).overrideAttrs ({ - version = "continuwuity-v0.5.0-unstable-2026-03-27"; + version = "continuwuity-v0.5.0-unstable-2026-05-19"; src = fetchFromGitea { domain = "forgejo.ellis.link"; owner = "continuwuation"; repo = "rocksdb"; - rev = "463f47afceebfe088f6922420265546bd237f249"; - hash = "sha256-1ef75IDMs5Hba4VWEyXPJb02JyShy5k4gJfzGDhopRk="; + rev = "3756b2b905e13216d8b56bcc783d814e7b073aff"; + hash = "sha256-rSv4fr2bf9JJwdodgeuPCuceeh7k97KVxrAOC0wyPQY="; }; # We have this already at https://forgejo.ellis.link/continuwuation/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155