feat: add customizable cargoExtraArgs

This commit is contained in:
Henry-Hiles
2026-04-03 10:56:45 -04:00
committed by Henry Hiles
parent 867a3ac376
commit 0fdb1be938
2 changed files with 77 additions and 67 deletions
+68
View File
@@ -0,0 +1,68 @@
{
lib,
self,
craneLib,
callPackage,
pkg-config,
rustPlatform,
liburing,
stdenv,
cargoExtraArgs ? [ ],
}:
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";
};
rocksdb = callPackage ./rocksdb.nix { };
attrs = {
inherit src;
nativeBuildInputs = [
pkg-config
rustPlatform.bindgenHook
];
buildInputs = lib.optional stdenv.hostPlatform.isLinux liburing;
env = {
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
};
};
cargoArtifacts = craneLib.buildDepsOnly attrs;
in
craneLib.buildPackage (
lib.recursiveUpdate attrs {
inherit cargoArtifacts cargoExtraArgs;
# Needed to make continuwuity link to rocksdb
postFixup = ''
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";
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ quadradical ];
};
}
)
+9 -67
View File
@@ -1,77 +1,19 @@
{ inputs, ... }:
{
self,
...
}:
{
perSystem =
{
craneLib,
self',
pkgs,
lib,
craneLib,
...
}:
{
packages =
let
src =
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);
in
lib.cleanSourceWith {
src = inputs.self;
filter = webOrRustNotNix;
name = "source";
};
rocksdb = pkgs.callPackage ./rocksdb.nix { };
attrs = {
inherit src;
nativeBuildInputs = with pkgs; [
pkg-config
rustPlatform.bindgenHook
];
buildInputs = [
pkgs.liburing
];
env = {
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
};
};
cargoArtifacts = craneLib.buildDepsOnly attrs;
in
{
default = craneLib.buildPackage (
lib.recursiveUpdate attrs {
inherit cargoArtifacts;
# Needed to make continuwuity link to rocksdb
postFixup = ''
old_rpath="$(patchelf --print-rpath $out/bin/conduwuit)"
extra_rpath="${
pkgs.lib.makeLibraryPath [
pkgs.rocksdb
]
}"
patchelf --set-rpath "$old_rpath:$extra_rpath" $out/bin/conduwuit
'';
meta = {
description = "A community-driven Matrix homeserver in Rust";
mainProgram = "conduwuit";
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ quadradical ];
};
}
);
inherit rocksdb;
};
packages = {
rocksdb = pkgs.callPackage ./rocksdb.nix { };
default = pkgs.callPackage ./continuwuity.nix { inherit self craneLib; };
};
};
}