help-guix
[Top][All Lists]
Advanced

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

Re: How do you write a package's deps to a file?


From: zimoun
Subject: Re: How do you write a package's deps to a file?
Date: Tue, 01 Dec 2020 00:23:10 +0100

Hi,

>>#+begin_src scheme
>>(add-after 'install 'create-dependency-file
>>                 (lambda* (#:key inputs outputs #:allow-other-keys)

[...]

>>                         (map (lambda (input)
>>                                (let ((name (car input)))
                                    (pk input)
>>                                  ,(package-version
>>                                    (specification->package name)) " | "

[...]

>>                              inputs)))
>>                       ))
>>                   ))
>>#+end_src
>>
>>That ^^ doesn't seem to work as I'd like it to. The output(truncated)
>>looks something like:

It is expected, as Julien explained.


Well, I have tried to uses modules in the builder in order to import
’specification->package’ but I failed.  There is still something a bit
unclear for me: the arguments #:modules vs ’use-modules’.  And for
example, I miss why

--8<---------------cut here---------------start------------->8---
    (arguments
     `(#:modules ((gnu packages))
…     
--8<---------------cut here---------------end--------------->8---

fails.  Moreover…

>>Notice that the version, home page and description
>>are repeated across rows. Herein lies my question:
>>How would you fetch the details of the inputs(like
>>version, home-page, description) etc etc from a
>>modifed phase. Do I need to create a closure from
>>which I can import the modules like say _(use (gnu
>>packages))_. How do I do that if that's the case?

…I am not convinced it is the right level to extract the
information you need since ’input’ is, e.g.,

  ;;; (("source" . 
"/gnu/store/hbdalsf5lpf01x4dcknwx6xbn6n5km6k-hello-2.10.tar.gz"))
  ;;; (("grep" . "/gnu/store/yhqc5imq7sn2sf9f48dj4gk12y4kw4s4-grep-3.4"))
  ;;; (("libc:static" . 
"/gnu/store/s3dcqzwqaakv1yx37by9chksdbkgih17-glibc-2.31-static"))
  
therefore you need ’specification->package’ to find back the package
mapping to the string in order to access the metadata (version,
home-page, etc.).  Aside the issue that some do not have corresponding
packages (source, libc:static for instance).  Aside the issue of
multiple versions, for instance compare the version of the ’gcc’ input
of ’hello’ returning the string “gcc” with:

--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> (specification->package "gcc")
guix repl: package 'gcc' has been superseded by 'gcc-toolchain'
$1 = #<package gcc-toolchain@10.2.0 gnu/packages/commencement.scm:3836 
7f3b72596640>
--8<---------------cut here---------------end--------------->8---


What do you want?  Get the list of inputs and their metadata when typing
“guix install foo”?  And this list becoming part of the outputs?  Or
simply get somehow the list of inputs and their metadata?  Which is
straightforward.


Well, I am interested by the answer of: is it possible to get the
metadata of the inputs in phases?

All the best,
simon



reply via email to

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