mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-27 02:52:02 +03:00
960d350770
* Source vendoring is passed as a standalone attribute to `mkCargoDerivation`, meaning it does not automagically get spliced with the correct local/cross system inputs (i.e. what would happen if it was a `depsBuildBuild` entry) * To fix this we need to make sure that `vendorCargoDeps` and all of its transitive dependencies always use `runCommand` (and friends) from their `pkgsBuildBuild` equivalent. This should always be safe to do (even for cross-builds) since this amounts to building up a bunch of sources which will be read by the build system * Unfortunately I had to manually specify `pkgsBuildBuild.whatever` in multiple places as I could not get things to work by messing with the `callPackage` definition. Perhaps we should be using `makeScopeWithSplicing'` instead of `makeScope` when constructing the library, but I couldn't get it working (and I couldn't find any decent docs on how to use it online) so this will make do for the time being.
28 lines
531 B
Nix
28 lines
531 B
Nix
{ pkgsBuildBuild
|
|
, urlForCargoPackage
|
|
}:
|
|
|
|
let
|
|
inherit (pkgsBuildBuild)
|
|
fetchurl
|
|
runCommand;
|
|
in
|
|
{ name
|
|
, version
|
|
, checksum
|
|
, ...
|
|
}@args:
|
|
let
|
|
pkgInfo = urlForCargoPackage args;
|
|
tarball = fetchurl (pkgInfo.fetchurlExtraArgs // {
|
|
inherit (pkgInfo) url;
|
|
name = "${name}-${version}";
|
|
sha256 = checksum;
|
|
});
|
|
in
|
|
runCommand "cargo-package-${name}-${version}" { } ''
|
|
mkdir -p $out
|
|
tar -xzf ${tarball} -C $out --strip-components=1
|
|
echo '{"files":{}, "package":"${checksum}"}' > $out/.cargo-checksum.json
|
|
''
|