projects/guix·blob javascript-team · refs

90 lines · 3.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2022 Ludovic Courtès <[email protected]>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;;
15;;; You should have received a copy of the GNU General Public License
16;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
17
18(define-module (gnu installer hardware)
19 #:use-module (gnu build linux-modules)
20 #:use-module (guix i18n)
21 #:use-module (srfi srfi-1)
22 #:use-module (srfi srfi-71)
23 #:export (unsupported-pci-device?
24 pci-device-description))
25
26(define %unsupported-linux-modules
27 ;; List of Linux modules that are useless without non-free firmware.
28 ;;
29 ;; Currently only drivers for PCI devices are listed. USB devices such as
30 ;; "btintel" would require support to list USB devices and read the USB
31 ;; device ID database. Punt for now as this is usually less critical.
32 ;;
33 ;; This list is currently manually maintained based on information on
34 ;; non-free firmware available from
35 ;; <https://packages.debian.org/search?keywords=firmware&searchon=names&suite=stable&section=all>.
36 '(;; WiFi.
37 "brcmfmac"
38 "ipw2100"
39 "ipw2200"
40 "iwlwifi"
41 "mwl8k"
42 "rtl8188ee"
43 "rtl818x_pci"
44 "rtl8192ce"
45 "rtl8192de"
46 "rtl8192ee"
47
48 ;; Ethernet.
49 "bnx2"
50 "bnx2x"
51 "liquidio"
52
53 ;; Graphics.
54 "amdgpu"
55 "radeon"
56
57 ;; Multimedia.
58 "ivtv"))
59
60(define unsupported-pci-device?
61 ;; Arrange to load the module alias database only once.
62 (let ((aliases (delay (known-module-aliases))))
63 (lambda (device)
64 "Return true if DEVICE is known to not be supported by free software."
65 (any (lambda (module)
66 (member module %unsupported-linux-modules))
67 (matching-modules (pci-device-module-alias device)
68 (force aliases))))))
69
70(define (pci-device-description pci-database)
71 "Return a procedure that, given a PCI device, returns a string describing
72it."
73 (define (with-fallback lookup)
74 (lambda (vendor-id id)
75 (let ((vendor name (lookup vendor-id id)))
76 (values (or vendor (number->string vendor-id 16))
77 (or name (number->string id 16))))))
78
79 (define pci-lookup
80 (with-fallback (load-pci-device-database pci-database)))
81
82 (lambda (device)
83 (let ((vendor name (pci-lookup (pci-device-vendor device)
84 (pci-device-id device))))
85 (if (network-pci-device? device)
86 ;; TRANSLATORS: The two placeholders are the manufacturer
87 ;; and name of a PCI device.
88 (format #f (G_ "~a ~a (networking device)")
89 vendor name)
90 (string-append vendor " " name)))))