summaryrefslogtreecommitdiff
path: root/gnu/packages/linux.scm
diff options
context:
space:
mode:
authorSergio Pastor Pérez <sergio.pastor-perez@inria.fr>2026-07-20 10:21:51 +0200
committerVagrant Cascadian <vagrant@debian.org>2026-08-27 00:05:04 -0700
commit7b017250d937e08137dcb33dd67c97d6332534b7 (patch)
treeda5164c56a7697f40219dba65b52d5f9346d54c7 /gnu/packages/linux.scm
parent38a7797012907bc8e0ec5f6d4e76aede9666e38a (diff)
gnu: linux: Use package properties to modularize initrd build.
* doc/guix.texi (operating-system Reference): Document initrd-modules change. (Initial RAM Disk): Inform about deprecation of '%base-initrd-modules' and document 'base-initrd-modules'. * gnu/packages/linux.scm (make-linux*): New argument 'produced-modules'. Handle GEXP in 'defconfig' arguments. (virtio-modules, default-linux-libre-initrd-modules): New variable. (make-linux-libre*): Adjust to instruct 'make-linux*' which modules a Debian configuration will produce. * gnu/system.scm (<operating-system>): Compute default operating systems initrd modules with 'base-initrd-modules'. * gnu/system/linux-initrd.scm (default-initrd-modules): Remove in favor of 'base-initrd-modules' which takes a mandatory kernel argument from which to extract the initrd-modules from the package properties. (base-initrd-modules): New procedure. (%base-initrd-modules): Deprecate in favor of 'base-initrd-modules'.
Diffstat (limited to 'gnu/packages/linux.scm')
-rw-r--r--gnu/packages/linux.scm103
1 files changed, 86 insertions, 17 deletions
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 6965528ab7a..252328f4230 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1047,7 +1047,7 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
1047 (and (version>=? version "5.10") 1047 (and (version>=? version "5.10")
1048 (not (version>=? version "6.2")))) ;patch applied upstream 1048 (not (version>=? version "6.2")))) ;patch applied upstream
1049 1049
1050(define* (make-linux* version source supported-systems 1050(define* (make-linux* version source supported-systems produced-modules
1051 #:key 1051 #:key
1052 (extra-version #f) 1052 (extra-version #f)
1053 ;; A function that takes an arch and a variant. 1053 ;; A function that takes an arch and a variant.
@@ -1055,6 +1055,30 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
1055 (configuration-file #f) 1055 (configuration-file #f)
1056 (defconfig "defconfig") 1056 (defconfig "defconfig")
1057 (extra-options (default-extra-linux-options version))) 1057 (extra-options (default-extra-linux-options version)))
1058 "Create a Linux package from VERSION using SOURCE for SUPPORTED-SYSTEMS.
1059
1060Produced modules will use package-properties to convey which modules the given
1061configuration produced either by CONFIGURATION-FILE or DEFCONFIG will yield.
1062This allows 'operating-system' records to infer their 'intrd-modules' value
1063from their 'kernel' field package.
1064
1065EXTRA-VERSION will control the emitted package name as well as the
1066EXTRAVERSION value of the kernel build.
1067
1068CONFIGURATION-FILE is a file-like object which will be used as the
1069configuration file to use for building the kernel. If used the DEFCONFIG
1070argument will be ignored.
1071
1072DEFCONFIG can either be a string, which will control the make target that
1073generates the configuration file used for building the kernel, or a GEXP which
1074should produce the '.config' file that will be used for building the kernel.
1075
1076EXTRA-OPTIONS will be appended to the configuration file provided by
1077CONFIGURATION-FILE or generated by DEFCONFIG. It must be an alist where each element has the form:
1078(KERNEL-OPTION . VALUE)
1079
1080KERNEL-OPTION must be a string and VALUE can be '#t', '#f' or 'm' for
1081instructing that the configuration option should build a kernel module."
1058 (package 1082 (package
1059 (name (if extra-version 1083 (name (if extra-version
1060 (string-append "linux-" extra-version) 1084 (string-append "linux-" extra-version)
@@ -1133,7 +1157,13 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
1133 (begin 1157 (begin
1134 (copy-file config ".config") 1158 (copy-file config ".config")
1135 (chmod ".config" #o666)) 1159 (chmod ".config" #o666))
1136 (invoke "make" #$defconfig)) 1160 #$(cond
1161 ((string? defconfig)
1162 #~(invoke "make" #$defconfig))
1163 ((promise? defconfig)
1164 (force defconfig))
1165 (else
1166 defconfig)))
1137 ;; Appending works even when the option wasn't in the file. 1167 ;; Appending works even when the option wasn't in the file.
1138 ;; The last one prevails if duplicated. 1168 ;; The last one prevails if duplicated.
1139 (let ((port (open-file ".config" "a")) 1169 (let ((port (open-file ".config" "a"))
@@ -1211,7 +1241,9 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
1211 (home-page #f) 1241 (home-page #f)
1212 (synopsis #f) 1242 (synopsis #f)
1213 (description #f) 1243 (description #f)
1214 (license #f))) 1244 (license #f)
1245 (properties
1246 `((base-initrd-modules . ,produced-modules)))))
1215 1247
1216(define* (make-linux-libre version gnu-revision hash-string supported-systems 1248(define* (make-linux-libre version gnu-revision hash-string supported-systems
1217 #:key 1249 #:key
@@ -1240,6 +1272,39 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
1240 #:defconfig defconfig 1272 #:defconfig defconfig
1241 #:extra-options extra-options)) 1273 #:extra-options extra-options))
1242 1274
1275(define virtio-modules
1276 ;; Modules for Linux para-virtualized devices, for use in QEMU guests.
1277 '("virtio_pci" "virtio_balloon" "virtio_blk" "virtio_net"
1278 "virtio_console" "virtio-rng" "virtio_mmio" "virtio_scsi"))
1279
1280(define default-linux-libre-initrd-modules
1281 ;; Default set of modules that need to be available in the initrd when
1282 ;; booting Linux-libre.
1283 (let* ((generic `("ahci" ;for SATA controllers
1284 "nvme" ;for NVMe controllers
1285 "usb-storage" "uas" ;for the installation image etc.
1286 "usbhid" "hid-generic" ;keyboards during early boot
1287 "mmc_block" ;for MMC block device driver
1288 "dm-crypt" "xts" "serpent_generic" "wp512" ;for encrypted root partitions
1289 "nls_iso8859-1" ;for `mkfs.fat`, et.al
1290 ,@virtio-modules))
1291 (_86 (cons*
1292 "hid-apple"
1293 "pata_acpi" "pata_atiixp" ;for ATA controllers
1294 "isci"
1295 generic))
1296 (others (cons*
1297 "hid-apple"
1298 generic)))
1299 `(("x86_64-linux" . ,_86)
1300 ("i686-linux" . ,_86)
1301 ("armhf-linux" . ,others)
1302 ("aarch64-linux" . ,others)
1303 ("mips64el-linux" . ,others)
1304 ("powerpc-linux" . ,others)
1305 ("powerpc64le-linux" . ,others)
1306 ("riscv64-linux" . ,generic))))
1307
1243(define* (make-linux-libre* version gnu-revision source supported-systems 1308(define* (make-linux-libre* version gnu-revision source supported-systems
1244 #:key 1309 #:key
1245 (extra-version #f) 1310 (extra-version #f)
@@ -1248,21 +1313,25 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
1248 (configuration-file #f) 1313 (configuration-file #f)
1249 (defconfig "defconfig") 1314 (defconfig "defconfig")
1250 (extra-options (default-extra-linux-options version))) 1315 (extra-options (default-extra-linux-options version)))
1251 (package 1316 (let ((linux (make-linux* version source supported-systems
1252 (inherit (make-linux* version source supported-systems 1317 default-linux-libre-initrd-modules
1253 #:extra-version extra-version 1318 #:extra-version extra-version
1254 #:configuration-file configuration-file 1319 #:configuration-file configuration-file
1255 #:defconfig defconfig 1320 #:defconfig defconfig
1256 #:extra-options extra-options)) 1321 #:extra-options extra-options)))
1257 (name (if extra-version 1322 (package
1258 (string-append "linux-libre-" extra-version) 1323 (inherit linux)
1259 "linux-libre")) 1324 (name (if extra-version
1260 (home-page "https://www.gnu.org/software/linux-libre/") 1325 (string-append "linux-libre-" extra-version)
1261 (synopsis "100% free redistribution of a cleaned Linux kernel") 1326 "linux-libre"))
1262 (description "GNU Linux-Libre is a free (as in freedom) variant of the 1327 (home-page "https://www.gnu.org/software/linux-libre/")
1328 (synopsis "100% free redistribution of a cleaned Linux kernel")
1329 (description "GNU Linux-Libre is a free (as in freedom) variant of the
1263Linux kernel. It has been modified to remove all non-free binary blobs.") 1330Linux kernel. It has been modified to remove all non-free binary blobs.")
1264 (license license:gpl2) 1331 (license license:gpl2)
1265 (properties %linux-libre-timeout-properties))) 1332 (properties (append %linux-libre-timeout-properties
1333 (package-properties linux))))))
1334
1266 1335
1267 1336
1268;;; 1337;;;