;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2019 Ludovic Courtès ;;; Copyright © 2014, 2017 Mark H Weaver ;;; Copyright © 2014 Joshua Grant ;;; Copyright © 2014 Alex Kost ;;; Copyright © 2015 Sou Bunnbu ;;; Copyright © 2015 Eric Dvorsak ;;; Copyright © 2015, 2017 Ricardo Wurmus ;;; Copyright © 2015, 2016 Leo Famulari ;;; Copyright © 2016, 2017, 2018 ng0 ;;; Copyright © 2016 Jookia <166291@gmail.com> ;;; Copyright © 2016 Eric Bavier ;;; Copyright © 2016 Dmitry Nikolaev ;;; Copyright © 2016, 2017, 2018, 2019 Efraim Flashner ;;; Copyright © 2016 Marius Bakke ;;; Copyright © 2016 Toni Reina ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2017 José Miguel Sánchez Ga
aboutsummaryrefslogtreecommitdiff
blob: a00785f699b23a6beefcaf45052cd251e78c983d (about) (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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:
;;;
;;; This module contains helpers used as part of the jami-service-type
;;; definition.
;;;
;;; Code:

(define-module (gnu build jami-service)
  #:use-module (gnu build dbus-service)
  #:use-module (ice-9 format)
  #:use-module (ice-9 match)
  #:use-module (ice-9 rdelim)
  #:use-module (ice-9 regex)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:export (jami-service-available?

            account-fingerprint?
            account-details->recutil
            get-accounts
            get-usernames
            set-account-details
            add-account
            account->username
            username->account
            username->contacts
            enable-account
            disable-account

            add-contact
            remove-contact

            set-all-moderators
            set-moderator
            username->all-moderators?
            username->moderators))

;;;
;;; Utilities.
;;;

(define (alist->list alist)
  "Flatten ALIST into a list."
  (append-map (match-lambda
                (() '())
                ((key . value)
                 (list key value)))
              alist))

(define account-fingerprint-rx (make-regexp "[0-9A-Fa-f]{40}"))

(define (account-fingerprint? val)
  "A Jami account fingerprint is 40 characters long and only contains
hexadecimal characters."
  (and (string? val)
       (regexp-exec account-fingerprint-rx val)))

(define (validate-fingerprint fingerprint)
  "Validate that fingerprint is 40 characters long."
  (unless (account-fingerprint? fingerprint)
    (error "Account fingerprint is not valid:" fingerprint)))

(define (jami-service-available?)
  "Whether the Jami D-Bus service was acquired by the D-Bus daemon."
  (unless (%current-dbus-connection)
    (initialize-dbus-connection!))
  (dbus-service-available? "cx.ring.Ring"))


;;;
;;; Bindings for the Jami D-Bus API.
;;;

(define* (call-configuration-manager-method method #:optional arguments
                                            #:key timeout)
  "Query the Jami D-Bus ConfigurationManager interface with METHOD applied to
ARGUMENTS.  TIMEOUT can optionally be provided as a value in seconds."
  (unless (%current-dbus-connection)
    (initialize-dbus-connection!))
  (call-dbus-method method
                    #:path "/cx/ring/Ring/ConfigurationManager"
                    #:destination "cx.ring.Ring"
                    #:interface "cx.ring.Ring.ConfigurationManager"
                    #:arguments arguments
                    #:timeout timeout))

;;; The following methods are for internal use; they make use of the account
;;; ID, an implementation detail of Jami the user should not need to be
;;; concerned with.
(define (get-account-ids)
  "Return the available Jami account identifiers (IDs).  Account IDs are an
implementation detail used to identify the accounts in Jami."
  (vector->list (call-configuration-manager-method "getAccountList")))

(define (id->account-details id)
  "Retrieve the account data associated with the given account ID."
  (vector->list (call-configuration-manager-method "getAccountDetails"
                                                   (list id))))

(define (id->volatile-account-details id)
  "Retrieve the account data associated with the given account ID."
  (vector->list (call-configuration-manager-method "getVolatileAccountDetails"
                                                   (list id))))

(define (id->account id)
  "Retrieve the complete account data associated with the given account ID."
  (append (id->volatile-account-details id)
          (id->account-details id)))

(define %username-to-id-cache #f)

(define (invalidate-username-to-id-cache!)
  (set! %username-to-id-cache #f))

(define (username->id username)
  "Return the first account ID corresponding to USERNAME."
  (unless (assoc-ref %username-to-id-cache username)
    (set! %username-to-id-cache
          (append-map
           (lambda (id)
             (let* ((account (id->account id))
                    (username (assoc-ref account "Account.username"))
                    (registered-name (assoc-ref account
                                                "Account.registeredName")))
               `(,@(if username
                       (list (cons username id))
                       '())
                 ,@(if registered-name
                       (list (cons registered-name id))
                       '()))))
           (get-account-ids))))
  (or (assoc-ref %username-to-id-cache username)
      (let ((message (format #f "no account ID for ~:[username~;fingerprint~]"
                             (account-fingerprint? username))))
        (error message username))))

(define (account->username account)
  "Return the public key fingerprint of ACCOUNT."
  (assoc-ref account "Account.username"))

(define (id->username id)
  "Return the public key fingerprint corresponding to account with ID, else #f."
  (account->username (id->account id)))

(define (get-accounts)
  "Return the list of all accounts, as a list of alists."
  (map id->account (get-account-ids)))

(define (get-usernames)
  "Return the list of the usernames associated with the present accounts."
  (map account->username (get-accounts)))

(define (username->account username)
  "Return the first account associated with USERNAME, else #f.
USERNAME can be either the account 40 characters public key fingerprint or a
registered username."
  (find (lambda (account)
          (member username
                  (list (assoc-ref account "Account.username")
                        (assoc-ref account "Account.registeredName"))))
        (get-accounts)))

(define (add-account archive)
  "Import the Jami account ARCHIVE and return its account ID.  The archive
should *not* be encrypted with a password.  Return the username associated
with the account."
  (invalidate-username-to-id-cache!)
  (let ((id (call-configuration-manager-method
             "addAccount" (list `#(("Account.archivePath" . ,archive)
                                   ("Account.type" . "RING"))))))
    ;; The account information takes some time to be populated.
    (with-retries 20 1
      (let ((username (id->username id)))
        (if (and=> username (negate string-null?))
            username
            #f)))))

(define (remove-account username)
  "Delete the Jami account associated with USERNAME, the account 40 characters
fingerprint or a registered username."
  (let ((id (username->id username)))
    (call-configuration-manager-method "removeAccount" (list id)))
  (invalidate-username-to-id-cache!))

(define* (username->contacts username)
  "Return the contacts associated with the account of USERNAME as two values;
the first one being the regular contacts and the second one the banned
contacts.  USERNAME can be either the account 40 characters public key
fingerprint or a registered username.  The contacts returned are represented
using their 40 characters fingerprint."
  (let* ((id (username->id username))
         ;; The contacts are returned as "aa{ss}", that is, an array of arrays
         ;; containing (string . string) pairs.
         (contacts (map vector->list
                        (vector->list (call-configuration-manager-method
                                       "getContacts" (list id)))))
         (banned? (lambda (contact)
                    (and=> (assoc-ref contact "banned")
                           (cut string=? "true" <>))))
         (banned (filter banned? contacts))
         (not-banned (filter (negate banned?) contacts))
         (fingerprint (cut assoc-ref <> "id")))
    (values (map fingerprint not-banned)
            (map fingerprint banned))))

(define* (remove-contact contact username #:key ban?)
  "Remove CONTACT, the 40 characters public key fingerprint of a contact, from
the account associated with USERNAME (either a fingerprint or a registered
username).  When BAN? is true, also mark the contact as banned."
  (validate-fingerprint contact)
  (let ((id (username->id username)))
    (call-configuration-manager-method "removeContact" (list id contact ban?))))

(define (add-contact contact username)
  "Add CONTACT, the 40 characters public key fingerprint of a contact, to the
account of USERNAME (either a fingerprint or a registered username)."
  (validate-fingerprint contact)
  (let ((id (username->id username)))
    (call-configuration-manager-method "addContact" (list id contact))))

(define* (set-account-details details username #:key timeout)
  "Set DETAILS, an alist containing the key value pairs to set for the account
of USERNAME, a registered username or account fingerprint.  The value of the
parameters not provided are unchanged.  TIMEOUT is a value in milliseconds to
pass to the `call-configuration-manager-method' procedure."
  (let* ((id (username->id username))
         (current-details (id->account-details id))
         (updated-details (map (match-lambda
                                 ((key . value)
                                  (or (and=> (assoc-ref details key)
                                             (cut cons key <>))
                                      (cons key value))))
                               current-details)))
    (call-configuration-manager-method
     "setAccountDetails" (list id (list->vector updated-details))
     #:timeout timeout)))

(define (set-all-moderators enabled? username)
  "Set the 'AllModerators' property to enabled? for the account of USERNAME, a
registered username or account fingerprint."
  (let ((id (username->id username)))
    (call-configuration-manager-method "setAllModerators" (list id enabled?))))

(define (username->all-moderators? username)
  "Return the 'AllModerators' property for the account of USERNAME, a
registered username or account fingerprint."
  (let ((id (username->id username)))
    (call-configuration-manager-method "isAllModerators" (list id))))

(define (username->moderators username)
  "Return the moderators for the account of USERNAME, a registered username or
account fingerprint."
  (let* ((id (username->id username)))
    (vector->list (call-configuration-manager-method "getDefaultModerators"
                                                     (list id)))))

(define (set-moderator contact enabled? username)
  "Set the moderator flag to ENABLED? for CONTACT, the 40 characters public
key fingerprint of a contact for the account of USERNAME, a registered
username or account fingerprint."
  (validate-fingerprint contact)
  (let* ((id (username->id username)))
    (call-configuration-manager-method "setDefaultModerator"
                                       (list id contact enabled?))))

(define (disable-account username)
  "Disable the account known by USERNAME, a registered username or account
fingerprint."
  (set-account-details '(("Account.enable" . "false")) username
                       ;; Waiting for the reply on this command takes a very
                       ;; long time that trips the default D-Bus timeout value
                       ;; (25 s), for some reason.
                        #:timeout 60))

(define (enable-account username)
  "Enable the account known by USERNAME, a registered username or account
fingerprint."
  (set-account-details '(("Account.enable" . "true")) username))


;;;
;;; Presentation procedures.
;;;

(define (.->_ text)
  "Map each period character to underscore characters."
  (string-map (match-lambda
                (#\. #\_)
                (c c))
              text))

(define (account-details->recutil account-details)
  "Serialize the account-details alist into a recutil string.  Period
characters in the keys are normalized to underscore to meet Recutils' format
requirements."
  (define (pair->recutil-property pair)
    (match pair
      ((key . value)
       (string-append (.->_ key) ": " value))))

  (define sorted-account-details
    ;; Have the account username, display name and alias appear first, for
    ;; convenience.
    (let ((first-items '("Account.username"
                         "Account.displayName"
                         "Account.alias")))
      (append (map (cut assoc <> account-details) first-items)
              (fold alist-delete account-details first-items))))

  (string-join (map pair->recutil-property sorted-account-details) "\n"))
regular version above. (version "1.003") (source (origin (method url-fetch) (uri (string-append "https://www.marksimonson.com/assets/content/fonts/" "AnonymousProMinus-" version ".zip")) (sha256 (base32 "1p2n91jja37d2cshp5pjwld9lq0v7gnpk7ywwn2blq7k46q6vq38")))) (synopsis "Fixed-width fonts designed with coding in mind, without bitmaps") (description "Anonymous Pro is a family of four fixed-width fonts designed with coding in mind. Anonymous Pro features an international, Unicode-based character set, with support for most Western and Central European Latin-based languages, plus Greek and Cyrillic. Anonymous Pro Minus is identical to Anonymous Pro, minus its embedded bitmaps for use at smaller text sizes"))) (define-public font-gnu-unifont (package (name "font-gnu-unifont") (version "12.1.04") (source (origin (method url-fetch) (uri (list (string-append "http://unifoundry.com/pub/unifont/unifont-" version "/unifont-" version ".tar.gz") (string-append "mirror://gnu/unifont/unifont-" version "/unifont-" version ".tar.gz"))) (sha256 (base32 "1h5dyhg4j8sh4qpbwnsn34igb8mfapz5b3nf4k71hq1c5z3j0mcv")))) (build-system gnu-build-system) (outputs '("out" ; TrueType version "pcf" ; PCF (bitmap) version "psf" ; PSF (console) version "bin")) ; Utilities to manipulate '.hex' format (arguments '(#:tests? #f ; no check target #:phases (modify-phases %standard-phases (replace 'configure (lambda _ (setenv "CC" "gcc") #t)) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((ttf (string-append (assoc-ref outputs "out") "/share/fonts/truetype")) (pcf (string-append (assoc-ref outputs "pcf") "/share/fonts/misc")) (psf (string-append (assoc-ref outputs "psf") "/share/consolefonts")) (bin (assoc-ref outputs "bin"))) (invoke "make" (string-append "PREFIX=" bin) (string-append "TTFDEST=" ttf) (string-append "PCFDEST=" pcf) (string-append "CONSOLEDEST=" psf) "install") ;; Move Texinfo file to the right place. (mkdir (string-append bin "/share/info")) (invoke "gzip" "-9n" "doc/unifont.info") (install-file "doc/unifont.info.gz" (string-append bin "/share/info")) #t)))))) (inputs `(("perl" ,perl))) ; for utilities (synopsis "Large bitmap font covering Unicode's Basic Multilingual Plane") (description "GNU Unifont is a bitmap font covering essentially all of Unicode's Basic Multilingual Plane. The package also includes utilities to ease adding new glyphs to the font.") (home-page "http://unifoundry.com/unifont.html") (properties '((upstream-name . "unifont"))) (license license:gpl2+))) (define-public font-google-noto (package (name "font-google-noto") (version "20171025") (source (origin (method url-fetch/zipbomb) (uri (string-append "https://noto-website-2.storage.googleapis.com/" "pkgs/Noto-hinted.zip")) (file-name (string-append name "-" version ".zip")) (sha256 (base32 "1bp42whyin7xcgmrbnfvz3rvd98xmxaz3ywqybbjmqzwaa9llyw3")))) (build-system font-build-system) (home-page "https://www.google.com/get/noto/") (synopsis "Fonts to cover all languages") (description "Google Noto Fonts is a family of fonts designed to support all languages with a consistent look and aesthetic. Its goal is to properly display all Unicode symbols.") (license license:silofl1.1))) (define-public font-google-roboto (package (name "font-google-roboto") (version "2.136") (source (origin (method url-fetch) (uri (string-append "https://github.com/google/roboto/releases/download/" "v" version "/roboto-hinted.zip")) (file-name (string-append name "-" version ".zip")) (sha256 (base32 "0spscx08fad7i8qs7icns96iwcapniq8lwwqqvbf7bamvs8qfln4")))) (build-system font-build-system) (home-page "https://github.com/google/roboto") (synopsis "The Roboto family of fonts") (description "Roboto is Google’s signature family of fonts, the default font on Android and Chrome OS, and the recommended font for the visual language \"Material Design\".") (license license:asl2.0))) (define-public font-un (package (name "font-un") (version "1.0.2-080608") (source (origin (method url-fetch) (uri (string-append "https://kldp.net/unfonts/release/2607-" "un-fonts-core-" version ".tar.gz")) (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "13liaz2pmww3aqabm55la5npd08m1skh334ky7qfidxaz5s742iv")))) (build-system font-build-system) (home-page "https://kldp.net/projects/unfonts/") (synopsis "Collection of Korean fonts") (description "Un-fonts is a family of mainly Korean fonts. It contains the following fonts and styles: @enumerate @item UnBatang, UnBatangBold: serif; @item UnDotum, UnDotumBold: sans-serif; @item UnGraphic, UnGraphicBold: sans-serif style; @item UnDinaru, UnDinaruBold, UnDinaruLight; @item UnPilgi, UnPilgiBold: script; @item UnGungseo: cursive, brush-stroke. @end enumerate\n") (license license:gpl2+))) (define-public font-fantasque-sans (package (name "font-fantasque-sans") (version "1.7.2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/belluzj/fantasque-sans.git") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1gjranq7qf20rfxnpxsckv1hl35nzsal0rjs475nhfbpqy5wmly6")))) (build-system gnu-build-system) (native-inputs `(("ttfautohint" ,ttfautohint) ("woff-tools" ,woff-tools) ("fontforge" ,fontforge) ("woff2" ,woff2) ("ttf2eot" ,ttf2eot) ("zip" ,zip))) (arguments `(#:tests? #f ;test target intended for visual inspection #:phases (modify-phases %standard-phases (delete 'configure) ;no configuration (add-before 'build 'xrange->range ;; Rather than use a python2 fontforge, just replace the ;; offending function. (lambda _ (substitute* "Scripts/fontbuilder.py" (("xrange") "range")) #t)) (replace 'install ;; 'make install' wants to install to ~/.fonts, install to ;; output instead. Install only the "Normal" variant. (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (font-dir (string-append out "/share/fonts")) (truetype-dir (string-append font-dir "/truetype")) (opentype-dir (string-append font-dir "/opentype")) (webfonts-dir (string-append font-dir "/webfonts"))) (with-directory-excursion "Variants/Normal" (copy-recursively "OTF" opentype-dir) (for-each (lambda (f) (install-file f truetype-dir)) (find-files "." "\\.ttf$")) (copy-recursively "Webfonts" webfonts-dir) #t))))))) (synopsis "Font family with a monospaced variant for programmers") (description "Fantasque Sans Mono is a programming font designed with functionality in mind. The font includes a bold version and a good italic version with new glyph designs, not just an added slant.") (home-page "https://fontlibrary.org/en/font/fantasque-sans-mono") (license license:silofl1.1))) (define-public font-hack (package (name "font-hack") (version "3.003") (source (origin (method url-fetch/zipbomb) (uri (string-append "https://github.com/source-foundry/Hack/releases/download/v" version "/Hack-v" version "-ttf.zip")) (sha256 (base32 "1b4hh8zkrx92m2v2vfkja1napb0192p0j3laqr0m018z3dih89hc")))) (build-system font-build-system) (home-page "https://sourcefoundry.org/hack/") (synopsis "Typeface designed for source code") (description "Hack is designed to be a workhorse typeface for code. It expands upon the Bitstream Vera & DejaVu projects, provides over 1,500 glyphs, and includes Powerline support.") (license ;; See https://github.com/source-foundry/Hack/issues/271 for details. (list license:expat ; the Hack modifications to... license:public-domain ; ...the DejaVu modifications to... (license:x11-style ; ...the Bitstream Vera typeface "file://LICENSE.md" "Bitstream Vera License"))))) (define-public font-adobe-source-code-pro (package (name "font-adobe-source-code-pro") (version "2.030R-ro-1.050R-it") (source (origin (method url-fetch) (uri (string-append "https://github.com/adobe-fonts/source-code-pro/archive/" (regexp-substitute/global ;; The upstream tag uses "/" between the roman and italic ;; versions, so substitute our "-" separator here. #f "R-ro-" version 'pre "R-ro/" 'post) ".tar.gz")) (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "0arhhsf3i7ss39ykn73d1j8k4n8vx7115xph6jwkd970p1cxvr54")))) (build-system font-build-system) (home-page "https://github.com/adobe-fonts/source-code-pro") (synopsis "Monospaced font family for user interface and coding environments") (description "Source Code Pro is a set of monospaced OpenType fonts that have been designed to work well in user interface environments.") (license license:silofl1.1))) (define-public font-adobe-source-sans-pro (package (name "font-adobe-source-sans-pro") (version "2.040R-ro-1.090R-it") (source (origin (method url-fetch) (uri (string-append "https://github.com/adobe-fonts/source-sans-pro/archive/" (regexp-substitute/global ;; The upstream tag uses "/" between the roman and italic ;; versions, so substitute our "-" separator here. #f "R-ro-" version 'pre "R-ro/" 'post) ".tar.gz")) (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "1wpbhd2idps53ph8rg1mhr3vz4lsgbpjprcq10nliwcxdz9d8lv0")))) (build-system font-build-system) (home-page "https://github.com/adobe-fonts/source-sans-pro") (synopsis "Sans serif font family for user interface environments") (description "Source Sans Pro is a set of OpenType fonts that have been designed to work well in user interface (UI) environments.") (license license:silofl1.1))) (define-public font-adobe-source-serif-pro (package (name "font-adobe-source-serif-pro") (version "2.007R-ro-1.007R-it") (source (origin (method url-fetch) (uri (string-append "https://github.com/adobe-fonts/source-serif-pro/archive/" (regexp-substitute/global ;; The upstream tag uses "/" between the roman and italic ;; versions, so substitute our "-" separator here. #f "R-ro-" version 'pre "R-ro/" 'post) ".tar.gz")) (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "1sws9k26ldqk375qsigk1zv8cq1xlvadjwvv3dqrcc3qzm1c7hwc")))) (build-system font-build-system) (home-page "https://github.com/adobe-fonts/source-serif-pro") (synopsis "Serif typeface to complement Source Sans Pro for setting text") (description "Source Serif Pro is a set of OpenType fonts to complement the Source Sans Pro family.") (license license:silofl1.1))) (define-public font-fira-mono (package (name "font-fira-mono") (version "3.206") (source (origin (method url-fetch) (uri (string-append "https://carrois.com/downloads/fira_mono_3_2/" "FiraMonoFonts" (string-replace-substring version "." "") ".zip")) (sha256 (base32 "1z65x0dw5dq6rs6p9wyfrir50rlh95vgzsxr8jcd40nqazw4jhpi")))) (build-system font-build-system) (home-page "https://mozilla.github.io/Fira/") (synopsis "Mozilla's monospace font") (description "This is the typeface used by Mozilla in Firefox OS.") (license license:silofl1.1))) (define-public font-fira-sans (package (name "font-fira-sans") (version "4.202") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/mozilla/Fira.git") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "116j26gdj5g1r124b4669372f7490vfjqw7apiwp2ggl0am5xd0w")))) (build-system font-build-system) (home-page "https://mozilla.github.io/Fira/") (synopsis "Mozilla's Fira Sans Font") (description "This is the typeface used by Mozilla in Firefox OS.") (license license:silofl1.1))) (define-public font-fira-code (package (name "font-fira-code") (version "1.206") (source (origin (method url-fetch/zipbomb) (uri (string-append "https://github.com/tonsky/FiraCode/releases/" "download/" version "/FiraCode_" version ".zip")) (sha256 (base32 "02r1lcp0c9135ps71v66wdvbsrcxwirrp0blqsa1xbjkkq2rwgj3")))) (build-system font-build-system) (home-page "https://mozilla.github.io/Fira/") (synopsis "Monospaced font with programming ligatures") (description "Fira Code is an extension of the Fira Mono font containing a set of ligatures for common programming multi-character combinations. This is just a font rendering feature: underlying code remains ASCII-compatible. This helps to read and understand code faster. For some frequent sequences like .. or //, ligatures allow us to correct spacing.") (license license:silofl1.1))) (define-public font-awesome (package (name "font-awesome") ;; XXX The build scripts of version 5 are not freely licensed and ;; so we have to stick with version 4 for now: ;; (version "4.7.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/FortAwesome/Font-Awesome.git") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0w30y26jp8nvxa3iiw7ayl6rkza1rz62msl9xw3srvxya1c77grc")))) (build-system font-build-system) (arguments '(#:phases (modify-phases %standard-phases (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (source (string-append (getcwd) "/fonts")) (fonts (string-append out "/share/fonts"))) (for-each (lambda (file) (install-file file (string-append fonts "/truetype"))) (find-files source "\\.(ttf|ttc)$")) (for-each (lambda (file) (install-file file (string-append fonts "/opentype"))) (find-files source "\\.(otf|otc)$")) #t)))))) (home-page "https://fontawesome.com/") (synopsis "Font that contains a rich iconset") (description "Font Awesome is a full suite of pictographic icons for easy scalable vector graphics.") (license license:silofl1.1))) (define-public font-tamzen (package (name "font-tamzen") (version "1.11.4") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/sunaku/tamzen-font.git") (commit (string-append "Tamzen-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "17kgmvg6q32mqhx9g44hjvzv0si0mnpprga4z7na930g2zdd8846")))) (build-system trivial-build-system) (arguments `(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (let* ((out (assoc-ref %outputs "out")) (font-dir (string-append out "/share/fonts/misc")) (psf-dir (string-append out "/share/kbd/consolefonts"))) (chdir (assoc-ref %build-inputs "source")) (mkdir-p font-dir) (mkdir-p psf-dir) (for-each (lambda (pcf) (install-file pcf font-dir)) (find-files "pcf" "\\.pcf$")) (for-each (lambda (psf) (install-file psf psf-dir)) (find-files "psf" "\\.psf$")) #t)))) (home-page "https://github.com/sunaku/tamzen-font") (synopsis "Monospaced bitmap font for console and X11") (description "Tamzen is a fork of the @code{Tamsyn} font. It is programmatically forked from @code{Tamsyn} version 1.11, backporting glyphs from older versions while deleting deliberately empty glyphs (which are marked as unimplemented) to allow secondary/fallback fonts to provide real glyphs at those codepoints. The @code{TamzenForPowerline} fonts provide additional @code{Powerline} symbols, which are programmatically injected with @code{bitmap-font-patcher} and later hand-tweaked with the gbdfed(1) editor: @enumerate @item all icons are expanded to occupy the maximum available space @item the branch of the fork icon ( U+E0A0) was made larger than the trunk @item for the newline icon ( U+E0A1), the @emph{N} was made larger at the bottom @item the keyhole in the padlock icon ( U+E0A2) was replaced with @emph{//} lines. @end enumerate\n") (license (license:non-copyleft "file://LICENSE")))) (define-public font-comic-neue (package (name "font-comic-neue") ;; The ‘v2.3’ and ‘v2.4’ releases at https://github.com/crozynski/comicneue ;; are equivalent. The home page hosts 2.3, not 2.4, so we use that here. (version "2.3") (source (origin (method url-fetch/zipbomb) (uri (string-append "http://www.comicneue.com/comic-neue-" version ".zip")) (sha256 (base32 "1695hkpd8kqnr2a88p8xs496slgzxjjkzpa9aa33ml3pnh7519zk")))) (build-system font-build-system) (arguments `(#:phases (modify-phases %standard-phases ;; Delete Mac OS X specific files. If not deleted, these cause ;; several hidden files to be installed. (add-before 'install 'delete-macosx-files (lambda _ (delete-file-recursively "__MACOSX") #t)) (add-after 'install 'install-conf (lambda* (#:key outputs #:allow-other-keys) (let ((conf-dir (string-append (assoc-ref outputs "out") "/share/fontconfig/conf.avail"))) (mkdir-p conf-dir) (call-with-output-file (string-append conf-dir "/30-comic-neue.conf") (lambda (port) (format port " Comic Sans MS Comic Neue \n")))) #t))))) (home-page "http://www.comicneue.com/") (synopsis "Font that fixes the shortcomings of Comic Sans") (description "Comic Neue is a font that attempts to create a respectable casual typeface, by mimicking Comic Sans while fixing its most obvious shortcomings.") (license license:silofl1.1))) (define-public font-iosevka (package (name "font-iosevka") ;; When updating, also update the hash of the Iosevka variant(s) below. (version "2.3.3") (source (origin (method url-fetch/zipbomb) (uri (string-append "https://github.com/be5invis/Iosevka" "/releases/download/v" version "/ttc-iosevka-" version ".zip")) (sha256 (base32 "0jkv5rkg5hi0avhwyhcjiqzjslp6zjj77f09vxx2gj9l93byz731")))) (build-system font-build-system) (home-page "https://be5invis.github.io/Iosevka/") (synopsis "Coders' typeface, built from code") (description "Iosevka is a slender monospace sans-serif or slab-serif typeface inspired by Pragmata Pro, M+, and PF DIN Mono, designed to be the ideal font for programming. Iosevka is completely generated from its source code.") (license (list license:silofl1.1 ; build artifacts (i.e. the fonts) license:bsd-3)))) ; supporting code (define-public font-iosevka-slab (package (inherit font-iosevka) (name "font-iosevka-slab") (version (package-version font-iosevka)) (source (origin (method url-fetch/zipbomb) (uri (string-append "https://github.com/be5invis/Iosevka" "/releases/download/v" version "/ttc-iosevka-slab-" version ".zip")) (sha256 (base32 "1rkmgi08kknc1fg54zpa6w92m3b3v7pc8cpwygz22kgd2h0mdrr8")))))) (define-public font-go (let ((commit "f03a046406d4d7fbfd4ed29f554da8f6114049fc") (revision "1")) (package (name "font-go") (version (string-append "20170330-" revision "." (string-take commit 7))) (source (origin (file-name (string-append "go-image-" version "-checkout")) (method git-fetch) (uri (git-reference (url "https://go.googlesource.com/image") (commit commit))) (sha256 (base32 "1aq6mnjayks55gd9ahavk6jfydlq5lm4xm0xk4pd5sqa74p5p74d")))) (build-system font-build-system) (arguments `(#:phases (modify-phases %standard-phases (add-before 'install 'chdir (lambda _ (chdir "font/gofont/ttfs") #t))))) (home-page "https://blog.golang.org/go-fonts") (synopsis "The Go font family") (description "The Go font family is a set of WGL4 TrueType fonts from the Bigelow & Holmes type foundry, released under the same license as the Go programming language. It includes a set of proportional, sans-serif fonts, and a set of monospace, slab-serif fonts.") (license license:bsd-3)))) (define-public font-google-material-design-icons (package (name "font-google-material-design-icons") (version "3.0.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/google/material-design-icons.git") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "17q5brcqyyc8gbjdgpv38p89s60cwxjlwy2ljnrvas5cj0s62np0")))) (build-system font-build-system) (home-page "http://google.github.io/material-design-icons") (synopsis "Icon font of Google Material Design icons") (description "Material design system icons are simple, modern, friendly, and sometimes quirky. Each icon is created using our design guidelines to depict in simple and minimal forms the universal concepts used commonly throughout a UI. Ensuring readability and clarity at both large and small sizes, these icons have been optimized for beautiful display on all common platforms and display resolutions.") (license license:asl2.0))) (define-public font-open-dyslexic (package (name "font-open-dyslexic") (version "20160623") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/antijingoist/open-dyslexic.git") (commit (string-append version "-Stable")))) (file-name (git-file-name name version)) (sha256 (base32 "0nr7s92nk1kbr459154idnib977ixc70z6g9mbra3lp73nyrmyvz")))) (build-system font-build-system) (home-page "https://opendyslexic.org") (synopsis "Font for dyslexics and high readability") (description "OpenDyslexic is a font designed to help readability for some of the symptoms of dyslexia. Letters have heavy weighted bottoms to provide an indication of orientation to make it more difficult to confuse with other similar letters. Consistently weighted bottoms can also help reinforce the line of text. The unique shapes of each letter can help prevent flipping and swapping. The italic style for OpenDyslexic has been crafted to be used for emphasis while still being readable.") (license (license:fsdg-compatible "https://www.gnome.org/fonts/#Final_Bitstream_Vera_Fonts" "The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.")))) (define-public font-dosis (package (name "font-dosis") (version "1.7") (source (origin (method url-fetch/zipbomb) (uri (string-append "http://www.impallari.com/media/releases/dosis-" "v" version ".zip")) (sha256 (base32 "1qhci68f68mf87jd69vjf9qjq3wydgw1q7ivn3amjb65ls1s0c4s")))) (build-system font-build-system) (home-page "http://www.impallari.com/dosis") (synopsis "Very simple, rounded, sans serif family") (description "Dosis is a very simple, rounded, sans serif family. The lighter weights are minimalist. The bolder weights have more personality. The medium weight is nice and balanced. The overall result is a family that's clean and modern, and can express a wide range of voices & feelings. It comes in 7 incremental weights: ExtraLight, Light, Book, Medium, Semibold, Bold & ExtraBold") (license license:silofl1.1))) (define-public font-culmus (package (name "font-culmus") (version "0.133") (source (origin (method url-fetch) (uri (string-append "https://sourceforge.net/projects/" "culmus/files/culmus/" version "/culmus-src-" version ".tar.gz")) (sha256 (base32 "02akysgsqhi15cck54xcacm16q5raf4l7shgb8fnj7xr3c1pbfyp")))) (build-system font-build-system) (arguments `(#:phases (modify-phases %standard-phases (add-before 'install 'build (lambda _ (let ((compile (lambda (name ext) (invoke "fontforge" "-lang=ff" "-c" (string-append "Open('" name "');" "Generate('" (basename name "sfd") ext "')"))))) ;; This part based on the fonts shipped in the non-source package. (for-each (lambda (name) (compile name "ttf")) (find-files "." "^[^Nachlieli].*\\.sfd$")) (for-each (lambda (name) (compile name "otf")) (find-files "." "^Nachlieli.*\\.sfd$")) #t)))))) (native-inputs `(("fontforge" ,fontforge))) (home-page "http://culmus.sourceforge.net/") (synopsis "TrueType Hebrew Fonts for X11") (description "14 Hebrew trivial families. Contain ASCII glyphs from various sources. Those families provide a basic set of a serif (Frank Ruehl), sans serif (Nachlieli) and monospaced (Miriam Mono) trivials. Also included Miriam, Drugulin, Aharoni, David, Hadasim etc. Cantillation marks support is available in Keter YG.") (license license:gpl2))) ; consult the LICENSE file included (define-public font-lohit (package (name "font-lohit") (version "20140220") (source (origin (method url-fetch) (uri (string-append "https://releases.pagure.org/lohit/lohit-ttf-" version ".tar.gz")) (sha256 (base32 "1rmgr445hw1n851ywy28csfvswz1i6hnc8mzp88qw2xk9j4dn32d")))) (build-system font-build-system) (home-page "https://pagure.io/lohit") (synopsis "Lohit TrueType Indic fonts") (description "Lohit is a font family designed to cover Indic scripts. Lohit supports the Assamese, Bengali, Devanagari (Hindi, Kashmiri, Konkani, Maithili, Marathi, Nepali, Sindhi, Santali, Bodo, Dogri languages), Gujarati, Kannada, Malayalam, Manipuri, Oriya, Punjabi, Tamil and Telugu scripts.") (license license:silofl1.1))) (define-public font-blackfoundry-inria (package (name "font-blackfoundry-inria") (version "1.200") (home-page "https://github.com/BlackFoundry/InriaFonts") (source (origin (method git-fetch) (uri (git-reference (url home-page) (commit (string-append "v" version)))) (sha256 (base32 "06775y99lyh6hj5hzvrx56iybdck8a8xfqkipqd5c4cldg0a9hh8")) (file-name (string-append name "-" version "-checkout")))) ;; XXX: There are .ufo directories (the "source") so in theory we should ;; be able to rebuild TTF and OTF files with FontForge. Unfortunately a ;; command like: ;; ;; fontforge -lang=ff -c "Open('InriaSans-Regular.ufo'); Generate('foo.ttf');" ;; ;; segfaults in '_UFOLoadGlyph', which calls out to libpython. :-/ ;; In the meantime we ship the precompiled OTF and TTF files. (build-system font-build-system) (synopsis "Inria Sans and Inria Serif type family") (description "Inria Sans and Inria Serif are the two members of a type family designed for Inria, a public research institute in computer science and mathematics.") (license license:silofl1.1))) (define-public font-sil-gentium (package (name "font-sil-gentium") (version "5.000") (source (origin (method url-fetch) (uri (string-append "https://software.sil.org/downloads/r/gentium/GentiumPlus-" version ".zip")) (sha256 (base32 "0m7189870hha217n1vgpmf89mwggrxkh679ffi1lxpnjggqi2n9k")))) ;; Note: The zip file provides TTF files only, but the developer release, ;; which contains additional files, has a 'SOURCES.txt' file that says ;; that "the primary source files for the fonts are the fonts themselves". ;; Thus it looks like the TTF can be considered source. (build-system font-build-system) (synopsis "Serif font for the Cyrillic, Greek, and Latin alphabets") (description "Gentium is a typeface family designed to enable the diverse ethnic groups around the world who use the Latin, Cyrillic and Greek scripts to produce readable, high-quality publications. The font comes with regular and italics shapes. This package provides only TrueType files (TTF).") (home-page "https://software.sil.org/gentium/") (license license:silofl1.1))) (define-public font-sil-andika (package (name "font-sil-andika") (version "5.000") (source (origin (method url-fetch) (uri (string-append "https://software.sil.org/downloads/r/andika/Andika-" version ".zip")) (sha256 (base32 "01zm7p32gxfwmv7h3cfj2vx59846w2y6rxqy67grn2dyjh8pljv0")))) ;; As for Gentium (see above), the TTF files are considered source. (build-system font-build-system) (synopsis "Sans serif font designed especially for literacy use") (description "Andika SIL is a sans serif, Unicode-compliant font designed especially for literacy use, taking into account the needs of beginning readers. The focus is on clear, easy-to-perceive letterforms that will not be readily confused with one another. This package provides only TrueType files (TTF).") (home-page "https://software.sil.org/andika/") (license license:silofl1.1))) (define-public font-sil-charis (package (name "font-sil-charis") (version "5.000") (source (origin (method url-fetch) (uri (string-append "https://software.sil.org/downloads/r/charis/CharisSIL-" version ".zip")) (sha256 (base32 "1zcvw37f1a7gkml3yfm6hxh93844llm7xj4w52600qq3ndrm8gjy")))) ;; As for Gentium (see above), the TTF files are considered source. (build-system font-build-system) (synopsis "Serif font for the Cyrillic and Latin alphabets") (description "Charis SIL is a Unicode-based font family that supports the wide range of languages that use the Latin and Cyrillic scripts. It is specially designed to make long texts pleasant and easy to read, even in less than ideal reproduction and display environments. This package provides only TrueType files (TTF).") (home-page "https://software.sil.org/charis/") (license license:silofl1.1))) (define-public font-mononoki (package (name "font-mononoki") (version "1.2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/madmalik/mononoki/") (commit version))) (sha256 (base32 "1rkzyxn30rn8qv2h2xz324j7q15hzg2lci8790a7cdl1dfgic4xi")) (file-name (git-file-name name version)))) (build-system font-build-system) (synopsis "Font for programming and code review") (description "Mononoki is a typeface by Matthias Tellen, created to enhance code formatting.") (home-page "https://madmalik.github.io/mononoki/") (license license:silofl1.1))) (define-public font-public-sans (package (name "font-public-sans") (version "1.0.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/uswds/public-sans.git") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "12ccj7ph3pg962d52d3slbvd44gwfm6bb2846dxyf1xc5h2iwhdv")) (modules '((guix build utils))) (snippet '(begin ;; remove versions of predecessor font (delete-file-recursively "fonts/_archive") #t)))) (build-system font-build-system) (home-page "https://public-sans.digital.gov/") (synopsis "Neutral typeface for interfaces, text, and headings") (description "Public Sans is a strong, neutral, sans-serif typeface for text or display based on Libre Franklin.") (license license:silofl1.1))) (define-public font-hermit (package (name "font-hermit") (version "2.0") (source (origin (method url-fetch/tarbomb) (uri (string-append "https://pcaro.es/d/otf-hermit-" version ".tar.gz")) (sha256 (base32 "09rmy3sbf1j1hr8zidighjgqc8kp0wsra115y27vrnlf10ml6jy0")))) (build-system font-build-system) (arguments `(#:tests? #f)) (home-page "https://pcaro.es/p/hermit/") (synopsis "Monospace font") (description "Hermit is a monospace font designed to be clear, pragmatic and very readable. Its creation has been focused on programming. Every glyph was carefully planned and calculated, according to defined principles and rules. For this reason, Hermit is coherent and regular. Symbols stand out from common text. Dots and commas are easily seen, and operators are clear even when not surrounded by spaces. Similar characters have been designed to be very distinguishable from each other.") (license license:silofl1.1))) (define-public font-dseg (package (name "font-dseg") (version "0.45") (source (origin (method url-fetch/zipbomb) (uri (string-append "https://github.com/keshikan/DSEG/" "releases/download/v" version "/fonts-DSEG_v" (string-concatenate (string-split version #\.)) ".zip")) (sha256 (base32 "0v8sghh4vl286faf8pvi74znz07pyf0qii8z4wjllisqwc35sx72")))) (build-system font-build-system) (arguments `(#:phases (modify-phases %standard-phases (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (font-dir (string-append out "/share/fonts")) (truetype-dir (string-append font-dir "/truetype"))) (with-directory-excursion (string-append "fonts-DSEG_v" (apply string-append (string-split ,version #\.))) (for-each (lambda (f) (install-file f truetype-dir)) (find-files "." "\\.ttf$")) #t))))))) (home-page "https://www.keshikan.net/fonts-e.html") (synopsis "DSEG: 7-segment and 14-segment fonts") (description "DSEG is a font family that imitates seven- and fourteen-segment LCD displays (7SEG, 14SEG). DSEG includes the roman alphabet and symbol glyphs. This package provides the TrueType fonts.") (license license:silofl1.1)))