From 3857d86267284000dc48660a5dfd56cb2a8cf004 Mon Sep 17 00:00:00 2001 From: Tomas Volf <~@wolfsden.cz> Date: Thu, 11 Jan 2024 13:30:38 +0100 Subject: [PATCH] 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 --- nongnu/packages/linux.scm | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/nongnu/packages/linux.scm b/nongnu/packages/linux.scm index 652f258..365590c 100644 --- a/nongnu/packages/linux.scm +++ b/nongnu/packages/linux.scm @@ -24,6 +24,7 @@ ;;; Copyright © 2023 Adam Kandur ;;; Copyright © 2023 Hilton Chain ;;; Copyright © 2023 Ada Stevenson +;;; Copyright © 2023 Tomas Volf <~@wolfsden.cz> (define-module (nongnu packages linux) #:use-module (gnu packages) @@ -52,10 +53,42 @@ "/linux/kernel/v" (version-major version) ".x" "/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 #:key (name "linux") - (configs '()) + (configs (nonguix-extra-linux-options freedo)) (defconfig #f)) ;; TODO: This very directly depends on guix internals.