i-dot-ming: fetch all fonts, fix update script, use installFonts (#532775)

This commit is contained in:
Yohann Boniface
2026-06-23 21:46:53 +00:00
committed by GitHub
+13 -33
View File
@@ -1,47 +1,27 @@
{
lib,
stdenvNoCC,
fetchurl,
writeScript,
fetchFromGitHub,
installFonts,
nix-update-script,
}:
stdenvNoCC.mkDerivation rec {
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "i.ming";
version = "8.10";
src = fetchurl {
url = "https://raw.githubusercontent.com/ichitenfont/I.Ming/${version}/${version}/I.Ming-${version}.ttf";
hash = "sha256-y6E7dbBQ1nG2EdAGMUcmLkIeFDWa1FMJSLBw9WER8PM=";
src = fetchFromGitHub {
owner = "ichitenfont";
repo = "I.Ming";
tag = finalAttrs.version;
hash = "sha256-TutIcX/DoeO5cwjD0o1IaXErStY73Cqk00NDKbXw39I=";
rootDir = finalAttrs.version;
};
dontUnpack = true;
installPhase = ''
runHook preInstall
install -DT -m444 $src $out/share/fonts/truetype/I.Ming/I.Ming.ttf
runHook postInstall
'';
nativeBuildInputs = [ installFonts ];
passthru = {
updateScript = writeScript "updater" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused
set -e
version=$(curl -i -s https://github.com/ichitenfont/I.Ming/releases/latest | sed -n -E 's|^location.*releases/tag/([0-9.]+).*$|\1|p')
if [[ $version != ${version} ]]; then
tmp=$(mktemp -d)
curl -Lo $tmp/I.Ming.ttf https://raw.githubusercontent.com/ichitenfont/I.Ming/$version/$version/I.Ming-$version.ttf
install -DT -m444 $tmp/I.Ming.ttf $tmp/share/fonts/truetype/I.Ming/I.Ming.ttf
rm $tmp/I.Ming.ttf
hash=$(nix --extra-experimental-features nix-command hash path --type sha256 --base32 --sri $tmp)
sed -i -E \
-e "s/version = \"[0-9.]+\"/version = \"$version\"/" \
-e "s|hash = \".*\"|hash = \"$hash\"|" \
pkgs/data/fonts/i-dot-ming/default.nix
fi
'';
updateScript = nix-update-script { };
};
meta = {
@@ -51,4 +31,4 @@ stdenvNoCC.mkDerivation rec {
platforms = lib.platforms.all;
maintainers = [ lib.maintainers.linsui ];
};
}
})