Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
1.9 KiB
Nix
Raw Permalink Normal View History

2026-04-03 10:56:45 -04:00
{
lib,
self,
2026-04-03 11:12:49 -04:00
stdenv,
liburing,
2026-04-03 10:56:45 -04:00
craneLib,
pkg-config,
rustPlatform,
2026-04-03 11:02:45 -04:00
cargoExtraArgs ? "",
rustflags ? "",
2026-05-11 15:05:57 +02:00
target_cpu ? null,
rocksdb,
profile ? "release",
2026-04-03 10:56:45 -04:00
}:
let
# see https://crane.dev/API.html#cranelibfiltercargosources
# we need to keep the `web` directory which would be filtered out by the regular source filtering function
# https://crane.dev/API.html#cranelibcleancargosource
isWebTemplate = path: _type: builtins.match ".*(src/(web|service)|docs).*" path != null;
isRust = craneLib.filterCargoSources;
isNix = path: _type: builtins.match ".+/nix.*" path != null;
webOrRustNotNix = p: t: !(isNix p t) && (isWebTemplate p t || isRust p t);
src = lib.cleanSourceWith {
src = self;
filter = webOrRustNotNix;
name = "source";
};
attrs = {
inherit src;
nativeBuildInputs = [
pkg-config
rustPlatform.bindgenHook
];
2026-04-03 11:02:45 -04:00
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ liburing ];
2026-04-03 10:56:45 -04:00
env = {
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
CARGO_PROFILE = profile;
RUSTFLAGS = rustflags;
2026-05-11 15:05:57 +02:00
}
// (lib.optionalAttrs (target_cpu != null) {
TARGET_CPU = target_cpu;
});
2026-04-03 10:56:45 -04:00
};
in
craneLib.buildPackage (
lib.recursiveUpdate attrs {
2026-04-03 11:12:49 -04:00
inherit cargoExtraArgs;
cargoArtifacts = craneLib.buildDepsOnly attrs;
2026-04-03 10:56:45 -04:00
# Needed to make continuwuity link to rocksdb
2026-04-08 12:16:30 -04:00
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
2026-04-03 10:56:45 -04:00
old_rpath="$(patchelf --print-rpath $out/bin/conduwuit)"
extra_rpath="${
lib.makeLibraryPath [
rocksdb
]
}"
2026-05-23 13:59:24 -04:00
patchelf --set-rpath "$old_rpath:$extra_rpath" $out/bin/conduwuit
2026-04-03 10:56:45 -04:00
'';
meta = {
description = "A community-driven Matrix homeserver in Rust";
mainProgram = "conduwuit";
2026-04-08 11:31:22 -04:00
platforms = lib.platforms.all;
2026-04-03 10:56:45 -04:00
maintainers = with lib.maintainers; [ quadradical ];
};
}
)