summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ip/ipamjfont/package.nix
blob: ac74a663fef338349d4b53abdce4564026caab97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{
  lib,
  stdenvNoCC,
  fetchzip,
  installFonts,
  writeShellApplication,
  curl,
  gnugrep,
  common-updater-scripts,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "ipamjfont";
  version = "006.01";

  src =
    let
      suffix = lib.strings.replaceString "." "" finalAttrs.version;
    in
    fetchzip {
      url = "https://dforest.watch.impress.co.jp/library/i/ipamjfont/10750/ipamjm${suffix}.zip";
      hash = "sha256-Rft8hmxm3D4hOaLaSYDfD14oarDIHUQkMZX+/ZDD4m0=";
      stripRoot = false;
    };

  nativeBuildInputs = [ installFonts ];

  passthru = {
    updateScript = lib.getExe (writeShellApplication {
      name = "${finalAttrs.pname}-updater";

      runtimeInputs = [
        curl
        gnugrep
        common-updater-scripts
      ];

      text = ''
        suffix="$(
          curl --fail --silent 'https://forest.watch.impress.co.jp/library/software/ipamjfont/download_10750.html' | \
            grep --perl-regexp --only-matching 'meta.+?ipamjm\K[0-9]+'
        )"
        version="''${suffix:0:3}.''${suffix:3:2}"
        update-source-version '${finalAttrs.pname}' "$version" --ignore-same-version --print-changes
      '';
    });
  };

  meta = {
    description = "Japanese Mincho font implementing IVS compliant with Hanyo-Denshi collection";
    downloadPage = "https://forest.watch.impress.co.jp/library/software/ipamjfont/";
    homepage = "https://moji.or.jp/mojikiban/font/";
    license = lib.licenses.ipa;
    maintainers = with lib.maintainers; [
      kachick
    ];
  };
})