Some checks failed
Documentation / Build and Deploy Documentation (push) Successful in 1m8s
Checks / Prek / Pre-commit & Formatting (push) Successful in 1m44s
Release Docker Image / Build linux-amd64 (release) (push) Successful in 5m49s
Release Docker Image / Build linux-arm64 (release) (push) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (push) Has been cancelled
Release Docker Image / Create Multi-arch Release Manifest (push) Has been cancelled
Release Docker Image / Build linux-amd64 (max-perf) (push) Has been cancelled
Release Docker Image / Build linux-arm64 (max-perf) (push) Has been cancelled
Release Docker Image / Create Max-Perf Manifest (push) Has been cancelled
Without this the rpath is empty and the binary won't be able to load the librocksdb.so.10 shared lib
111 lines
3.3 KiB
Nix
111 lines
3.3 KiB
Nix
args@{ pkgs, inputs, ... }:
|
|
let
|
|
inherit (pkgs) lib;
|
|
uwuenv = import ./environment.nix args;
|
|
selfpkgs = inputs.self.packages.${pkgs.stdenv.system};
|
|
in
|
|
rec {
|
|
# basic, very minimal instance of the crane library with a minimal rust toolchain
|
|
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (_: selfpkgs.build-toolchain);
|
|
# the checks require more rust toolchain components, hence we have this separate instance of the crane library
|
|
craneLibForChecks = (inputs.crane.mkLib pkgs).overrideToolchain (_: selfpkgs.dev-toolchain);
|
|
|
|
# meta information (name, version, etc) of the rust crate based on the Cargo.toml
|
|
crateInfo = craneLib.crateNameFromCargoToml { cargoToml = "${inputs.self}/Cargo.toml"; };
|
|
|
|
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.*" 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";
|
|
};
|
|
|
|
# common attrs that are shared between building continuwuity's deps and the package itself
|
|
commonAttrs =
|
|
{
|
|
profile ? "dev",
|
|
...
|
|
}:
|
|
{
|
|
inherit (crateInfo)
|
|
pname
|
|
version
|
|
;
|
|
inherit src;
|
|
|
|
# this prevents unnecessary rebuilds
|
|
strictDeps = true;
|
|
|
|
dontStrip = profile == "dev" || profile == "test";
|
|
dontPatchELF = profile == "dev" || profile == "test";
|
|
|
|
doCheck = true;
|
|
|
|
nativeBuildInputs = [
|
|
# bindgen needs the build platform's libclang. Apparently due to "splicing
|
|
# weirdness", pkgs.rustPlatform.bindgenHook on its own doesn't quite do the
|
|
# right thing here.
|
|
pkgs.rustPlatform.bindgenHook
|
|
];
|
|
};
|
|
|
|
makeRocksDBEnv =
|
|
{ rocksdb }:
|
|
{
|
|
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
|
|
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
|
|
};
|
|
|
|
# function that builds the continuwuity dependencies derivation
|
|
buildDeps =
|
|
{
|
|
rocksdb,
|
|
features,
|
|
commonAttrsArgs,
|
|
}:
|
|
craneLib.buildDepsOnly (
|
|
(commonAttrs commonAttrsArgs)
|
|
// {
|
|
env = uwuenv.buildDepsOnlyEnv // (makeRocksDBEnv { inherit rocksdb; });
|
|
inherit (features) cargoExtraArgs;
|
|
}
|
|
|
|
);
|
|
|
|
# function that builds the continuwuity package
|
|
buildPackage =
|
|
{
|
|
deps,
|
|
rocksdb,
|
|
features,
|
|
commonAttrsArgs,
|
|
}:
|
|
let
|
|
rocksdbEnv = makeRocksDBEnv { inherit rocksdb; };
|
|
in
|
|
craneLib.buildPackage (
|
|
(commonAttrs commonAttrsArgs)
|
|
// {
|
|
postFixup = ''
|
|
patchelf --set-rpath "$(${pkgs.patchelf}/bin/patchelf --print-rpath $out/bin/${crateInfo.pname}):${rocksdb}/lib" $out/bin/${crateInfo.pname}
|
|
'';
|
|
cargoArtifacts = deps;
|
|
doCheck = true;
|
|
env = uwuenv.buildPackageEnv // rocksdbEnv;
|
|
passthru.env = uwuenv.buildPackageEnv // rocksdbEnv;
|
|
meta.mainProgram = crateInfo.pname;
|
|
inherit (features) cargoExtraArgs;
|
|
}
|
|
);
|
|
}
|