From mboxrd@z Thu Jan 1 00:00:00 1970 From: Danny Milosavljevic Subject: Re: Loading modules built using linux-module-build-system Date: Mon, 21 Oct 2019 23:39:25 +0200 Message-ID: <20191021233925.0ba18a4c@scratchpost.org> References: <877e8snntp.fsf@jlicht.xyz> <20191021202733.3c340770@scratchpost.org> <20191021204857.5dff6e9b@scratchpost.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/0+Rc+CcPFIp9kGOuPoU4JnW"; protocol="application/pgp-signature"; micalg=pgp-sha256 Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:46767) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMfOn-00058G-UC for guix-devel@gnu.org; Mon, 21 Oct 2019 17:39:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMfOm-0003Km-Gf for guix-devel@gnu.org; Mon, 21 Oct 2019 17:39:33 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:46776) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iMfOm-0003KQ-6Q for guix-devel@gnu.org; Mon, 21 Oct 2019 17:39:32 -0400 In-Reply-To: <20191021204857.5dff6e9b@scratchpost.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Jelle Licht Cc: guix-devel@gnu.org --Sig_/0+Rc+CcPFIp9kGOuPoU4JnW Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable A patch to guix master which * Puts the kernel modules (including any other packages that have "lib/modu= les" inside their derivation) into /run/booted-system/profile/lib/modules * Ensures that depmod is invoked on that * Makes the modprobe wrapper use it is provided below. The case when there's only one package in the system profile (the package i= s the kernel) could still be optimized: Then, depmod doesn't need to run (it already ran when building the kernel i= n the first place). Probably, the profile hook will fail in some cases because modules.dep alre= ady exists in the source. The patch still needs to be adapted for that. Also, tests need to be added (system test in vm). Help wanted :) (Right now I didn't test it because "guix system reconfigure" fails when building qemu-4.1.0 three times in a row (for now), wasting many hours) Also, long term, it might make sense to use something else instead of profile-service-type (something like a new linux-module-service-type). diff --git a/gnu/services.scm b/gnu/services.scm index 6ee05d4580..d2977c2012 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -491,7 +491,11 @@ ACTIVATION-SCRIPT-TYPE." (program-file "modprobe" #~(begin (setenv "LINUX_MODULE_DIRECTORY" - "/run/booted-system/kernel/lib/modules") + (if (file-exists? "/run/booted-system/profil= e/lib/modules") + "/run/booted-system/profile/lib/modules" + ;; Provides compatibility with previous + ;; Guix generations. + "/run/booted-system/kernel/lib/modules")) (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))) =20 diff --git a/gnu/system.scm b/gnu/system.scm index a353b1a5c8..2dfbb9e73f 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -887,9 +887,11 @@ we're running in the final root." (define* (operating-system-profile os) "Return a derivation that builds the system profile of OS." (mlet* %store-monad - ((services -> (operating-system-services os)) - (profile (fold-services services - #:target-type profile-service-type))) + ((kernel -> (operating-system-kernel os)) + (services -> (operating-system-services os)) + (profile (cons kernel (fold-services services + #:target-type + profile-service-type)))) (match profile (("profile" profile) (return profile))))) diff --git a/guix/profiles.scm b/guix/profiles.scm index cd3b21e390..13b5bf1a85 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 ;;; ;;; This file is part of GNU Guix. ;;; @@ -1125,6 +1126,43 @@ 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-26) + (guix build utils) + (guix build union) + (ice-9 match)) + (let ((destdir (string-append #$output "/lib/modules")) + (dirs (filter file-exists? + (map (cut string-append <> + "/lib/modules") + '#$(manifest-inputs manifest)))) + (System.maps (filter file-exists? + (map (cut string-append <> "/System.map") + '#$(manifest-inputs manifest)))) + (Module.symvers (filter file-exists? + (map (cut string-append <> "/Module.symvers") + '#$(manifest-inputs manifest))))) + (mkdir-p (string-append #$output "/lib")) + (union-build destdir dirs #:create-all-directories? #t) + (exit (zero? (system* (string-append #$kmod "/bin/depmod") + "-e" ; Report symbols that aren't supplied + "-w" ; Warn on duplicates + "-b" destdir + "-F" (match System.maps ((x) x)) + "-E" (match Module.symvers ((x) x))))))))) + (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 @@ -1425,7 +1463,8 @@ MANIFEST." gtk-im-modules texlive-configuration xdg-desktop-database - xdg-mime-database)) + xdg-mime-database + linux-module-database)) =20 (define* (profile-derivation manifest #:key --Sig_/0+Rc+CcPFIp9kGOuPoU4JnW Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl2uJY0ACgkQ5xo1VCww uqWgogf5ATA0oUtdXvwcAOGUS3vQZUMaxBW95SO610qXgA1b+swnkQD7uSe3IEjK etd8dZ4oO/r8biSzA/eD7ttXdFPLDDzePnByP6K5gjca65qshIGK9VB6Was4m6MH Mncbdl1GUIG65niAz3DGBc4zuwvzU6gXGePbSq39ulHq+WWtRtXaH6aO67Ke6lYW dOexcmr4utFKe1rshO/Qrw1hUtGyyKKyGYQAo+e4D/yC/68/SHXs50/8sYLPBDOK 0xotBbN2GE4BGa0zsIiMkHIezMP9GuqHbd8bTPKgMTpg6FStoaeCr5IQ393OleC1 0Gu5I7Cu9uDvSceIYze6eHk+eCAs1Q== =YQnI -----END PGP SIGNATURE----- --Sig_/0+Rc+CcPFIp9kGOuPoU4JnW--