crane/lib/downloadCargoPackage.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
475 B
Nix
Raw Normal View History

2021-12-27 01:05:23 +03:00
{ fetchurl
, urlForCargoPackage
, runCommand
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
runCommand "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
''