summary refs log tree commit diff
path: root/pkgs/data/fonts/joypixels/default.nix
blob: 146b832af9c745141a5e8a888b5d51af1a4725c1 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{ lib, stdenv
, fetchurl
, config
, acceptLicense ? config.joypixels.acceptLicense or false
}:

let
  inherit (stdenv.hostPlatform.parsed) kernel;

  systemSpecific = {
    darwin = rec {
      systemTag =  "nix-darwin";
      capitalized = systemTag;
      fontFile = "JoyPixels-SBIX.ttf";
    };
  }.${kernel.name} or rec {
    systemTag = "nixos";
    capitalized = "NixOS";
    fontFile = "joypixels-android.ttf";
  };

  joypixels-free-license = with systemSpecific; {
    spdxId = "LicenseRef-JoyPixels-Free-6.0";
    fullName = "JoyPixels Free License Agreement 6.0";
    url = "https://cdn.joypixels.com/distributions/${systemTag}/license/free-license.pdf";
    free = false;
  };

  joypixels-license-appendix = with systemSpecific; {
    spdxId = "LicenseRef-JoyPixels-NixOS-Appendix";
    fullName = "JoyPixels ${capitalized} License Appendix";
    url = "https://cdn.joypixels.com/distributions/${systemTag}/appendix/joypixels-license-appendix.pdf";
    free = false;
  };

  throwLicense = throw ''
    Use of the JoyPixels font requires acceptance of the license.
      - ${joypixels-free-license.fullName} [1]
      - ${joypixels-license-appendix.fullName} [2]

    You can express acceptance by setting acceptLicense to true in your
    configuration. Note that this is not a free license so it requires allowing
    unfree licenses.

    configuration.nix:
      nixpkgs.config.allowUnfree = true;
      nixpkgs.config.joypixels.acceptLicense = true;

    config.nix:
      allowUnfree = true;
      joypixels.acceptLicense = true;

    [1]: ${joypixels-free-license.url}
    [2]: ${joypixels-license-appendix.url}
  '';

in

stdenv.mkDerivation rec {
  pname = "joypixels";
  version = "6.5.0";

  src = assert !acceptLicense -> throwLicense;
    with systemSpecific; fetchurl {
      name = fontFile;
      url = "https://cdn.joypixels.com/distributions/${systemTag}/font/${version}/${fontFile}";
      sha256 = {
        darwin = "034bwxy6ljvhx9zlm6jkb8vw222sg79sjwlcjfql51rk6zkmv4wx";
      }.${kernel.name} or "1v6hz0qhbnzayxhs5j9qfa2ggn7nak53ij7kr06m93wcmlnnln86";
    };

  dontUnpack = true;

  installPhase = with systemSpecific; ''
    runHook preInstall

    install -Dm644 $src $out/share/fonts/truetype/${fontFile}

    runHook postInstall
  '';

  meta = with lib; {
    description = "The finest emoji you can use legally (formerly EmojiOne)";
    longDescription = ''
      Updated for 2021! JoyPixels 6.5 includes 3,559 originally crafted icon
      designs and is 100% Unicode 13.1 compatible. We offer the largest
      selection of files ranging from png, svg, iconjar, sprites, and fonts.
    '';
    homepage = "https://www.joypixels.com/fonts";
    license =
      let
        free-license = joypixels-free-license;
        appendix = joypixels-license-appendix;
      in with systemSpecific; {
        spdxId = "LicenseRef-JoyPixels-Free-6.0-with-${capitalized}-Appendix";
        fullName = "${free-license.fullName} with ${appendix.fullName}";
        url = free-license.url;
        appendixUrl = appendix.url;
        free = false;
      };
    maintainers = with maintainers; [ toonn jtojnar ];
  };
}