crane/lib/cargoFmt.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
613 B
Nix
Raw Normal View History

{ mkCargoDerivation
2022-01-17 04:49:39 +03:00
, rustfmt
}:
{ cargoExtraArgs ? ""
, rustFmtExtraArgs ? ""
, ...
}@origArgs:
let
args = builtins.removeAttrs origArgs [
"cargoExtraArgs"
"rustFmtExtraArgs"
];
2022-01-17 04:49:39 +03:00
in
mkCargoDerivation (args // {
2022-01-17 04:49:39 +03:00
cargoArtifacts = null;
cargoVendorDir = null;
pnameSuffix = "-fmt";
buildPhaseCargoCommand = "cargo fmt ${cargoExtraArgs} -- --check ${rustFmtExtraArgs}";
2022-01-17 04:49:39 +03:00
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ rustfmt ];
preInstallPhases = [ "ensureTargetDir" ] ++ (args.preInstallPhases or [ ]);
ensureTargetDir = ''
mkdir -p ''${CARGO_TARGET_DIR:-target}
'';
2022-01-17 04:49:39 +03:00
})