nongnu: linux: Enable mt7921e driver.

In order to be able to use WiFi chip in P14s ThinkPad, the mt7921e module is
required.  This commit enables it in kernels that do have it.

I originally implemented this using a list of additional option, same way
%default-extra-linux-options is done.  However I quickly realized that
approach is not suitable for hardware enablement.  The older versions do not
support the same drivers as the newer ones.

Solution is to create a new procedure that generates the list for a specific
kernel version and use it as a default value for #:configs.

* nongnu/packages/linux.scm (nonguix-extra-linux-options): New procedure.
(corrupt-linux): Use it as default value for #:configs.

Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
Tomas Volf 2024-01-11 13:30:38 +01:00 committed by Jonathan Brielmaier
parent d0a8b135d3
commit 3857d86267
No known key found for this signature in database
GPG key ID: ECFC83988B4E4B9F

View file

@ -24,6 +24,7 @@
;;; Copyright © 2023 Adam Kandur <rndd@tuta.io> ;;; Copyright © 2023 Adam Kandur <rndd@tuta.io>
;;; Copyright © 2023 Hilton Chain <hako@ultrarare.space> ;;; Copyright © 2023 Hilton Chain <hako@ultrarare.space>
;;; Copyright © 2023 Ada Stevenson <adanskana@gmail.com> ;;; Copyright © 2023 Ada Stevenson <adanskana@gmail.com>
;;; Copyright © 2023 Tomas Volf <~@wolfsden.cz>
(define-module (nongnu packages linux) (define-module (nongnu packages linux)
#:use-module (gnu packages) #:use-module (gnu packages)
@ -52,10 +53,42 @@
"/linux/kernel/v" (version-major version) ".x" "/linux/kernel/v" (version-major version) ".x"
"/linux-" version ".tar.xz")) "/linux-" version ".tar.xz"))
;;; If you are corrupting the kernel on your own, consider using output of
;;; this procedure as a base for your options:
;;; (corrupt-linux linux-libre-lts
;;; #:configs (cons* "CONFIG_FOO=y"
;;; (nonguix-extra-linux-options linux-libre-lts)
(define-public (nonguix-extra-linux-options linux-or-version)
"Return a list containing additional options that nonguix sets by default
for a corrupted linux package of specified version. linux-or-version can be
some freedo package or an output of package-version procedure."
(define linux-version
(if (package? linux-or-version)
(package-version linux-or-version)
linux-or-version))
(reverse (fold (lambda (opt opts)
(if (version>=? linux-version (car opt))
(cons* (cdr opt) opts)
opts))
'()
;; List of additional options for nonguix corrupted linux.
;; Each member is a pair of a minimal version (>=) and the
;; option itself. Option has to be in a format suitable for
;; (@ (guix build kconfig) modify-defconfig) procedure.
;;
;; Do note that this list is intended for enabling use of
;; hardware requiring non-free firmware. If a configuration
;; option does work under linux-libre, it should go into Guix
;; actual.
'(
;; Driver for MediaTek mt7921e wireless chipset
("5.15" . "CONFIG_MT7921E=m")))))
(define* (corrupt-linux freedo (define* (corrupt-linux freedo
#:key #:key
(name "linux") (name "linux")
(configs '()) (configs (nonguix-extra-linux-options freedo))
(defconfig #f)) (defconfig #f))
;; TODO: This very directly depends on guix internals. ;; TODO: This very directly depends on guix internals.