hardware.scm 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
  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. (define-module (gnu installer hardware)
  18. #:use-module (gnu build linux-modules)
  19. #:use-module (guix i18n)
  20. #:use-module (srfi srfi-1)
  21. #:use-module (srfi srfi-71)
  22. #:export (unsupported-pci-device?
  23. pci-device-description))
  24. (define %unsupported-linux-modules
  25. ;; List of Linux modules that are useless without non-free firmware.
  26. ;;
  27. ;; Currently only drivers for PCI devices are listed. USB devices such as
  28. ;; "btintel" would require support to list USB devices and read the USB
  29. ;; device ID database. Punt for now as this is usually less critical.
  30. ;;
  31. ;; This list is currently manually maintained based on information on
  32. ;; non-free firmware available from
  33. ;; <https://packages.debian.org/search?keywords=firmware&searchon=names&suite=stable&section=all>.
  34. '(;; WiFi.
  35. "brcmfmac"
  36. "ipw2100"
  37. "ipw2200"
  38. "iwlwifi"
  39. "mwl8k"
  40. "rtl8188ee"
  41. "rtl818x_pci"
  42. "rtl8192ce"
  43. "rtl8192de"
  44. "rtl8192ee"
  45. ;; Ethernet.
  46. "bnx2"
  47. "bnx2x"
  48. "liquidio"
  49. ;; Graphics.
  50. "amdgpu"
  51. "radeon"
  52. ;; Multimedia.
  53. "ivtv"))
  54. (define unsupported-pci-device?
  55. ;; Arrange to load the module alias database only once.
  56. (let ((aliases (delay (known-module-aliases))))
  57. (lambda (device)
  58. "Return true if DEVICE is known to not be supported by free software."
  59. (any (lambda (module)
  60. (member module %unsupported-linux-modules))
  61. (matching-modules (pci-device-module-alias device)
  62. (force aliases))))))
  63. (define (pci-device-description pci-database)
  64. "Return a procedure that, given a PCI device, returns a string describing
  65. it."
  66. (define (with-fallback lookup)
  67. (lambda (vendor-id id)
  68. (let ((vendor name (lookup vendor-id id)))
  69. (values (or vendor (number->string vendor-id 16))
  70. (or name (number->string id 16))))))
  71. (define pci-lookup
  72. (with-fallback (load-pci-device-database pci-database)))
  73. (lambda (device)
  74. (let ((vendor name (pci-lookup (pci-device-vendor device)
  75. (pci-device-id device))))
  76. (if (network-pci-device? device)
  77. ;; TRANSLATORS: The two placeholders are the manufacturer
  78. ;; and name of a PCI device.
  79. (format #f (G_ "~a ~a (networking device)")
  80. vendor name)
  81. (string-append vendor " " name)))))