2024-05-03 20:29:10 +02:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
rustPlatform,
|
2024-09-30 16:14:02 +02:00
|
|
|
}:
|
|
|
|
let
|
2024-05-03 20:29:10 +02:00
|
|
|
readToml = path: builtins.fromTOML (builtins.readFile path);
|
|
|
|
cargoToml = readToml ./Cargo.toml;
|
|
|
|
pname = cargoToml.package.name;
|
|
|
|
inherit (cargoToml.package) version description;
|
2024-06-16 13:50:55 +02:00
|
|
|
src = lib.cleanSourceWith {
|
|
|
|
src = ./.;
|
|
|
|
name = "${pname}-source";
|
|
|
|
# Adapted from <https://github.com/ipetkov/crane/blob/master/lib/filterCargoSources.nix>
|
|
|
|
# no need to pull in crane for just this
|
2024-09-30 16:14:02 +02:00
|
|
|
filter =
|
|
|
|
orig_path: type:
|
|
|
|
let
|
|
|
|
path = toString orig_path;
|
|
|
|
base = baseNameOf path;
|
|
|
|
parentDir = baseNameOf (dirOf path);
|
|
|
|
matchesSuffix = lib.any (suffix: lib.hasSuffix suffix base) [
|
|
|
|
# Rust sources
|
|
|
|
".rs"
|
|
|
|
# TOML files are often used to configure cargo based tools (e.g. .cargo/config.toml)
|
|
|
|
".toml"
|
|
|
|
];
|
|
|
|
isCargoLock = base == "Cargo.lock";
|
|
|
|
# .cargo/config.toml is captured above
|
|
|
|
isOldStyleCargoConfig = parentDir == ".cargo" && base == "config";
|
|
|
|
in
|
2024-06-16 13:50:55 +02:00
|
|
|
type == "directory" || matchesSuffix || isCargoLock || isOldStyleCargoConfig;
|
|
|
|
};
|
2024-05-03 20:29:10 +02:00
|
|
|
in
|
2024-09-30 16:14:02 +02:00
|
|
|
rustPlatform.buildRustPackage {
|
|
|
|
inherit pname version src;
|
|
|
|
cargoLock.lockFile = ./Cargo.lock;
|
|
|
|
useNextest = true;
|
2024-05-03 20:29:10 +02:00
|
|
|
|
2024-09-30 16:14:02 +02:00
|
|
|
meta = {
|
|
|
|
inherit description;
|
|
|
|
license = lib.licenses.mit;
|
|
|
|
homepage = "https://github.com/jalil-salame/webnsupdate";
|
|
|
|
mainProgram = "webnsupdate";
|
|
|
|
};
|
|
|
|
}
|