crane/lib/downloadCargoPackage.nix

24 lines
485 B
Nix
Raw Normal View History

2021-12-27 01:05:23 +03:00
{ fetchurl
, urlForCargoPackage
, runCommandLocal
2021-12-27 01:05:23 +03:00
}:
{ name
, version
, checksum
, ...
}@args:
2021-12-27 01:05:23 +03:00
let
pkgInfo = urlForCargoPackage args;
tarball = fetchurl (pkgInfo.fetchurlExtraArgs // {
inherit (pkgInfo) url;
2021-12-27 01:05:23 +03:00
name = "${name}-${version}";
sha256 = checksum;
});
2021-12-27 01:05:23 +03:00
in
runCommandLocal "cargo-package-${name}-${version}" { } ''
2021-12-27 01:05:23 +03:00
mkdir -p $out
tar -xzf ${tarball} -C $out --strip-components=1
echo '{"files":{}, "package":"${checksum}"}' > $out/.cargo-checksum.json
''