1{ lib, rustPlatform, fetchFromGitLab, pkg-config, sqlite, stdenv, darwin, nixosTests, rocksdb_6_23 }:
2
3rustPlatform.buildRustPackage rec {
4 pname = "matrix-conduit";
5 version = "0.5.0";
6
7 src = fetchFromGitLab {
8 owner = "famedly";
9 repo = "conduit";
10 rev = "v${version}";
11 sha256 = "sha256-GSCpmn6XRbmnfH31R9c6QW3/pez9KHPjI99dR+ln0P4=";
12 };
13
14 # We have to use importCargoLock here because `cargo vendor` currently doesn't support workspace
15 # inheritance within Git dependencies, but importCargoLock does.
16 cargoLock = {
17 lockFile = ./Cargo.lock;
18 outputHashes = {
19 "heed-0.10.6" = "sha256-rm02pJ6wGYN4SsAbp85jBVHDQ5ITjZZd+79EC2ubRsY=";
20 "reqwest-0.11.9" = "sha256-wH/q7REnkz30ENBIK5Rlxnc1F6vOyuEANMHFmiVPaGw=";
21 "ruma-0.7.4" = "sha256-ztobLdOXSGyK1YcPMMIycO3ZmnjxG5mLkHltf0Fbs8s=";
22 };
23 };
24
25 # Conduit enables rusqlite's bundled feature by default, but we'd rather use our copy of SQLite.
26 preBuild = ''
27 substituteInPlace Cargo.toml --replace "features = [\"bundled\"]" "features = []"
28 cargo update --offline -p rusqlite
29 '';
30
31 nativeBuildInputs = [
32 rustPlatform.bindgenHook
33 pkg-config
34 ];
35
36 buildInputs = [ sqlite ] ++ lib.optionals stdenv.isDarwin [
37 darwin.apple_sdk.frameworks.Security
38 ];
39
40 ROCKSDB_INCLUDE_DIR = "${rocksdb_6_23}/include";
41 ROCKSDB_LIB_DIR = "${rocksdb_6_23}/lib";
42
43 # tests failed on x86_64-darwin with SIGILL: illegal instruction
44 doCheck = !(stdenv.isx86_64 && stdenv.isDarwin);
45
46 passthru.tests = {
47 inherit (nixosTests) matrix-conduit;
48 };
49
50 meta = with lib; {
51 description = "A Matrix homeserver written in Rust";
52 homepage = "https://conduit.rs/";
53 license = licenses.asl20;
54 maintainers = with maintainers; [ pstn piegames pimeys ];
55 mainProgram = "conduit";
56 };
57}