This repository has been archived on 2024-10-13. You can view files and clone it, but cannot push or open issues or pull requests.
nix-packages/lib/mkPleromaEmoji.nix

50 lines
1.1 KiB
Nix
Raw Permalink Normal View History

2022-09-25 14:46:19 +00:00
{
stdenv,
fetchurl,
oxipng,
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 = [
oxipng
2022-11-21 10:01:19 +00:00
pngquant
2022-09-25 14:46:19 +00:00
libarchive
];
unpackPhase = ''
bsdtar -xf $src
'';
buildPhase = ''
find . -type f -name '*.png' -execdir ${./crushpng.sh} {} {}.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
'';
meta = with lib; {
inherit (manifestData) description homepage;
license = fixLicense manifestData.license;
};
}
// args)