mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-26 09:08:57 +03:00
8b4f7a4dab
For example, commands which extract a tarball should be cached (i.e should use `runCommand` not `runCommandLocal`) because it allows builds to download the unpacked result instead of having to write both to the store
24 lines
475 B
Nix
24 lines
475 B
Nix
{ fetchurl
|
|
, urlForCargoPackage
|
|
, runCommand
|
|
}:
|
|
|
|
{ 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
|
|
''
|