diff options
| author | Hilton Chain <hako@ultrarare.space> | 2025-05-13 19:19:38 +0800 |
|---|---|---|
| committer | Hilton Chain <hako@ultrarare.space> | 2025-05-15 21:22:42 +0800 |
| commit | f9fedea132fc146c0ad692deb1f3d840acc4a967 (patch) | |
| tree | 293cdec95580b0b36300771ad86e5b22ac6fdd9b | |
| parent | 38d420fa5ae4b69e8ef118ffffba50a68d3d9893 (diff) | |
nongnu: corrupt-linux: Apply Nonguix configs in a separate build phase.
* nongnu/packages/linux.scm (corrupt-linux)[arguments]<#:phases>: Add
‘nonguix-configure’.
Fixes: https://gitlab.com/nonguix/nonguix/-/issues/392
| -rw-r--r-- | nongnu/packages/linux.scm | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/nongnu/packages/linux.scm b/nongnu/packages/linux.scm index cc80770..4390e68 100644 --- a/nongnu/packages/linux.scm +++ b/nongnu/packages/linux.scm | |||
| @@ -52,17 +52,21 @@ | |||
| 52 | #:use-module (srfi srfi-1) | 52 | #:use-module (srfi srfi-1) |
| 53 | #:export (corrupt-linux)) | 53 | #:export (corrupt-linux)) |
| 54 | 54 | ||
| 55 | ;; To customize the kernel with extra defconfig, use: | ||
| 56 | ;; (customize-linux #:linux linux | ||
| 57 | ;; #:configs | ||
| 58 | ;; '("CONFIG_A=y" | ||
| 59 | ;; "CONFIG_B=m" | ||
| 60 | ;; "# CONFIG_C is not set")) | ||
| 61 | ;; See also the Guix Cookbook entry (search ‘customize-linux’): | ||
| 62 | ;; https://guix.gnu.org/cookbook/en/html_node/Customizing-the-Kernel.html | ||
| 63 | |||
| 55 | (define (linux-url version) | 64 | (define (linux-url version) |
| 56 | "Return a URL for Linux VERSION." | 65 | "Return a URL for Linux VERSION." |
| 57 | (string-append "mirror://kernel.org" | 66 | (string-append "mirror://kernel.org" |
| 58 | "/linux/kernel/v" (version-major version) ".x" | 67 | "/linux/kernel/v" (version-major version) ".x" |
| 59 | "/linux-" version ".tar.xz")) | 68 | "/linux-" version ".tar.xz")) |
| 60 | 69 | ||
| 61 | ;;; If you are corrupting the kernel on your own, consider using output of | ||
| 62 | ;;; this procedure as a base for your options: | ||
| 63 | ;;; (corrupt-linux linux-libre-lts | ||
| 64 | ;;; #:configs (cons* "CONFIG_FOO=y" | ||
| 65 | ;;; (nonguix-extra-linux-options linux-libre-lts) | ||
| 66 | (define-public (nonguix-extra-linux-options linux-or-version) | 70 | (define-public (nonguix-extra-linux-options linux-or-version) |
| 67 | "Return a list containing additional options that nonguix sets by default | 71 | "Return a list containing additional options that nonguix sets by default |
| 68 | for a corrupted linux package of specified version. linux-or-version can be | 72 | for a corrupted linux package of specified version. linux-or-version can be |
| @@ -93,13 +97,17 @@ some freedo package or an output of package-version procedure." | |||
| 93 | (define* (corrupt-linux freedo | 97 | (define* (corrupt-linux freedo |
| 94 | #:key | 98 | #:key |
| 95 | (name "linux") | 99 | (name "linux") |
| 96 | (configs (nonguix-extra-linux-options freedo)) | 100 | (configs "") |
| 97 | (defconfig #f)) | 101 | (defconfig #f) |
| 102 | (get-extra-configs nonguix-extra-linux-options)) | ||
| 98 | 103 | ||
| 99 | ;; TODO: This very directly depends on guix internals. | 104 | ;; TODO: This very directly depends on guix internals. |
| 100 | ;; Throw it all out when we manage kernel hashes. | 105 | ;; Throw it all out when we manage kernel hashes. |
| 101 | (define gexp-inputs (@@ (guix gexp) gexp-inputs)) | 106 | (define gexp-inputs (@@ (guix gexp) gexp-inputs)) |
| 102 | 107 | ||
| 108 | (define linux-srcarch | ||
| 109 | (@@ (gnu packages linux) linux-srcarch)) | ||
| 110 | |||
| 103 | (define extract-gexp-inputs | 111 | (define extract-gexp-inputs |
| 104 | (compose gexp-inputs force origin-uri)) | 112 | (compose gexp-inputs force origin-uri)) |
| 105 | 113 | ||
| @@ -117,19 +125,37 @@ some freedo package or an output of package-version procedure." | |||
| 117 | (pristine-source (package-source freedo)) | 125 | (pristine-source (package-source freedo)) |
| 118 | (inputs (map gexp-input-thing (extract-gexp-inputs pristine-source))) | 126 | (inputs (map gexp-input-thing (extract-gexp-inputs pristine-source))) |
| 119 | (sources (filter origin? inputs)) | 127 | (sources (filter origin? inputs)) |
| 120 | (hash (find-source-hash sources url))) | 128 | (hash (find-source-hash sources url)) |
| 129 | (base (customize-linux | ||
| 130 | #:name name | ||
| 131 | #:linux freedo | ||
| 132 | #:source (origin | ||
| 133 | (method url-fetch) | ||
| 134 | (uri url) | ||
| 135 | (hash hash)) | ||
| 136 | #:configs configs | ||
| 137 | #:defconfig defconfig))) | ||
| 121 | (package | 138 | (package |
| 122 | (inherit | 139 | (inherit base) |
| 123 | (customize-linux | ||
| 124 | #:name name | ||
| 125 | #:linux freedo | ||
| 126 | #:source (origin | ||
| 127 | (method url-fetch) | ||
| 128 | (uri url) | ||
| 129 | (hash hash)) | ||
| 130 | #:configs configs | ||
| 131 | #:defconfig defconfig)) | ||
| 132 | (version version) | 140 | (version version) |
| 141 | (arguments | ||
| 142 | (substitute-keyword-arguments (package-arguments base) | ||
| 143 | ((#:phases phases) | ||
| 144 | #~(modify-phases #$phases | ||
| 145 | ;; Make sure the resulted package is compatible with | ||
| 146 | ;; ‘customize-linux’. | ||
| 147 | (add-before 'configure 'nonguix-configure | ||
| 148 | (lambda _ | ||
| 149 | (unless #$defconfig | ||
| 150 | (let ((guix_defconfig | ||
| 151 | (format #f "arch/~a/configs/guix_defconfig" | ||
| 152 | #$(linux-srcarch)))) | ||
| 153 | (invoke "make" "defconfig") | ||
| 154 | (modify-defconfig | ||
| 155 | ".config" | ||
| 156 | '#$(get-extra-configs (package-version this-package))) | ||
| 157 | (invoke "make" "savedefconfig") | ||
| 158 | (rename-file "defconfig" guix_defconfig))))))))) | ||
| 133 | (home-page "https://www.kernel.org/") | 159 | (home-page "https://www.kernel.org/") |
| 134 | (synopsis "Linux kernel with nonfree binary blobs included") | 160 | (synopsis "Linux kernel with nonfree binary blobs included") |
| 135 | (description | 161 | (description |
