crane/lib/downloadCargoPackage.nix
2022-10-23 23:20:22 +00:00

23 lines
425 B
Nix

{ fetchurl
, urlForCargoPackage
, runCommandLocal
}:
{ name
, version
, checksum
, ...
}@args:
let
tarball = fetchurl {
name = "${name}-${version}";
sha256 = checksum;
url = urlForCargoPackage args;
};
in
runCommandLocal "cargo-package-${name}-${version}" { } ''
mkdir -p $out
tar -xzf ${tarball} -C $out --strip-components=1
echo '{"files":{}, "package":"${checksum}"}' > $out/.cargo-checksum.json
''