From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: (guix modules) and =?utf-8?Q?=E2=80=98source-module-closure?= =?utf-8?Q?=E2=80=99?= Date: Mon, 5 Sep 2016 10:13:27 +0200 Message-ID: References: <8760qbi9qu.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgp2F-00014o-3U for guix-devel@gnu.org; Mon, 05 Sep 2016 04:13:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgp2A-0008UU-P5 for guix-devel@gnu.org; Mon, 05 Sep 2016 04:13:42 -0400 In-Reply-To: <8760qbi9qu.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel Ludovic Court=C3=A8s 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 =E2=80=98with-imported-modules=E2=80=99 usa= ge, as explained > in the manual: > > --8<---------------cut here---------------start------------->8--- > Usually you want the _closure_ of the module to be imported=E2=80=94= i.e., the > module itself and all the modules it depends on=E2=80=94rather than jus= t the > module; failing to do that, attempts to use the module will fail becaus= e > of missing dependent modules. The =E2=80=98source-module-closure=E2=80= =99 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=3D239c6e27621481= 3f59f761c9dc5cc0e9d266b49b 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