Subject: [bug#67983] built-in downloader

From: Jaeme Sifat <[email-masked]>
Date: Sun, 21 Jan 2024 12:25:32 -0500

On 1/21/24 03:29, Liliana Marie Prikler wrote:

> Am Samstag, dem 20.01.2024 um 18:51 -0500 schrieb Jaeme Sifat:
>> Hi, This is just a friendly bump for my patchset to add nerd font
>> packages to Emacs. There has been no activity on this thread for
>> almost a month regarding the new patches.
> I don't see how "a built-in downloader" fixes the issues I've pointed
> out.  Rather, unless this downloader only picks free fonts, it might
> well violate the FSDG.  I think we'd do well in substitute*-ing the
> nerd fonts where needed.
>
> Cheers

On closer inspection, The built-in downloader for `nerd-icons.el' is 
this procedure.

--8<---------------cut here---------------start------------->8---

;;;###autoload
(defun nerd-icons-install-fonts (&optional pfx)
   "Helper function to download and install the latests fonts based on OS.
The provided Nerd Font is Symbols Nerd Font Mono.
When PFX is non-nil, ignore the prompt and just install"
   (interactive "P")
   (when (or pfx (yes-or-no-p "This will download and install fonts, are you sure you want to do this?"))
     (let* ((url-format "https://raw.githubusercontent.com/rainstormstudio/nerd-icons.el/main/fonts/%s")
            (font-dest (cond
                        ;; Default Linux install directories
                        ((member system-type '(gnu gnu/linux gnu/kfreebsd))
                         (concat (or (getenv "XDG_DATA_HOME")
                                     (concat (getenv "HOME") "/.local/share"))
                                 "/fonts/"
                                 nerd-icons-fonts-subdirectory))
                        ;; Default MacOS install directory
                        ((eq system-type 'darwin)
                         (concat (getenv "HOME")
                                 "/Library/Fonts/"
                                 nerd-icons-fonts-subdirectory))))
            (known-dest? (stringp font-dest))
            (font-dest (or font-dest (read-directory-name "Font installation directory: " "~/"))))

       (unless (file-directory-p font-dest) (mkdir font-dest t))

       (mapc (lambda (font)
               (url-copy-file (format url-format font) (expand-file-name font font-dest) t))
             nerd-icons-font-names)
       (when known-dest?
         (message "Fonts downloaded, updating font cache... <fc-cache -f -v> ")
         (shell-command-to-string (format "fc-cache -f -v")))
       (message "%s Successfully %s `nerd-icons' fonts to `%s'!"
                (nerd-icons-wicon "nf-weather-stars" :v-adjust 0.0)
                (if known-dest? "installed" "downloaded")
                font-dest))))

--8<---------------cut here---------------end--------------->8---

The provided font is Symbols Nerd Font Mono, which is distributed under the expat license.
However, I agree that this built in downloader has the chance of violating the FSDG sometime in the future
since it points to the main branch of the repo. It [the nerd icons repository] also redistributes the nerd icons font
without the respective license notice.

> I think we'd do well in substitute*-ing the
> nerd fonts where needed.

I agree, the much better solution would be to create a patch that removes this crude built-in downloader and instead uses Guix for
the nerd icons. So I'm going to send patches that 1. removes the built-in font downloader for `emacs-nerd-icons' and 2.
Adds the nerd icons font to Emacs (licensed under expat) and 3. Adds that icon font as a propagated input to `emacs-nerd-icons'

As a note I'm surprised that `emacs-nerd-icons' managed to be merged into master as it seems to be the main culprit.
Maybe we should remove it for the sake of consistency until this fix is made? I'm willing to send a revised patchset
that contains all the emacs nerd font packages + compliance patches with the FSDG.

I'm going to see what I can do, thank you for your patience.

---
Jaeme