all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tomas Volf <~@wolfsden.cz>
To: Felix Lechner <felix.lechner@lease-up.com>
Cc: guix-devel@gnu.org
Subject: Re: Module unavailable on build side
Date: Sun, 14 Jan 2024 13:55:03 +0100	[thread overview]
Message-ID: <ZaPZp-5MhLZlwDDo@ws> (raw)
In-Reply-To: <87cyu44kp5.fsf@lease-up.com>

[-- Attachment #1: Type: text/plain, Size: 2298 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-01-14 12:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-14  4:12 Module unavailable on build side Felix Lechner via Development of GNU Guix and the GNU System distribution.
2024-01-14 12:55 ` Tomas Volf [this message]
2024-01-15  0:20   ` Attila Lendvai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZaPZp-5MhLZlwDDo@ws \
    --to=~@wolfsden.cz \
    --cc=felix.lechner@lease-up.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.