nix-packages/lib/mkPleromaEmoji.nix

48 lines
1.1 KiB
Nix
Raw Normal View History

2022-09-25 14:46:19 +00:00
{
stdenv,
fetchurl,
2022-11-21 10:01:19 +00:00
pngquant,
2022-09-25 14:46:19 +00:00
lib,
libarchive,
}: {
name,
manifest,
...
} @ args: let
manifestData = (builtins.fromJSON (builtins.readFile manifest)).${name};
src = fetchurl {
url = manifestData.src;
sha256 = manifestData.src_sha256;
};
brokenLicenses = {
"CC BY-NC-SA 4.0" = lib.licenses.cc-by-nc-sa-20;
"Apache 2.0" = lib.licenses.asl20;
2022-09-25 13:54:42 +00:00
};
2022-09-25 14:46:19 +00:00
fixLicense = license: brokenLicenses.${license} or license;
in
stdenv.mkDerivation ({
inherit name src;
nativeBuildInputs = [
2022-11-21 10:01:19 +00:00
pngquant
2022-09-25 14:46:19 +00:00
libarchive
];
unpackPhase = ''
bsdtar -xf $src
'';
buildPhase = ''
2023-08-12 11:07:49 +00:00
find . -type f -name '*.png' -print0 | xargs -0 -n 1 -P $NIX_BUILD_CORES sh -c '${./crushpng.sh} $0 $0.new 50000'
2022-11-21 10:01:19 +00:00
for f in $(find . -type f -name '*.new'); do
mv $f ${"$"}{f%.new}
done
2022-09-25 14:46:19 +00:00
'';
installPhase = ''
mkdir $out
2022-11-21 10:01:19 +00:00
cp -r *.png $out
2022-09-25 14:46:19 +00:00
'';
2023-09-09 10:23:47 +00:00
meta = {
2022-09-25 14:46:19 +00:00
inherit (manifestData) description homepage;
license = fixLicense manifestData.license;
};
}
// args)