summary refs log tree commit diff
path: root/pkgs/data/fonts/gohufont/default.nix
blob: 29b4241be92c51c1c7cb322cb3ba65e7537ef3d9 (plain) (blame)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
{ stdenv, fetchurl, fetchFromGitHub
, mkfontdir, mkfontscale, bdf2psf, bdftopcf
}:

stdenv.mkDerivation rec {
  pname = "gohufont";
  version = "2.1";

  src = fetchurl {
    url = "http://font.gohu.org/${pname}-${version}.tar.gz";
    sha256 = "10dsl7insnw95hinkcgmp9rx39lyzb7bpx5g70vswl8d6p4n53bm";
  };

  bdf = fetchFromGitHub {
    owner  = "hchargois";
    repo   = "gohufont";
    rev    = "cc36b8c9fed7141763e55dcee0a97abffcf08224";
    sha256 = "1hmp11mrr01b29phw0xyj4h9b92qz19cf56ssf6c47c5j2c4xmbv";
  };

  nativeBuildInputs = [ mkfontdir mkfontscale bdf2psf bdftopcf ];

  buildPhase = ''
    # convert bdf to psf fonts
    build=$(pwd)
    mkdir psf
    cd ${bdf2psf}/share/bdf2psf
    for i in $bdf/*.bdf; do
      bdf2psf \
        --fb "$i" standard.equivalents \
        ascii.set+useful.set+linux.set 512 \
        "$build/psf/$(basename $i .bdf).psf"
    done
    cd $build

    # convert hidpi variant to pcf
    for i in $bdf/hidpi/*.bdf; do
        name=$(basename $i .bdf).pcf
        bdftopcf -o "$name" "$i"
    done
  '';

  installPhase = ''
    # install the psf fonts (for the virtual console)
    fontDir="$out/share/consolefonts"
    mkdir -p "$fontDir"
    mv -t "$fontDir" psf/*.psf

    # install the pcf fonts (for xorg applications)
    fontDir="$out/share/fonts/misc"
    mkdir -p "$fontDir"
    mv -t "$fontDir" *.pcf.gz *.pcf

    cd "$fontDir"
    mkfontdir
    mkfontscale
  '';

  outputHashAlgo = "sha256";
  outputHashMode = "recursive";
  outputHash     = "0kl7k8idl0fnsap2c4j02i33z017p2s4gi2cgspy6ica46fczcc1";

  meta = with stdenv.lib; {
    description = ''
      A monospace bitmap font well suited for programming and terminal use
    '';
    homepage    = http://font.gohu.org/;
    license     = licenses.wtfpl;
    maintainers = with maintainers; [ epitrochoid rnhmjoj ];
  };
}