forked from ipetkov/crane
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support the MacOS sandbox for larger projects
Fixes ipetkov#482. MacOS has trouble with derivations which (directly or transitively) have many buildInputs. Crane at present creates a build structure in which a given cargo command will transitively depend on numCrates nix store paths. This means that Crane fails to build projects with over about 600 crate dependencies on MacOS if the sandbox is enabled. This MR utilises a tiering approach to improve this. Each registry is assigned to a shard based on the hash of the crate name. If there are <32 crates in a registry there is one shard, if <2048 there are 16 shards, otherwise 256. Crates are directly extracted into these shard derivations rather than symlinking. What this means is: 1. Crane will not create a vendoring derivation with many inputs unless a project has a truly crazy number of dependencies. 1. No downstream cargo derivation will have many inputs either.
- Loading branch information
Showing
5 changed files
with
61 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ fetchurl | ||
, urlForCargoPackage | ||
, runCommand | ||
, lib | ||
}: | ||
|
||
{shardName, packages}: | ||
let | ||
getTarball = ({ name, version, checksum, ...}@args: let | ||
pkgInfo = urlForCargoPackage args; | ||
in | ||
{ | ||
inherit name version checksum; | ||
tarball = fetchurl (pkgInfo.fetchurlExtraArgs // { | ||
inherit (pkgInfo) url; | ||
name = "${name}-${version}"; | ||
sha256 = checksum; | ||
}); | ||
}); | ||
|
||
tarballs = map getTarball packages; | ||
|
||
extract = (tarball: let outPath = "$out/${lib.escapeShellArg "${tarball.name}-${tarball.version}"}"; | ||
in '' | ||
mkdir -p ${outPath} | ||
tar -xf ${tarball.tarball} -C ${outPath} --strip-components=1 | ||
echo '{"files":{}, "package":"${tarball.checksum}"}' > ${outPath}/.cargo-checksum.json | ||
''); | ||
|
||
name = if builtins.stringLength shardName == 0 then "extract-cargo-packages" else "extract-cargo-packages-${shardName}"; | ||
in | ||
runCommand name { } '' | ||
mkdir -p $out | ||
${lib.strings.concatMapStrings extract tarballs} | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters