Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion lib/vendorCargoDeps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ let
);

lock = args.cargoLockParsed or (builtins.fromTOML cargoLockContents);

toml = builtins.fromTOML (readFile (src + "/Cargo.toml"));

patch = lib.attrsets.foldlAttrs (acc: registry: value: acc // value) {} (toml.patch or {});
in
vendorMultipleCargoDeps (
{
inherit cargoConfigs;
inherit cargoConfigs patch src;
cargoLockParsedList = [ lock ];
outputHashes = args.outputHashes or { };
overrideVendorCargoPackage = args.overrideVendorCargoPackage or (_: drv: drv);
Expand Down
14 changes: 14 additions & 0 deletions lib/vendorMultipleCargoDeps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,24 @@ in
overrideVendorCargoPackage ? _: drv: drv,
overrideVendorGitCheckout ? _: drv: drv,
registries ? null,
patch ? { },
src,
}:
let
cargoLocksParsed =
(map fromTOML ((map readFile cargoLockList) ++ cargoLockContentsList)) ++ cargoLockParsedList;

linkedPatches =
lib.attrsets.foldlAttrs (acc: name: value: if value ? path then acc + ''
ln -s ${src}/${value.path} $out/${name}
'' else acc) "" patch;

linkedPatchesWarn =
if linkedPatches != "" then
builtins.warn "Using Crane together with [patch] may prevent the caching of build atrefacts" linkedPatches
else
"";

# Extract all packages from all Cargo.locks and trim any unused attributes from the parsed
# data so we do not get any faux duplicates
allowedAttrs = {
Expand Down Expand Up @@ -94,4 +107,5 @@ runCommandLocal "vendor-cargo-deps" { } ''

${linkSources vendoredRegistries.sources}
${linkSources vendoredGit.sources}
${linkedPatchesWarn}
''