yoke/nix/package.nix
2025-11-17 09:20:25 +11:00

49 lines
1.2 KiB
Nix

{
pkgs,
lib,
rustPlatform,
features ? [ ],
abi ? 6,
...
}:
let
details = (builtins.fromTOML (builtins.readFile ../Cargo.toml)).package;
in
rustPlatform.buildRustPackage (finalAttrs: {
pname = details.name;
inherit (details) version;
src = lib.cleanSourceWith {
src = lib.cleanSource ../.;
filter =
path_t: type:
let
path = toString path_t;
baseName = baseNameOf path;
parentDir = baseNameOf (dirOf path);
matchesSuffix = lib.any (suffix: lib.hasSuffix suffix baseName) [
".rs"
".toml"
];
isCargoFile = baseName == "Cargo.lock";
isCargoConf = parentDir == ".cargo" && baseName == "config";
in
type == "directory" || matchesSuffix || isCargoFile || isCargoConf;
};
cargoLock.lockFile = ../Cargo.lock;
buildNoDefaultFeatures = true;
buildFeatures = features ++ [
"nix"
"abi-${toString abi}"
];
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
C_INCLUDE_PATH = "${pkgs.linuxHeaders}/include";
meta = {
description = details.description;
homepage = details.repository;
license = lib.licenses.gpl3Plus;
maintainers = [ lib.maintainers.atagen ];
mainProgram = details.name;
};
})