Subject: Re: [bug#54069] [PATCH v2 3/4] gnu: libosinfo: Unbundle usb.ids, pci.ids.

From: Brendan Tildesley <[email-masked]>
Date: Sun, 27 Feb 2022 02:37:02 +0100 (CET)

> On 02/26/2022 12:21 PM Maxime Devos <[email-masked]> wrote:
> 
>  
> Brendan Tildesley schreef op za 26-02-2022 om 15:32 [+1100]:
> > +         (string-append "-Dwith-usb-ids-path=" #$hwdata:usb "/share/hwdata/usb.ids")
> > +         (string-append "-Dwith-pci-ids-path=" #$hwdata:pci "/share/hwdata/pci.ids"))
> 
> To allow for package transformations, I recommend using
> this-package-input or the like instead of hardcoding a particular
> package:
> 
> #~(list
>     (string-append
>       "-Dwith-usb-ids-path="
>       #$(this-package-input "hwdata:usb") "/share/hwdata/usb.ids"))
>     [...])
> 
> it might also be possible to use 'search-input-file' instead, avoiding
> input labels (untested):
> 
> #~(let* ((inputs #$(input-tuples->gexp (package-inputs this-package)))
>          (usb.ids (search-input-file inputs "/share/hwdata/usb.ids"))
>          (pci.ids (search-input-file inputs "/share/hwdata/pci.ids")))
>     (list (string-append "-Dwith-usb-ids-path=" usb.ids) [...]))
> 
I got strange errors trying that and couldn't figure out how to make it work.
There are no examples of input-tuples->gexp being used in a package definition.

This works:
 #~(list
         (string-append "-Dwith-usb-ids-path="
                        (search-input-file %build-inputs "/share/hwdata/usb.ids"))
         (string-append "-Dwith-pci-ids-path="
                        (search-input-file %build-inputs "/share/hwdata/pci.ids")))

I thought %build-inputs was not a recommended thing to use though?
> Greetings,
> Maxime.

Backtrace:
In guix/store.scm:
   1385:9 19 (map/accumulate-builds #<store-connection 256.99 7f3a3…> …)
   1320:8 18 (call-with-build-handler #<procedure 7f3a22f4b360 at g…> …)
In guix/scripts/build.scm:
   582:16 17 (_ #<package [email-masked] /home/b/code/guix/gnu/pack…>)
   571:24 16 (_ #<package [email-masked] /home/b/code/guix/gnu/pac…> …)
In guix/packages.scm:
  1260:17 15 (supported-package? #<package [email-masked] /home/b/…> …)
In guix/memoization.scm:
    101:0 14 (_ #<hash-table 7f3a2538e7a0 0/31> #<package libosinfo…> …)
In guix/packages.scm:
  1238:37 13 (_)
  1498:16 12 (package->bag _ _ _ #:graft? _)
  1603:43 11 (thunk)
In ice-9/eval.scm:
   191:35 10 (_ #(#(#<directory (gnu packages virtualization) 7f…>) …))
   173:47  9 (_ #(#(#<directory (gnu packages virtualization) 7f…>) …))
   213:29  8 (_ #(#(#<directory (gnu packages virtualization) 7f…>) …))
    155:9  7 (_ #(#(#<directory (gnu packages virtualization) 7f…>) …))
   202:35  6 (_ #(#(#<directory (gnu packages virtualization) 7f…>) …))
In guix/gexp.scm:
   1886:4  5 (input-tuples->gexp (("glib" #<package [email-masked]…> …) …) …)
In srfi/srfi-1.scm:
   586:17  4 (map1 (("glib" #<package [email-masked] gnu/packages…> …) …))
In guix/gexp.scm:
   1886:9  3 (_ _)
In ice-9/boot-9.scm:
  1685:16  2 (raise-exception _ #:continuable? _)
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern" ("glib" #<package [email-masked] gnu/packages/glib.scm:180 7f3a24fdbdc0> "bin"))'.