diff mbox series

[bug#60826,gnome-team,v3,2/5] build: gnu: Export a %gnu-default-modules variable.

Message ID 788ffede0cb9cdab9d7b7573de321dfd554caa0b.1687212109.git.mirai@makinata.eu
State New
Headers show
Series [bug#60826,staging] gnu: shared-mime-info: Update to 2.2. | expand

Commit Message

Bruno Victal June 19, 2023, 10:07 p.m. UTC
This makes tweaking the #:module argument less reliant on the programmers
astral wisdom to divine the right module imports.

* guix/build-system/gnu.scm (%default-modules): Rename to …
(%gnu-default-modules): … this and export it as well.
---
 guix/build-system/gnu.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Liliana Marie Prikler June 20, 2023, 4:18 a.m. UTC | #1
Am Montag, dem 19.06.2023 um 23:07 +0100 schrieb Bruno Victal:
> This makes tweaking the #:module argument less reliant on the
> programmers astral wisdom to divine the right module imports.
> 
> * guix/build-system/gnu.scm (%default-modules): Rename to …
> (%gnu-default-modules): … this and export it as well.
> ---
Uhm, is this required?  I see it used in xdgmime, but I'd very much
like to do without it.

Cheers
Bruno Victal June 20, 2023, 6:59 a.m. UTC | #2
Hi Liliana,

On 2023-06-20 05:18, Liliana Marie Prikler wrote:
> Am Montag, dem 19.06.2023 um 23:07 +0100 schrieb Bruno Victal:
>> This makes tweaking the #:module argument less reliant on the
>> programmers astral wisdom to divine the right module imports.
>>
>> * guix/build-system/gnu.scm (%default-modules): Rename to …
>> (%gnu-default-modules): … this and export it as well.
>> ---
> Uhm, is this required?  I see it used in xdgmime, but I'd very much
> like to do without it.

As indicated in the commit message, its purpose is to make things
easier. (I've taken inspiration from elm-build-system here)

I think the most compelling arguments to this approach is that in
some packages you see things like:

--8<---------------cut here---------------start------------->8---
gnu/packages/boost.scm-     (list
gnu/packages/boost.scm:      #:imported-modules `((guix build python-build-system)
gnu/packages/boost.scm-                           ,@%gnu-build-system-modules)
gnu/packages/boost.scm:      #:modules `(((guix build python-build-system) #:select (python-version))
gnu/packages/boost.scm-                  ,@%gnu-build-system-modules)
gnu/packages/boost.scm-      #:tests? #f
gnu/packages/boost.scm-      #:configure-flags
--8<---------------cut here---------------end--------------->8---

Which is most likely a mistake since the actual #:module should
be about %default-modules which is a subset of %gnu-build-system-modules.
(albeit one with seemingly little impact)

The divination comment stems from the following reasoning:
“How can I know what gnu-build-system actually imports if not by
guessing/cargo-culting or peering at the private %default-modules?“
(at that point, why not export it as well?)

I'd argue it's a nice addition though strictly speaking its not fundamental
for this patch-series and can be left out, by manually expanding the
%gnu-default-modules value in the xdgmime arguments.
Liliana Marie Prikler June 20, 2023, 4:56 p.m. UTC | #3
Am Dienstag, dem 20.06.2023 um 07:59 +0100 schrieb Bruno Victal:
> The divination comment stems from the following reasoning:
> “How can I know what gnu-build-system actually imports if not by
> guessing/cargo-culting or peering at the private %default-modules?“
> (at that point, why not export it as well?)
> 
> I'd argue it's a nice addition though strictly speaking its not
> fundamental for this patch-series and can be left out, by manually
> expanding the %gnu-default-modules value in the xdgmime arguments.
The point is you shouldn't need to "divine" anything.  It doesn't take
much guesswork to find that the things you need for gnu-build-system
belong to either (guix build gnu-build-system) or (guix build utils) –
the latter being a module you ought to already be familiar with when
mixing phases, the former being named after the build system.  
%elm-default-modules OTOH requires four modules which aren't obvious to
the uninitiated or even slightly more initiated Guix hacker.

Cheers
diff mbox series

Patch

diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm
index 3308302472..448a2b2a44 100644
--- a/guix/build-system/gnu.scm
+++ b/guix/build-system/gnu.scm
@@ -28,6 +28,7 @@  (define-module (guix build-system gnu)
   #:use-module (srfi srfi-1)
   #:use-module (ice-9 match)
   #:export (%gnu-build-system-modules
+            %gnu-default-modules
             %strip-flags
             %strip-directories
             gnu-build
@@ -55,7 +56,7 @@  (define %gnu-build-system-modules
     (guix build gremlin)
     (guix elf)))
 
-(define %default-modules
+(define %gnu-default-modules
   ;; Modules in scope in the build-side environment.
   '((guix build gnu-build-system)
     (guix build utils)))
@@ -237,7 +238,7 @@  (define* (dist-package p source #:key (phases '%dist-phases))
       (arguments
        ;; Use the right phases and modules.
        (substitute-keyword-arguments (package-arguments p)
-         ((#:modules modules %default-modules)
+         ((#:modules modules %gnu-default-modules)
           `((guix build gnu-dist)
             ,@modules))
          ((#:imported-modules modules %gnu-build-system-modules)
@@ -360,7 +361,7 @@  (define* (gnu-build name inputs
                     (system (%current-system))
                     (build (nix-system->gnu-triplet system))
                     (imported-modules %gnu-build-system-modules)
-                    (modules %default-modules)
+                    (modules %gnu-default-modules)
                     (substitutable? #t)
                     allowed-references
                     disallowed-references)
@@ -500,7 +501,7 @@  (define* (gnu-cross-build name
                           (system (%current-system))
                           (build (nix-system->gnu-triplet system))
                           (imported-modules %gnu-build-system-modules)
-                          (modules %default-modules)
+                          (modules %gnu-default-modules)
                           (substitutable? #t)
                           allowed-references
                           disallowed-references)