guix-devel
[Top][All Lists]
Advanced

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

Re: (guix modules) and ‘source-module-closure’


From: Ricardo Wurmus
Subject: Re: (guix modules) and ‘source-module-closure’
Date: Mon, 5 Sep 2016 10:13:27 +0200
User-agent: mu4e 0.9.16; emacs 24.5.1

Ludovic Courtès <address@hidden> writes:

> Hi!
>
> Commit 7ca87354db53fd1e1a7a3dfeddb9a598ea064bbe adds (guix module),
> which provides a way to compute the closure of a Scheme module by
> looking at its source code.
>
> This has to do with typical ‘with-imported-modules’ usage, as explained
> in the manual:
>
> --8<---------------cut here---------------start------------->8---
>    Usually you want the _closure_ of the module to be imported—i.e., the
> module itself and all the modules it depends on—rather than just the
> module; failing to do that, attempts to use the module will fail because
> of missing dependent modules.  The ‘source-module-closure’ procedure
> computes the closure of a module by looking at its source file headers,
> which comes in handy in this case:
>
>      (use-modules (guix modules))   ;for 'source-module-closure'
>
>      (with-imported-modules (source-module-closure
>                               '((guix build utils)
>                                 (gnu build vm)))
>        (gexp->derivation "something-with-vms"
>                          #~(begin
>                              (use-modules (guix build utils)
>                                           (gnu build vm))
>                              ...)))
> --8<---------------cut here---------------end--------------->8---
>
> The benefit can be seen in the next commit:
>
>   
> http://git.savannah.gnu.org/cgit/guix.git/commit/?id=239c6e276214813f59f761c9dc5cc0e9d266b49b

Ah, very nice!

Why is it necessary to read the file and parse the define-module
expression?  Does Guile not keep any of this information?  Should it?
Will something like this become part of Guile eventually?

~~ Ricardo



reply via email to

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