Skip to content

Commit

Permalink
nix: Skip clippy for layers with no local crates
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Jan 7, 2024
1 parent 93f3eb0 commit c55678b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hacking/nix/rust-utils/build-crate-in-layers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 " "
Expand Down Expand Up @@ -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";
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit c55678b

Please sign in to comment.