mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: add customizable cargoExtraArgs
This commit is contained in:
@@ -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 ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -1,77 +1,19 @@
|
|||||||
{ inputs, ... }:
|
{
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
perSystem =
|
perSystem =
|
||||||
{
|
{
|
||||||
craneLib,
|
|
||||||
self',
|
|
||||||
pkgs,
|
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 { };
|
packages = {
|
||||||
|
rocksdb = pkgs.callPackage ./rocksdb.nix { };
|
||||||
attrs = {
|
default = pkgs.callPackage ./continuwuity.nix { inherit self craneLib; };
|
||||||
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;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user