crane/lib/downloadCargoPackage.nix
Ivan Petkov e80de1e74a
Allow passing arbitrary fetchurl args per registry (#168)
Co-authored-by: Amos Wenger <amoswenger@gmail.com>
2022-11-20 16:22:13 -08:00

24 lines
485 B
Nix

{ fetchurl
, urlForCargoPackage
, runCommandLocal
}:
{ name
, version
, checksum
, ...
}@args:
let
pkgInfo = urlForCargoPackage args;
tarball = fetchurl (pkgInfo.fetchurlExtraArgs // {
inherit (pkgInfo) url;
name = "${name}-${version}";
sha256 = checksum;
});
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
''