crane/lib/taploFmt.nix
[eureka@nixos] 96fd12c710
Add taploFmt TOML format function to mkLib (#674)
---------

Co-authored-by: Ivan Petkov <ivanppetkov@gmail.com>
2024-08-31 17:27:30 +00:00

25 lines
537 B
Nix

{ taplo
, mkCargoDerivation
}:
{ taploExtraArgs ? ""
, ...
}@origArgs:
let
args = builtins.removeAttrs origArgs [ "taploExtraArgs" ];
in
mkCargoDerivation (args // {
cargoArtifacts = null;
cargoVendorDir = null;
pnameSuffix = "-tomlfmt";
buildPhaseCargoCommand = "taplo fmt --check ${taploExtraArgs}";
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ taplo ];
preInstallPhases = [ "ensureTargetDir" ] ++ (args.preInstallPhases or [ ]);
ensureTargetDir = ''
mkdir -p ''${CARGO_TARGET_DIR:-target}
'';
})