nix-dylint/lib/cargo-dylint.nix
Marcel Müller 8bff2cf4cc Get a half working example working
Signed-off-by: Marcel Müller <neikos@neikos.email>
2025-03-03 15:30:17 +01:00

61 lines
1.1 KiB
Nix

{
pkgs,
craneLib,
pkg-config,
openssl,
cargo-dylint-driver,
}:
let
pname = "cargo-dylint";
version = "4.0.0";
src = pkgs.fetchFromGitHub {
owner = "trailofbits";
repo = "dylint";
tag = "v${version}";
sha256 = "sha256-Z8uuewp7Buoadayc0oTafmfvwNT36KukWKiHxL/mQfI=";
};
commonArgs = {
inherit pname version src;
buildInputs = [
openssl
];
nativeBuildInputs = [
pkg-config
];
RUSTUP_TOOLCHAIN = "nightly-nix";
doCheck = false;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in
craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
patches = [ ./cargo-dylint-patch-rustup.patch ];
postPatch = ''
substituteInPlace dylint/build.rs \
--replace-fail @DRIVER_DIR@ ${src}/driver
substituteInPlace internal/src/cargo.rs \
--replace-fail @STABLE_CARGO@ ${craneLib.cargo}/bin/cargo
substituteInPlace internal/src/rustup.rs \
--replace-fail @RUST_TOOLCHAIN@ "nightly-nix" \
--replace-fail @RUST_TOOLCHAIN_PATH@ ${craneLib.rustc}
'';
doNotRemoveReferencesToRustToolchain = true;
}
)