2021-01-23 17:15:07 +00:00
|
|
|
{ lib, stdenv, fetchurl }:
|
2015-12-13 22:12:08 +00:00
|
|
|
|
2021-08-16 20:09:48 +00:00
|
|
|
{ pkg
|
|
|
|
, version
|
|
|
|
, sha256
|
|
|
|
, meta ? { }
|
2015-12-13 22:12:08 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation ({
|
2024-04-25 12:44:35 +00:00
|
|
|
pname = pkg;
|
2021-08-16 20:09:48 +00:00
|
|
|
inherit version;
|
2021-08-17 03:05:11 +00:00
|
|
|
dontBuild = true;
|
|
|
|
dontConfigure = true;
|
|
|
|
dontFixup = true;
|
2015-12-13 22:12:08 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2016-06-15 14:14:59 +00:00
|
|
|
url = "https://repo.hex.pm/tarballs/${pkg}-${version}.tar";
|
2015-12-13 22:12:08 +00:00
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
unpackCmd = ''
|
2023-01-30 10:35:12 +00:00
|
|
|
tar -xf $curSrc contents.tar.gz CHECKSUM metadata.config
|
2015-12-13 22:12:08 +00:00
|
|
|
mkdir contents
|
|
|
|
tar -C contents -xzf contents.tar.gz
|
2023-01-30 10:35:12 +00:00
|
|
|
mv metadata.config contents/hex_metadata.config
|
|
|
|
|
|
|
|
# To make the extracted hex tarballs appear legitimate to mix, we need to
|
|
|
|
# make sure they contain not just the contents of contents.tar.gz but also
|
|
|
|
# a .hex file with some lock metadata.
|
|
|
|
# We use an old version of .hex file per hex's mix_task_test.exs since it
|
|
|
|
# is just plain-text instead of an encoded format.
|
|
|
|
# See: https://github.com/hexpm/hex/blob/main/test/hex/mix_task_test.exs#L410
|
|
|
|
echo -n "${pkg},${version},$(cat CHECKSUM | tr '[:upper:]' '[:lower:]'),hexpm" > contents/.hex
|
2015-12-13 22:12:08 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir "$out"
|
|
|
|
cp -Hrt "$out" .
|
|
|
|
success=1
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
inherit meta;
|
|
|
|
})
|