From d8f6e7df57751b43798510143b9cdd01f018ffef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E9=9B=81=20Cryolitia?= Date: Thu, 11 Apr 2024 11:03:02 +0800 Subject: [PATCH] shanggu-fonts: init at 1.020 --- pkgs/by-name/sh/shanggu-fonts/package.nix | 70 +++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 pkgs/by-name/sh/shanggu-fonts/package.nix diff --git a/pkgs/by-name/sh/shanggu-fonts/package.nix b/pkgs/by-name/sh/shanggu-fonts/package.nix new file mode 100644 index 000000000000..f769087d4055 --- /dev/null +++ b/pkgs/by-name/sh/shanggu-fonts/package.nix @@ -0,0 +1,70 @@ +{ + lib, + stdenvNoCC, + fetchurl, + p7zip, +}: +let + version = "1.020"; + + source = + with lib.attrsets; + mapAttrs' + ( + name: hash: + nameValuePair (lib.strings.toLower name) (fetchurl { + url = "https://github.com/GuiWonder/Shanggu/releases/download/${version}/Shanggu${name}TTCs.7z"; + inherit hash; + }) + ) + { + Mono = "sha256-PcP4zJk8pptuX9tchr4qOorqAvj8YMRBcVrtCbp/1Zo="; + Round = "sha256-3wqMdnpdn4xpw7wO+QmIpl5/vZjQGgcfTMdtewK28B8="; + Sans = "sha256-isRqIVcH24knPqPI+a+9CpxEKd+PG642giUS9+VbC60="; + Serif = "sha256-k0I0NXStE1hcdOaOykuESy6sYqBHHaMaDxxr3tJUSYU="; + }; +in +stdenvNoCC.mkDerivation { + pname = "shanggu-fonts"; + inherit version; + + outputs = [ "out" ] ++ builtins.attrNames source; + + nativeBuildInputs = [ p7zip ]; + + unpackPhase = '' + runHook preUnpack + '' + lib.strings.concatLines ( + lib.attrsets.mapAttrsToList (name: value: '' + 7z x ${value} -o${name} + '') source + ) + '' + runHook postUnpack + ''; + + installPhase = + '' + runHook preInstall + + mkdir -p $out/share/fonts/truetype + '' + + lib.strings.concatLines ( + lib.lists.forEach (builtins.attrNames source) ( + name: ('' + install -Dm444 ${name}/*.ttc -t $'' + name + ''/share/fonts/truetype + ln -s $'' + name + ''/share/fonts/truetype/*.ttc $out/share/fonts/truetype + '' + ) + ) + ) + '' + runHook postInstall + ''; + + meta = with lib; { + homepage = "https://github.com/GuiWonder/Shanggu"; + description = "Heritage glyph (old glyph) font based on Siyuan"; + license = licenses.ofl; + platforms = platforms.all; + maintainers = with maintainers; [ Cryolitia ]; + }; +}