From c55678b27e2200345fbff38692bed77055bba6ed Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Sat, 6 Jan 2024 20:18:13 +0000 Subject: [PATCH] nix: Skip clippy for layers with no local crates Signed-off-by: Nick Spinale --- hacking/nix/rust-utils/build-crate-in-layers.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hacking/nix/rust-utils/build-crate-in-layers.nix b/hacking/nix/rust-utils/build-crate-in-layers.nix index 0f761d429..d8bfc7cdb 100644 --- a/hacking/nix/rust-utils/build-crate-in-layers.nix +++ b/hacking/nix/rust-utils/build-crate-in-layers.nix @@ -133,7 +133,7 @@ let cargoSubcommand = if test then "test" else "build"; - mkCargoInvocation = commonArgs: subcommandArgs: + mkCargoInvocation = runClippy: commonArgs: subcommandArgs: let joinedCommonArgs = lib.concatStringsSep " " commonArgs; joinedSubcommandArgs = lib.concatStringsSep " " @@ -177,6 +177,9 @@ let { name = "Cargo.lock"; path = lockfile; } { name = "src"; path = src; } ]; + + # HACK don't run clippy if this layer has no local crates + runClippyThisLayer = runClippy && layer.reals != {}; in modifications.modifyDerivation (stdenv.mkDerivation (baseArgs // { name = "${rootCrate.name}-intermediate"; @@ -189,7 +192,7 @@ let cp -r --preserve=timestamps ${prev} $out chmod -R +w $out - ${mkCargoInvocation (flags ++ [ + ${mkCargoInvocation runClippyThisLayer (flags ++ [ "--config" "${config}" "--manifest-path" "${workspace}/Cargo.toml" "--target-dir" "$out" @@ -235,7 +238,7 @@ in let cp -r --preserve=timestamps ${lastIntermediateLayer} $target_dir chmod -R +w $target_dir - ${mkCargoInvocation (flags ++ [ + ${mkCargoInvocation runClippy (flags ++ [ "--config" "${config}" "--manifest-path" "${workspace}/Cargo.toml" "--target-dir" "$target_dir"