From patchwork Thu Oct 19 14:53:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 55029 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 170EF27BBEA; Thu, 19 Oct 2023 15:55:02 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1CFE927BBE2 for ; Thu, 19 Oct 2023 15:55:00 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtUQ3-0002iQ-Qr; Thu, 19 Oct 2023 10:54:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtUQ2-0002cK-QO for guix-patches@gnu.org; Thu, 19 Oct 2023 10:54:38 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtUQ2-0007Lj-DQ; Thu, 19 Oct 2023 10:54:38 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qtUQR-0004HK-4W; Thu, 19 Oct 2023 10:55:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66640] [PATCH 2/2] profiles: Hooks honor the #:system parameter of =?utf-8?b?4oCYcHJvZmlsZS1kZXJpdmF0aW9u4oCZLg==?= Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Thu, 19 Oct 2023 14:55:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66640 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66640@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Tobias Geerinckx-Rice , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 66640-submit@debbugs.gnu.org id=B66640.169772725316347 (code B ref 66640); Thu, 19 Oct 2023 14:55:03 +0000 Received: (at 66640) by debbugs.gnu.org; 19 Oct 2023 14:54:13 +0000 Received: from localhost ([127.0.0.1]:37453 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtUPc-0004Fa-8j for submit@debbugs.gnu.org; Thu, 19 Oct 2023 10:54:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtUPX-0004F5-Kf for 66640@debbugs.gnu.org; Thu, 19 Oct 2023 10:54:08 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtUP0-00075q-T8; Thu, 19 Oct 2023 10:53:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=9KfJvbsoiaG4TYdKyU75yYPoiFHpTqtNao+QNaaTdXE=; b=UZQWOu9IqC564Ouwjkna VO1XrUtj7PYWJsws+meUE7eTlnu6/pybpx9TIwNNCrNDS9XtFfdcHsAXzsKCGA96PNtkVRKYFIwOV XBx/IXFs/vSltuyboX2C+aSD2lXtGnLU6/SADEKW2ontj7W2vwbAIZGT/fiXEiA3XAAwGjdsotDSR oaVtNKFmJ2mAQTqYJ2HddKVMc9rZvUwiYZMKv4fYAXauqFxVopo4kdZ9EsgwjFK8h0qk6Ki8hO62a Y/5B87Zl48CaBa2Enp/65YNDD5ZMCPxg9tz3vOAiK4SK0M1eDr1lLIcWkgUj/AB/oeLeA+RbDBh6x By2NZ2ECl8CsxA==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 19 Oct 2023 16:53:23 +0200 Message-ID: <3fd8e6298a7e74b516f0fbc5bc2d3de3d3e38330.1697726601.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Fixes . * guix/profiles.scm (info-dir-file, package-cache-file) (info-dir-file, ghc-package-cache-file, ca-certificate-bundle) (emacs-subdirs, gdk-pixbuf-loaders-cache-file, glib-schemas) (gtk-icon-themes, gtk-im-modules, linux-module-database) (xdg-desktop-database, xdg-mime-database, fonts-dir-file) (manual-database, manual-database/optional): Add optional #:system parameter and pass it to ‘gexp->derivation’. (profile-derivation): Pass HOOK a second parameter, SYSTEM. * gnu/bootloader.scm (efi-bootloader-profile)[efi-bootloader-profile-hook]: Add optional #:system parameter and pass it to ‘gexp->derivation’. * guix/channels.scm (package-cache-file): Likewise. * tests/profiles.scm ("profile-derivation, #:system, and hooks"): New test. Reported-by: Tobias Geerinckx-Rice --- gnu/bootloader.scm | 5 +++-- guix/channels.scm | 3 ++- guix/profiles.scm | 49 ++++++++++++++++++++++++++++++---------------- tests/profiles.scm | 24 ++++++++++++++++++++++- 4 files changed, 60 insertions(+), 21 deletions(-) diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 2c36d8c6cf..ba06de7618 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -2,7 +2,7 @@ ;;; Copyright © 2017 David Craven ;;; Copyright © 2017, 2020, 2022 Mathieu Othacehe ;;; Copyright © 2017 Leo Famulari -;;; Copyright © 2019, 2021 Ludovic Courtès +;;; Copyright © 2019, 2021, 2023 Ludovic Courtès ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2022 Josselin Poiret ;;; Copyright © 2022 Reza Alizadeh Majd @@ -335,7 +335,7 @@ (define (efi-bootloader-profile packages files hooks) local-file, etc., or package contents produced with file-append. HOOKS lists additional hook functions to modify the profile." - (define (efi-bootloader-profile-hook manifest) + (define* (efi-bootloader-profile-hook manifest #:optional system) (define build (with-imported-modules '((guix build utils)) #~(begin @@ -383,6 +383,7 @@ (define (efi-bootloader-profile packages files hooks) (gexp->derivation "efi-bootloader-profile" build + #:system system #:local-build? #t #:substitutable? #f #:properties diff --git a/guix/channels.scm b/guix/channels.scm index 681adafc6c..f01903642d 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -926,7 +926,7 @@ (define* (channel-instances->manifest instances #:key system) (entries -> (map instance->entry instances derivations))) (return (manifest entries)))) -(define (package-cache-file manifest) +(define* (package-cache-file manifest #:optional system) "Build a package cache file for the instance in MANIFEST. This is meant to be used as a profile hook." ;; Note: Emit a profile in format version 3, which was introduced in 2017 @@ -961,6 +961,7 @@ (define (package-cache-file manifest) (gexp->derivation-in-inferior "guix-package-cache" build profile + #:system system ;; If the Guix in PROFILE is too old and ;; lacks 'guix repl', don't build the cache diff --git a/guix/profiles.scm b/guix/profiles.scm index fea766879d..5d2fb8dc64 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -993,7 +993,7 @@ (define* (manifest-lookup-package manifest name #:optional version) (anym %store-monad entry-lookup-package (manifest-entries manifest))) -(define (info-dir-file manifest) +(define* (info-dir-file manifest #:optional system) "Return a derivation that builds the 'dir' file for all the entries of MANIFEST." (define texinfo ;lazy reference @@ -1051,13 +1051,14 @@ (define (info-dir-file manifest) '#$(manifest-inputs manifest))))))) (gexp->derivation "info-dir" build + #:system system #:local-build? #t #:substitutable? #f #:properties `((type . profile-hook) (hook . info-dir)))) -(define (ghc-package-cache-file manifest) +(define* (ghc-package-cache-file manifest #:optional system) "Return a derivation that builds the GHC 'package.cache' file for all the entries of MANIFEST, or #f if MANIFEST does not have any GHC packages." (define ghc ;lazy reference @@ -1108,6 +1109,7 @@ (define (ghc-package-cache-file manifest) (if (any (cut string-prefix? "ghc" <>) (map manifest-entry-name (manifest-entries manifest))) (gexp->derivation "ghc-package-cache" build + #:system system #:local-build? #t #:substitutable? #f #:properties @@ -1115,7 +1117,7 @@ (define (ghc-package-cache-file manifest) (hook . ghc-package-cache))) (return #f)))) -(define (ca-certificate-bundle manifest) +(define* (ca-certificate-bundle manifest #:optional system) "Return a derivation that builds a single-file bundle containing the CA certificates in the /etc/ssl/certs sub-directories of the packages in MANIFEST. Single-file bundles are required by programs such as Git and Lynx." @@ -1179,13 +1181,14 @@ (define (ca-certificate-bundle manifest) #t)))))) (gexp->derivation "ca-certificate-bundle" build + #:system system #:local-build? #t #:substitutable? #f #:properties `((type . profile-hook) (hook . ca-certificate-bundle)))) -(define (emacs-subdirs manifest) +(define* (emacs-subdirs manifest #:optional system) (define build (with-imported-modules (source-module-closure '((guix build profiles) @@ -1219,13 +1222,14 @@ (define (emacs-subdirs manifest) (newline port) #t))))))) (gexp->derivation "emacs-subdirs" build + #:system system #:local-build? #t #:substitutable? #f #:properties `((type . profile-hook) (hook . emacs-subdirs)))) -(define (gdk-pixbuf-loaders-cache-file manifest) +(define* (gdk-pixbuf-loaders-cache-file manifest #:optional system) "Return a derivation that produces a loaders cache file for every gdk-pixbuf loaders discovered in MANIFEST." (define gdk-pixbuf ;lazy reference @@ -1264,6 +1268,7 @@ (define (gdk-pixbuf-loaders-cache-file manifest) (if gdk-pixbuf (gexp->derivation "gdk-pixbuf-loaders-cache-file" build + #:system system #:local-build? #t #:substitutable? #f #:properties @@ -1271,7 +1276,7 @@ (define (gdk-pixbuf-loaders-cache-file manifest) (hook . gdk-pixbuf-loaders-cache-file))) (return #f)))) -(define (glib-schemas manifest) +(define* (glib-schemas manifest #:optional system) "Return a derivation that unions all schemas from manifest entries and creates the Glib 'gschemas.compiled' file." (define glib ; lazy reference @@ -1318,6 +1323,7 @@ (define (glib-schemas manifest) ;; Don't run the hook when there's nothing to do. (if %glib (gexp->derivation "glib-schemas" build + #:system system #:local-build? #t #:substitutable? #f #:properties @@ -1325,7 +1331,7 @@ (define (glib-schemas manifest) (hook . glib-schemas))) (return #f)))) -(define (gtk-icon-themes manifest) +(define* (gtk-icon-themes manifest #:optional system) "Return a derivation that unions all icon themes from manifest entries and creates the GTK+ 'icon-theme.cache' file for each theme." (define gtk+ ; lazy reference @@ -1377,6 +1383,7 @@ (define (gtk-icon-themes manifest) ;; Don't run the hook when there's nothing to do. (if %gtk+ (gexp->derivation "gtk-icon-themes" build + #:system system #:local-build? #t #:substitutable? #f #:properties @@ -1384,7 +1391,7 @@ (define (gtk-icon-themes manifest) (hook . gtk-icon-themes))) (return #f)))) -(define (gtk-im-modules manifest) +(define* (gtk-im-modules manifest #:optional system) "Return a derivation that builds the cache files for input method modules for both major versions of GTK+." @@ -1454,6 +1461,7 @@ (define (gtk-im-modules manifest) #t)))) (if (or gtk+ gtk+-2) (gexp->derivation "gtk-im-modules" gexp + #:system system #:local-build? #t #:substitutable? #f #:properties @@ -1461,7 +1469,7 @@ (define (gtk-im-modules manifest) (hook . gtk-im-modules))) (return #f))))) -(define (linux-module-database manifest) +(define* (linux-module-database manifest #:optional system) "Return a derivation that unites all the kernel modules of the manifest and creates the dependency graph of all these kernel modules. @@ -1511,13 +1519,14 @@ (define (linux-module-database manifest) (_ (error "Specified Linux kernel and Linux kernel modules are not all of the same version")))))))) (gexp->derivation "linux-module-database" build + #:system system #:local-build? #t #:substitutable? #f #:properties `((type . profile-hook) (hook . linux-module-database)))) -(define (xdg-desktop-database manifest) +(define* (xdg-desktop-database manifest #:optional system) "Return a derivation that builds the @file{mimeinfo.cache} database from desktop files. It's used to query what applications can handle a given MIME type." @@ -1551,6 +1560,7 @@ (define (xdg-desktop-database manifest) ;; Don't run the hook when 'glib' is not referenced. (if glib (gexp->derivation "xdg-desktop-database" build + #:system system #:local-build? #t #:substitutable? #f #:properties @@ -1558,7 +1568,7 @@ (define (xdg-desktop-database manifest) (hook . xdg-desktop-database))) (return #f)))) -(define (xdg-mime-database manifest) +(define* (xdg-mime-database manifest #:optional system) "Return a derivation that builds the @file{mime.cache} database from manifest entries. It's used to query the MIME type of a given file." (define shared-mime-info ; lazy reference @@ -1605,6 +1615,7 @@ (define (xdg-mime-database manifest) ;; Don't run the hook when there are no GLib based applications. (if glib (gexp->derivation "xdg-mime-database" build + #:system system #:local-build? #t #:substitutable? #f #:properties @@ -1615,7 +1626,7 @@ (define (xdg-mime-database manifest) ;; Several font packages may install font files into same directory, so ;; fonts.dir and fonts.scale file should be generated here, instead of in ;; packages. -(define (fonts-dir-file manifest) +(define* (fonts-dir-file manifest #:optional system) "Return a derivation that builds the @file{fonts.dir} and @file{fonts.scale} files for the fonts of the @var{manifest} entries." (define mkfontscale @@ -1676,6 +1687,7 @@ (define (fonts-dir-file manifest) directories))))))) (gexp->derivation "fonts-dir" build + #:system system #:modules '((guix build utils) (guix build union) (srfi srfi-26)) @@ -1685,7 +1697,7 @@ (define (fonts-dir-file manifest) `((type . profile-hook) (hook . fonts-dir)))) -(define (manual-database manifest) +(define* (manual-database manifest #:optional system) "Return a derivation that builds the manual page database (\"mandb\") for the entries in MANIFEST." (define gdbm-ffi @@ -1761,23 +1773,24 @@ (define (manual-database manifest) (force-output)))))) (gexp->derivation "manual-database" build + #:system system #:substitutable? #f #:local-build? #t #:properties `((type . profile-hook) (hook . manual-database)))) -(define (manual-database/optional manifest) +(define* (manual-database/optional manifest #:optional system) "Return a derivation to build the manual database of MANIFEST, but only if MANIFEST contains the \"man-db\" package. Otherwise, return #f." ;; Building the man database (for "man -k") is expensive and rarely used. ;; Build it only if the profile also contains "man-db". (mlet %store-monad ((man-db (manifest-lookup-package manifest "man-db"))) (if man-db - (manual-database manifest) + (manual-database manifest system) (return #f)))) -(define (texlive-font-maps manifest) +(define* (texlive-font-maps manifest #:optional system) "Return a derivation that builds the TeX Live font maps for the entries in MANIFEST." (define entry->texlive-input @@ -1898,6 +1911,7 @@ (define (texlive-font-maps manifest) ;; incomplete modular TeX Live installations to generate errors. (if (any texlive-scripts-entry? (manifest-entries manifest)) (gexp->derivation "texlive-font-maps" build + #:system system #:substitutable? #f #:local-build? #t #:properties @@ -1977,7 +1991,8 @@ (define* (profile-derivation manifest (extras (if (null? (manifest-entries manifest)) (return '()) (mapm/accumulate-builds (lambda (hook) - (hook manifest)) + (hook manifest + system)) hooks)))) (define extra-inputs (filter-map (lambda (drv) diff --git a/tests/profiles.scm b/tests/profiles.scm index 9ad03f2b24..9c419ada93 100644 --- a/tests/profiles.scm +++ b/tests/profiles.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013-2022 Ludovic Courtès +;;; Copyright © 2013-2023 Ludovic Courtès ;;; Copyright © 2014 Alex Kost ;;; ;;; This file is part of GNU Guix. @@ -382,6 +382,28 @@ (define glibc (_ (built-derivations (list drv)))) (return (file-exists? (string-append bindir "/guile"))))) +(test-assertm "profile-derivation, #:system, and hooks" + ;; Make sure all the profile hooks are built for the system specified with + ;; #:system, even if that does not match (%current-system). + ;; See . + (mlet* %store-monad + ((system -> (if (string=? (%current-system) "riscv64-linux") + "x86_64-linux" + "riscv64-linux")) + (entry -> (package->manifest-entry packages:coreutils)) + (_ (set-guile-for-build (default-guile) system)) + (drv (profile-derivation (manifest (list entry)) + #:system system)) + (refs (references* (derivation-file-name drv)))) + (return (and (string=? (derivation-system drv) system) + (pair? refs) + (every (lambda (ref) + (or (not (string-suffix? ".drv" ref)) + (let ((drv (read-derivation-from-file ref))) + (string=? (derivation-system drv) + system)))) + refs))))) + (test-assertm "profile-derivation relative symlinks, one entry" (mlet* %store-monad ((entry -> (package->manifest-entry %bootstrap-guile))