2024-01-28 22:08:44 +03:00
|
|
|
{ pkgsBuildBuild
|
2021-12-27 01:05:23 +03:00
|
|
|
, urlForCargoPackage
|
|
|
|
}:
|
|
|
|
|
2024-01-28 22:08:44 +03:00
|
|
|
let
|
|
|
|
inherit (pkgsBuildBuild)
|
|
|
|
fetchurl
|
2024-05-19 02:39:46 +03:00
|
|
|
stdenv;
|
2024-01-28 22:08:44 +03:00
|
|
|
in
|
2021-12-27 01:05:23 +03:00
|
|
|
{ name
|
|
|
|
, version
|
|
|
|
, checksum
|
|
|
|
, ...
|
2022-01-30 03:12:22 +03:00
|
|
|
}@args:
|
2021-12-27 01:05:23 +03:00
|
|
|
let
|
2022-11-21 03:22:13 +03:00
|
|
|
pkgInfo = urlForCargoPackage args;
|
|
|
|
tarball = fetchurl (pkgInfo.fetchurlExtraArgs // {
|
|
|
|
inherit (pkgInfo) url;
|
2021-12-27 01:05:23 +03:00
|
|
|
name = "${name}-${version}";
|
|
|
|
sha256 = checksum;
|
2022-11-21 03:22:13 +03:00
|
|
|
});
|
2021-12-27 01:05:23 +03:00
|
|
|
in
|
2024-05-19 02:39:46 +03:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit version;
|
|
|
|
pname = "cargo-package-${name}";
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
runHook preUnpack
|
|
|
|
mkdir -p crate
|
|
|
|
tar -xzf ${tarball} --strip-components=1
|
|
|
|
runHook postUnpack
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out
|
|
|
|
cp -r -t $out .
|
|
|
|
echo '{"files":{}, "package":"${checksum}"}' > $out/.cargo-checksum.json
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
}
|