From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:35208) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3jvD-00068A-Iu for guix-patches@gnu.org; Mon, 17 Feb 2020 12:11:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3jvC-0001I2-9l for guix-patches@gnu.org; Mon, 17 Feb 2020 12:11:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33165) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3jvC-0001Hx-6G for guix-patches@gnu.org; Mon, 17 Feb 2020 12:11:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j3jvC-0007gw-2d for guix-patches@gnu.org; Mon, 17 Feb 2020 12:11:02 -0500 Subject: [bug#37868] [PATCH] guix: Allow multiple packages to provide Linux modules in the system profile. Resent-Message-ID: Date: Mon, 17 Feb 2020 18:10:45 +0100 From: Danny Milosavljevic Message-ID: <20200217181045.7d41f231@scratchpost.org> In-Reply-To: <87a78zq4xb.fsf@gnu.org> References: <20191022152238.12856-1-dannym@scratchpost.org> <20191112172048.61ba69eb@scratchpost.org> <87a78zq4xb.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/.R9wu+HpELz9kIF08Atvk+i"; protocol="application/pgp-signature"; micalg=pgp-sha256 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Mark H Weaver , 37868@debbugs.gnu.org --Sig_/.R9wu+HpELz9kIF08Atvk+i Content-Type: multipart/mixed; boundary="MP_/2=U6mP85rb71MR6_coVFDnO" --MP_/2=U6mP85rb71MR6_coVFDnO Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Ludo, should the following work (patch to guix master attached)? Because I get=20 guix system: error: #: invalid G-expression input on ./pre-inst-env guix system vm /etc/config.scm --MP_/2=U6mP85rb71MR6_coVFDnO Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=a.patch diff --git a/gnu/system.scm b/gnu/system.scm index 01baa248a2..9874861041 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -164,6 +164,8 @@ =20 (kernel operating-system-kernel ; package (default linux-libre)) + (kernel-module-packages operating-system-kernel-module-packages + (default '())) ; list of packages (kernel-arguments operating-system-user-kernel-arguments (default '("quiet"))) ; list of gexps/strings (bootloader operating-system-bootloader) ; @@ -469,9 +471,18 @@ OS." value of the SYSTEM-SERVICE-TYPE service." (let ((locale (operating-system-locale-directory os))) (mlet %store-monad ((kernel -> (operating-system-kernel os)) + (kernel-module-packages -> + (operating-system-kernel-module-packages os)) (initrd -> (operating-system-initrd-file os)) (params (operating-system-boot-parameters-file = os))) (return `(("kernel" ,kernel) + ("kernel-modules" + ,(profile-derivation + (packages->manifest (cons kernel kernel-module-packages= )) + ; TODO: system, target. + #:hooks (list linux-module-database) + #:system #f + #:target #f)) ("parameters" ,params) ("initrd" ,initrd) ("locale" ,locale)))))) ;used by libc diff --git a/guix/profiles.scm b/guix/profiles.scm index 0d38b2513f..ecc0d3ae5a 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -9,6 +9,7 @@ ;;; Copyright =C2=A9 2017 Huang Ying ;;; Copyright =C2=A9 2017 Maxim Cournoyer ;;; Copyright =C2=A9 2019 Kyle Meyer +;;; Copyright =C2=A9 2019 Danny Milosavljevic ;;; Copyright =C2=A9 2019 Mathieu Othacehe ;;; ;;; This file is part of GNU Guix. @@ -139,7 +140,9 @@ %current-profile ensure-profile-directory canonicalize-profile - user-friendly-profile)) + user-friendly-profile + + linux-module-database)) =20 ;;; Commentary: ;;; @@ -1137,6 +1140,77 @@ for both major versions of GTK+." (hook . gtk-im-modules))) (return #f))))) =20 +(define (linux-module-database manifest) + (mlet %store-monad + ((kmod (manifest-lookup-package manifest "kmod"))) + (define build + (with-imported-modules '((guix build utils) + (guix build union)) + #~(begin + (use-modules (srfi srfi-1) + (srfi srfi-26) + (guix build utils) + (guix build union) + (ice-9 ftw) + (ice-9 match)) + (let* ((inputs '#$(manifest-inputs manifest)) + (input-files (lambda (path) + (filter file-exists? + (map (cut string-append <> path) inputs)= ))) + (module-directories (input-files "/lib/modules")) + (System.maps (input-files "/System.map")) + (Module.symverss (input-files "/Module.symvers")) + (directory-entries (lambda (directory-name) + (filter (lambda (basename) + (not (string-prefix? "." + base= name))) + (scandir directory-name)))) + ;; Note: Should result in one entry. + (versions (append-map directory-entries module-directorie= s))) + ;; TODO: if len(module-directories) =3D=3D 1: return module-= directories[0] + (mkdir-p (string-append #$output "/lib/modules")) + ;; Iterate over each kernel version directory (usually one). + (for-each (lambda (version) + (let ((destination-directory (string-append #$ou= tput "/lib/modules/" version))) + (when (not (file-exists? destination-directory= )) ; unique + (union-build destination-directory + ;; All directories with the sam= e version as us. + (filter-map (lambda (directory-= name) + (if (member versi= on + (dire= ctory-entries directory-name)) + (string-appen= d directory-name "/" version) + #f)) + module-directories) + #:create-all-directories? #t) + ;; Delete generated files (they will be recr= eated shortly). + (for-each (lambda (basename) + (when (string-prefix? "modules."= basename) + (false-if-file-not-found + (delete-file + (string-append + destination-directory "/" + basename))))) + (directory-entries destination-dir= ectory)) + (unless (zero? (system* (string-append #$kmo= d "/bin/depmod") + "-e" ; Report symbol= s that aren't supplied + "-w" ; Warn on dupli= cates + "-b" #$output ; dest= ination-directory + "-F" (match System.m= aps + ((x) x)) + "-E" (match Module.s= ymverss + ((x) x)) + version)) + (display "FAILED\n" (current-error-port)) + (exit #f))))) + versions) + (exit #t))))) + (gexp->derivation "linux-module-database" build + #:local-build? #t + #:substitutable? #f + #:properties + `((type . profile-hook) + (hook . linux-module-database))))) + (define (xdg-desktop-database manifest) "Return a derivation that builds the @file{mimeinfo.cache} database from desktop files. It's used to query what applications can handle a given --MP_/2=U6mP85rb71MR6_coVFDnO-- --Sig_/.R9wu+HpELz9kIF08Atvk+i Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl5KyRUACgkQ5xo1VCww uqVEFQf9GFlM7I4B9PGp5AmjpX/P1NtogHcDqRO4Hx457+CAeeJoKj7nLgbIJi8U 2ztELh8Q8AU42Lz6fr5gJd0waswegVGMLd4ohcN9MOKtwtTzu3RoOidkPv1rJkj3 CuOV+Lis3FCVMUR0COVadqbr0wfR/KYLFW5ISR9WnJOeJ/c85/Wuf59upxtk2V72 mcNHKZjMDsgIvRflZC/jd6jf0SqEMHGUJRLQTRiGEtAiJ68w3RGLOEpNGWZv+jQm C+Vmpnl8WNt7rqKWDRiDFhXx3w2mQP7OncsevUT2JZ2eCSPBxM6n2E5DbvmejGSu qlIhUBA6jTeq2h8hr30hYTqv5dsGKg== =UdIf -----END PGP SIGNATURE----- --Sig_/.R9wu+HpELz9kIF08Atvk+i--