crane/lib/cargoFmt.nix

25 lines
527 B
Nix
Raw Normal View History

2022-01-17 04:49:39 +03:00
{ cargoBuild
, rustfmt
}:
{ cargoExtraArgs ? ""
, rustFmtExtraArgs ? ""
, ...
}@origArgs:
let
args = builtins.removeAttrs origArgs [ "rustFmtExtraArgs" ];
in
cargoBuild (args // {
cargoArtifacts = null;
cargoVendorDir = null;
doCheck = false;
doInstallCargoArtifacts = false;
doRemapSourcePathPrefix = false;
pnameSuffix = "-fmt";
cargoBuildCommand = "cargo fmt";
cargoExtraArgs = "${cargoExtraArgs} -- --check ${rustFmtExtraArgs}";
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ rustfmt ];
})