Subject: [bug#48314] [PATCH] Install guix system on Raspberry Pi

From: Maxim Cournoyer <[email-masked]>
Date: Thu, 01 Dec 2022 13:01:36 -0500

Hi,

> gnu: linux: New function to modify the configuration of a Linux kernel.
>
> From: Stefan <[email-masked]>
>
> * gnu/packages/linux.scm (system->linux-srcarch): New function to return the
> relevent folder name below arch/ in the Linux source code.
> (modify-linux): New function to make a customized Linux package inherited
> from another Linux package, which will be build with an own defconfig or
> configuration changes.
> (make-defconfig): Function to get a defconfig from an uri.

I've renamed it to customize-linux, and streamlined the commit message
like so:

--8<---------------cut here---------------start------------->8---
gnu: linux: Add a 'customize-linux' procedure.

* gnu/packages/linux.scm (linux-srcarch): New procedure.
(customize-linux): Likewise.
(make-defconfig): Procedure to retrieve a defconfig from an URI.

Signed-off-by: Maxim Cournoyer <[email-masked]>
Modified-by: Maxim Cournoyer <[email-masked]>
--8<---------------cut here---------------end--------------->8---

Otherwise, I've made the following changes (exporting procedures
explicitly from the modules):

--8<---------------cut here---------------start------------->8---
1 file changed, 25 insertions(+), 25 deletions(-)
gnu/packages/linux.scm | 50 +++++++++++++++++++++++++-------------------------

modified   gnu/packages/linux.scm
@@ -190,19 +190,19 @@ (define-module (gnu packages linux)
   #:use-module (srfi srfi-2)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
-  #:use-module (ice-9 optargs)
-  #:use-module (ice-9 regex))
+  #:use-module (ice-9 regex)
+  #:export (customize-linux))
 
-(define-public (linux-srcarch)
+(define (linux-srcarch)
   "Return the linux SRCARCH name, which is set in the toplevel Makefile of
-Linux and denotes the architecture specific directory name below arch/ in its
+Linux and denotes the architecture-specific directory name below arch/ in its
 source code.  Some few architectures share a common folder.  It resembles the
 definition of SRCARCH based on ARCH in the Makefile and may be used to place a
 defconfig file in the proper path."
   (let ((linux-arch (platform-linux-architecture
-                      (lookup-platform-by-target-or-system
-                        (or (%current-target-system)
-                            (%current-system))))))
+                     (lookup-platform-by-target-or-system
+                      (or (%current-target-system)
+                          (%current-system))))))
     (match linux-arch
       ("i386"    "x86")
       ("x86_64"  "x86")
@@ -213,7 +213,7 @@ (define-public (linux-srcarch)
 
 (define-public (system->defconfig system)
   "Some systems (notably powerpc-linux) require a special target for kernel
-defconfig.  Return the appropriate make target if applicable, otherwise return
+defconfig.  Return the appropriate Make target if applicable, otherwise return
 \"defconfig\"."
   (cond ((string-prefix? "powerpc-" system) "pmac32_defconfig")
         ((string-prefix? "powerpc64-" system) "ppc64_defconfig")
@@ -1271,19 +1271,19 @@ (define-public linux-libre-with-bpf
 ;;; Linux kernel customization functions.
 ;;;
 
-(define*-public (modify-linux #:key name
-                                    (linux linux-libre)
-                                    source
-                                    defconfig
-                                    (configs "")
-                                    extra-version)
-  "Make a Linux package NAME as a modification of another LINUX package.
+(define* (customize-linux #:key name
+                          (linux linux-libre)
+                          source
+                          defconfig
+                          (configs "")
+                          extra-version)
+  "Make a customized Linux package NAME derived from the LINUX package.
 
 If NAME is not given, then it defaults to the same name as the LINUX package.
 
 Unless SOURCE is given the source of LINUX is used.
 
-A DEFCONFIG file to be used can be given as an origin, as a file like object
+A DEFCONFIG file to be used can be given as an origin, as a file-like object
 (file-append, local-file etc.), or as a string with the name of a defconfig file
 available in the Linux sources.  If DEFCONFIG is not given, then a defconfig
 file will be saved from the LINUX package configuration.
@@ -1295,11 +1295,11 @@ (define*-public (modify-linux #:key name
 defconfig syntax has to be used, but there is a special extension to ease the
 removal of configurations.  Comment lines are supported as well.
 
-Here is an explaining usage example:
+Here is an example:
 
   '(;; This string defines the version tail in 'uname -r'.
     \"CONFIG_LOCALVERSION=\\\"-handcrafted\\\"
-    ;; This '# CONFIG_… is not set' syntax has to match exactly!
+    ;; This '# CONFIG_... is not set' syntax has to match exactly!
     \"# CONFIG_BOOT_CONFIG is not set\"
     \"CONFIG_NFS_SWAP=y\"
     ;; This is a multiline configuration:
@@ -1339,13 +1339,13 @@ (define*-public (modify-linux #:key name
                   #$(cond
                      ((not defconfig)
                       #~(begin
-                         ;; Call the original 'configure phase.
-                         (apply (assoc-ref #$phases 'configure) arguments)
-                         ;; Save a defconfig file.
-                         (invoke "make" "savedefconfig")
-                         ;; Move the saved defconfig to the proper location.
-                         (rename-file "defconfig"
-                                      guix_defconfig)))
+                          ;; Call the original 'configure phase.
+                          (apply (assoc-ref #$phases 'configure) arguments)
+                          ;; Save a defconfig file.
+                          (invoke "make" "savedefconfig")
+                          ;; Move the saved defconfig to the proper location.
+                          (rename-file "defconfig"
+                                       guix_defconfig)))
                      ((string? defconfig)
                       ;; Use another existing defconfig from the Linux sources.
                       #~(rename-file (string-append configs #$defconfig)
--8<---------------cut here---------------end--------------->8---

I'll push it shortly.

-- 
Thanks,
Maxim