Skip to content

Commit cb61181

Browse files
committed
fix wild cards and subcrates
1 parent be31fea commit cb61181

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

tools.nix

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -403,32 +403,30 @@ rec {
403403
else parsed.urlFragment;
404404
};
405405

406-
rootCargo = builtins.fromTOML (builtins.readFile "${src}/Cargo.toml");
407-
isWorkspace = rootCargo ? "workspace";
408-
isPackage = rootCargo ? "package";
409-
containedCrates = rootCargo.workspace.members ++ (if isPackage then [ "." ] else [ ]);
406+
allCargoTomls = lib.filter
407+
(lib.hasSuffix "Cargo.toml")
408+
(lib.filesystem.listFilesRecursive src);
410409

411410
getCrateNameFromPath = path:
412411
let
413-
cargoTomlCrate = builtins.fromTOML (builtins.readFile "${src}/${path}/Cargo.toml");
412+
cargoTomlCrate = builtins.fromTOML (builtins.readFile path);
414413
in
415-
cargoTomlCrate.package.name;
416-
417-
pathToExtract =
418-
if isWorkspace then
419-
builtins.head
420-
(builtins.filter
421-
(to_filter:
422-
(getCrateNameFromPath to_filter) == name
423-
)
424-
containedCrates)
425-
else
426-
".";
414+
cargoTomlCrate.package.name or null;
415+
416+
workspacePaths =
417+
builtins.head
418+
(builtins.filter
419+
(to_filter:
420+
(getCrateNameFromPath to_filter) == name
421+
)
422+
allCargoTomls);
423+
424+
pathToExtract = lib.removeSuffix "Cargo.toml" (builtins.head workspacePaths);
427425
in
428426
pkgs.runCommand (lib.removeSuffix ".tar.gz" src.name) { }
429427
''
430428
mkdir -p $out
431-
cp -apR ${src}/${pathToExtract}/* $out
429+
cp -apR ${pathToExtract}/* $out
432430
echo '{"package":null,"files":{}}' > $out/.cargo-checksum.json
433431
'';
434432

0 commit comments

Comments
 (0)