mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-30 05:57:28 +03:00
2a14c2d53b
* If a derivation is created without a name *and* we cannot infer a name from a Cargo.toml file, we'll throw a descriptive error message which hints towards the remediation * Otherwise nix can throw a pretty obtuse "derivation has no name" error with no error trace
29 lines
631 B
Nix
29 lines
631 B
Nix
{ fromTOML }:
|
|
|
|
{ src ? null
|
|
, cargoToml ? src + /Cargo.toml
|
|
, cargoTomlContents ? null
|
|
, ...
|
|
}:
|
|
|
|
if cargoTomlContents == null && (src == null || !builtins.pathExists cargoToml)
|
|
then
|
|
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
|
|
''
|
|
else
|
|
let
|
|
cargoTomlRealContents =
|
|
if cargoTomlContents != null
|
|
then cargoTomlContents
|
|
else builtins.readFile cargoToml;
|
|
|
|
toml = fromTOML cargoTomlRealContents;
|
|
p = toml.package;
|
|
in
|
|
{
|
|
inherit (p) version;
|
|
pname = p.name;
|
|
}
|