crane/lib/crateNameFromCargoToml.nix
adisbladis a1e56fba69 Stop passing around fromTOML
It's a builtin that we can just use directly.
2022-06-03 02:01:02 +08:00

19 lines
505 B
Nix

{}:
args:
let
src = args.src or (throw ''
unable to infer crate name and version. Please make sure the src directory
contains a valid Cargo.toml file, or consider setting a derivation name explicitly
'');
cargoToml = args.cargoToml or (args.src + "/Cargo.toml");
cargoTomlContents = args.cargoTomlContents or (builtins.readFile cargoToml);
toml = builtins.fromTOML cargoTomlContents;
in
{
pname = toml.package.name or "cargo-package";
version = toml.package.version or "0.0.1";
}