guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Module unavailable on build side


From: Tomas Volf
Subject: Re: Module unavailable on build side
Date: Sun, 14 Jan 2024 13:55:03 +0100

Hi,

On 2024-01-13 20:12:38 -0800, Felix Lechner via Development of GNU Guix and the 
GNU System distribution. wrote:
> Hi,
> 
> How may I make code from a channel available inside 'modify-phases',
> please?
> 
> I tried #:modules, but it says "no code for (x y z)." Thanks!

Based on some quick experimentation `source-module-closure' seems to be the way.
Package definition importing a (nonguix licenses) module follows:

(use-modules (guix build-system gnu)
             (guix gexp)
             (guix modules)
             (guix packages)
             (nongnu packages linux))

    (package
      (name "test")
      (version "1")
      (source #f)
      (build-system gnu-build-system)
      (arguments
       (list #:imported-modules
             (source-module-closure `((nonguix licenses)
                                      ,@%gnu-build-system-modules)
                                    #:select? (λ (m)
                                                (or (guix-module-name? m)
                                                    (eq? (car m) 'nonguix))))
             #:phases
             #~(modify-phases %standard-phases
                 (add-before 'unpack 'foo
                   (λ _
                     (use-modules (nonguix licenses))
                     (error nonfree))))))
      (home-page #f)
      (synopsis #f)
      (description #f)
      (license #f))

This does "build" resulting in the expected error:

    ice-9/boot-9.scm:1685:16: In procedure raise-exception:
    #<procedure nonfree (uri #:optional comment)>

However it took me a while to find a module that actually works.  Due to the web
of dependencies, it can get complex quickly and you would need to properly
manage the #:select? value.  Just putting (const #t) in there sadly does not
work.

Not sure, maybe there is a better way.  If there is, I hope someone will tell me
(us).

In the mean time, I hope this helps to some degree.

Have a nice day,
Tomas Volf

PS: My understanding it that #:modules is equivalent to (use-modules), that is
    why I used #:imported-modules to add them into the build environment first.

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]