nixpkgs/pkgs/servers/matrix-conduit/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

72 lines
1.7 KiB
Nix

{ lib
, rustPlatform
, fetchFromGitLab
, pkg-config
, sqlite
, stdenv
, darwin
, nixosTests
, rocksdb
, rust-jemalloc-sys
}:
rustPlatform.buildRustPackage rec {
pname = "matrix-conduit";
version = "0.8.0";
src = fetchFromGitLab {
owner = "famedly";
repo = "conduit";
rev = "v${version}";
hash = "sha256-/qKPeE2Ptweaf+rHOvdW0TUDLwN9D93MMgDoU4fTzEA=";
};
# We have to use importCargoLock here because `cargo vendor` currently doesn't support workspace
# inheritance within Git dependencies, but importCargoLock does.
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"ruma-0.10.1" = "sha256-I1mTeJLo+pgIqFkn1D2De/oACQPkUELjGdyGf3MVuLQ=";
};
};
# Conduit enables rusqlite's bundled feature by default, but we'd rather use our copy of SQLite.
preBuild = ''
substituteInPlace Cargo.toml --replace "features = [\"bundled\"]" "features = []"
cargo update --offline -p rusqlite
'';
nativeBuildInputs = [
rustPlatform.bindgenHook
pkg-config
];
buildInputs = [
sqlite
rust-jemalloc-sys
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
env = {
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
};
# tests failed on x86_64-darwin with SIGILL: illegal instruction
doCheck = !(stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform.isDarwin);
passthru.tests = {
inherit (nixosTests) matrix-conduit;
};
meta = with lib; {
description = "Matrix homeserver written in Rust";
homepage = "https://conduit.rs/";
license = licenses.asl20;
maintainers = with maintainers; [ pstn pimeys ];
mainProgram = "conduit";
};
}