ibm-plex: 6.4.0 -> 1.1.0

(cherry picked from commit 18ad5961d2)
This commit is contained in:
Ryan Cao 2024-11-13 19:57:52 +08:00 committed by github-actions[bot]
parent 8b31f63a2b
commit e6db7d6820
4 changed files with 88 additions and 10 deletions

View File

@ -0,0 +1,15 @@
{
"serif" = "sha256-8ygaAeMKygYS4GCub4YUQmkh87pYHfi3s0PQ6AbaeGw=";
"sans" = "sha256-mK+8GGl2ugF2+fS6yd3p5NWPHHcKEJWiShDS3lihOlI=";
"sans-condensed" = "sha256-/aJTXmrHuoPSrtCKNodBY7I0CriayNTx5LCXw+/MFvE=";
"sans-arabic" = "sha256-qi4k7kMLftIuq87idyxq46FOD6QYycdG6j3zJmu8mhI=";
"sans-devanagari" = "sha256-K57OVqcH5r9tZx8NFEoz1P3xpUooqpF7xxJzNmnObwE=";
"sans-thai" = "sha256-JZVbvZdj+IfBthiqivOXHrvAUe392M9ECGsiJkm0saE=";
"sans-thai-looped" = "sha256-cry/Ctwt1bsrdbvWkJIYWLjsvV6a1lLFsT85znqERnw=";
"sans-tc" = "sha256-kZvzSK6fEjfVMR4kxC4lxtD7GskqvJZx8BBJVT4T9MU=";
"sans-kr" = "sha256-FsHxMvLlI4yylgG96DOZIdW2DYpk7I+c5QgkVIkNZIE=";
"sans-jp" = "sha256-hUl/SSkN6q3pDTtrY2mJepw3ljhhLJskGbxfsTl9TuI=";
"sans-hebrew" = "sha256-rTuBQYLI+6gEFTumCdaWpeoLzRoyFSmqWbXziq+UG6I=";
"mono" = "sha256-OwUmrPfEehLDz0fl2ChYLK8FQM2p0G1+EMrGsYEq+6g=";
"math" = "sha256-dJA6uqxa/yb3eLY4l39NeP0yIl2NfrbaRpf6h0/F7Xc=";
}

View File

@ -1,22 +1,42 @@
{ lib, stdenvNoCC, fetchzip }: {
lib,
stdenvNoCC,
fetchzip,
families ? [ ],
}:
let
version = import ./version.nix;
availableFamilies = import ./hashes.nix;
stdenvNoCC.mkDerivation rec { availableFamilyNames = builtins.attrNames availableFamilies;
selectedFamilies = if (families == [ ]) then availableFamilyNames else families;
unknownFamilies = lib.subtractLists availableFamilyNames families;
in
assert lib.assertMsg (unknownFamilies == [ ]) "Unknown font(s): ${toString unknownFamilies}";
stdenvNoCC.mkDerivation {
pname = "ibm-plex"; pname = "ibm-plex";
version = "6.4.0"; inherit version;
src = fetchzip { srcs = builtins.map (
url = "https://github.com/IBM/plex/releases/download/v${version}/OpenType.zip"; family:
hash = "sha256-/aR3bu03VxenSPed6EqrGoPjWCcKT//MVtb9OC8tSRs="; fetchzip {
}; url = "https://github.com/IBM/plex/releases/download/%40ibm%2Fplex-${family}%40${version}/ibm-plex-${family}.zip";
hash = availableFamilies.${family};
}
) selectedFamilies;
dontUnpack = true;
sourceRoot = ".";
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
find $srcs -type f -name '*.otf' -exec install -Dm644 {} -t $out/share/fonts/opentype \;
install -Dm644 */*.otf IBM-Plex-Sans-JP/unhinted/* -t $out/share/fonts/opentype
runHook postInstall runHook postInstall
''; '';
passthru.updateScript = ./update.sh;
meta = with lib; { meta = with lib; {
description = "IBM Plex Typeface"; description = "IBM Plex Typeface";
homepage = "https://www.ibm.com/plex/"; homepage = "https://www.ibm.com/plex/";

View File

@ -0,0 +1,42 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nix nix-prefetch jq
# shellcheck shell=bash
set -eo pipefail
families=(
"serif"
"sans"
"sans-condensed"
"sans-arabic"
"sans-devanagari"
"sans-thai"
"sans-thai-looped"
"sans-tc"
"sans-kr"
"sans-jp"
"sans-hebrew"
"mono"
"math"
)
version=$(curl --silent 'https://api.github.com/repos/IBM/plex/releases/latest' | jq -r '.tag_name | sub("^@ibm/[\\w-]+@"; "")')
dirname="$(dirname "$0")"
echo \""${version}"\" >"$dirname/version-new.nix"
if diff -q "$dirname/version-new.nix" "$dirname/version.nix"; then
echo No new version available, current: "$version"
rm "$dirname/version-new.nix"
exit 0
else
echo Updated to version "$version"
mv "$dirname/version-new.nix" "$dirname/version.nix"
fi
printf '{\n' > "$dirname/hashes.nix"
for family in "${families[@]}"; do
url="https://github.com/IBM/plex/releases/download/%40ibm%2Fplex-${family}%40${version}/ibm-plex-${family}.zip"
printf ' "%s" = "%s";\n' "$family" "$(nix-prefetch-url --unpack "$url" | xargs nix hash convert --hash-algo sha256)" >>"$dirname/hashes.nix"
done
printf '}\n' >> "$dirname/hashes.nix"

View File

@ -0,0 +1 @@
"1.1.0"