rework features, add abi support, add fd args

This commit is contained in:
atagen 2025-11-06 17:06:03 +11:00
parent ab083b07e4
commit e2ad3c0b39
6 changed files with 174 additions and 61 deletions

45
nix/package.nix Normal file
View file

@ -0,0 +1,45 @@
{
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}"
];
meta = {
description = details.description;
homepage = details.repository;
license = lib.licenses.gpl3Plus;
maintainers = [ lib.maintainers.atagen ];
mainProgram = details.name;
};
})