crane/lib/path.nix
Ivan Petkov a3f0c63eed
Try to avoid IFD in vendorCargoDeps and crateNameFromCargoToml; also avoid recommending nesting cleanCargoSource and path (#641)
We don't need to nest `cleanCargoSource` and `path` just to populate a
default value for `name`. As they both ultimately delegate to
`builtins.path`, the nesting can lead to IFD in situations which are
otherwise avoidable
2024-06-10 20:53:46 -07:00

15 lines
316 B
Nix

{ internalCrateNameForCleanSource
, lib
}:
input:
let
inputIsAttrs = lib.isAttrs input;
name = input.name or (internalCrateNameForCleanSource (
if inputIsAttrs then input.path else input
));
pathArgs = if inputIsAttrs then input else { path = input; };
in
builtins.path ({ inherit name; } // pathArgs)