Skip to content

fix wild cards and subcrates #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -403,32 +403,30 @@ rec {
else parsed.urlFragment;
};

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

getCrateNameFromPath = path:
let
cargoTomlCrate = builtins.fromTOML (builtins.readFile "${src}/${path}/Cargo.toml");
cargoTomlCrate = builtins.fromTOML (builtins.readFile path);
in
cargoTomlCrate.package.name;

pathToExtract =
if isWorkspace then
builtins.head
(builtins.filter
(to_filter:
(getCrateNameFromPath to_filter) == name
)
containedCrates)
else
".";
cargoTomlCrate.package.name or null;

packageCargoToml =
builtins.head
(builtins.filter
(to_filter:
(getCrateNameFromPath to_filter) == name
)
allCargoTomls);

pathToExtract = lib.removeSuffix "Cargo.toml" packageCargoToml;
in
pkgs.runCommand (lib.removeSuffix ".tar.gz" src.name) { }
''
mkdir -p $out
cp -apR ${src}/${pathToExtract}/* $out
cp -apR ${pathToExtract}/* $out
echo '{"package":null,"files":{}}' > $out/.cargo-checksum.json
'';

Expand Down