all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* G-expressions in native-search-paths
@ 2023-08-08  9:01 Reza Housseini
  2023-08-08  9:36 ` (
  0 siblings, 1 reply; 4+ messages in thread
From: Reza Housseini @ 2023-08-08  9:01 UTC (permalink / raw)
  To: help-guix


[-- Attachment #1.1.1: Type: text/plain, Size: 1639 bytes --]

Hi List

I am trying to use g-expressions in nativ-search-paths field, but it 
fails with an error message, what is the issue her:

     (native-search-paths
      (list (search-path-specification
	    (variable "CFDEM_SRC_DIR")
	    (files #~'((string-append "share/" #$name "-" #$version))))))

and the error message:

Backtrace:
           11 (primitive-load "/gnu/store/3hbiwibrp9if0dhvyyhhdk87gb8…")
In ice-9/ports.scm:
    433:17 10 (call-with-output-file _ _ #:binary _ #:encoding _)
In guix/build/profiles.scm:
    100:23  9 (_ #<output: /gnu/store/2s49jj1sdm04zql9ivdpw5j1r5l2g41…>)
In srfi/srfi-1.scm:
    691:23  8 (filter-map #<procedure search-path-definition (spec)> . #)
In guix/search-paths.scm:
    202:22  7 (failure)
In ice-9/ports.scm:
     480:4  6 (with-error-to-port _ _)
In srfi/srfi-1.scm:
    673:15  5 (append-map #<procedure 2aaaadb2c360 at guix/build/uti…> …)
    586:17  4 (map1 ("/gnu/store/2s49jj1sdm04zql9ivdpw5j1r5l2g41b-pr…"))
    673:15  3 (append-map #<procedure 2aaaadb2c330 at guix/build/uti…> …)
    586:17  2 (map1 (quote ((string-append "share/" "cfdemcoupl…" …))))
In guix/build/utils.scm:
    601:42  1 (_ quote)
In unknown file:
            0 (string-append "/gnu/store/2s49jj1sdm04zql9ivdpw5j1r5l…" …)

ERROR: In procedure string-append:
In procedure string-append: Wrong type (expecting string): quote

which looks like he is trying to append a string to a string which 
should work in my opinion?

Best,
-- 
Reza Housseini

This message is signed with my GnuPG key:

     C0F3 0812 9AF2 80F4 0830 C2C1 C375 C6AF 0512 5C52

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 15557 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: G-expressions in native-search-paths
  2023-08-08  9:01 G-expressions in native-search-paths Reza Housseini
@ 2023-08-08  9:36 ` (
  2023-08-08  9:50   ` Reza Housseini
  0 siblings, 1 reply; 4+ messages in thread
From: ( @ 2023-08-08  9:36 UTC (permalink / raw)
  To: Reza Housseini; +Cc: help-guix

Reza Housseini <reza.housseini@gmail.com> writes:
> I am trying to use g-expressions in nativ-search-paths field, but it fails with
> an error message, what is the issue her:
>
>     (native-search-paths
>      (list (search-path-specification
> 	    (variable "CFDEM_SRC_DIR")
> 	    (files #~'((string-append "share/" #$name "-" #$version))))))

There's two issues here:

One, you can't use a gexp in FILES.  This will work fine:

  (files (list (string-append "share/" name "-" version)))

Two, this:

  '(string-append "share/" name "-" version)

does *not* evaluate to what you think it does; in fact, it becomes this:

  (list 'string-append "share/" 'name "-" 'version)

a list of strings and symbols, because it's quoted.  If you want to use
an expression within a quoted form, you can use quasiquote:

  `(,(string-append …))

LIST works fine most of the time, though.

  -- (


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: G-expressions in native-search-paths
  2023-08-08  9:36 ` (
@ 2023-08-08  9:50   ` Reza Housseini
  2023-08-08 10:39     ` (
  0 siblings, 1 reply; 4+ messages in thread
From: Reza Housseini @ 2023-08-08  9:50 UTC (permalink / raw)
  To: (; +Cc: help-guix


[-- Attachment #1.1.1: Type: text/plain, Size: 1243 bytes --]

> There's two issues here:
> 
> One, you can't use a gexp in FILES.  This will work fine:
> 
>    (files (list (string-append "share/" name "-" version)))

"name" and "version" come directly from the package definition?
How do I know where to use gexp's and where not?
> Two, this:
> 
>    '(string-append "share/" name "-" version)
> 
> does *not* evaluate to what you think it does; in fact, it becomes this:
> 
>    (list 'string-append "share/" 'name "-" 'version)
> 
> a list of strings and symbols, because it's quoted.  If you want to use
> an expression within a quoted form, you can use quasiquote:
> 
>    `(,(string-append …))
> 
> LIST works fine most of the time, though.

Thanks I knew about quasiquote, but as mentioned above when do I have to 
use quasiquote and when do I use gexp's? Using one or the other makes 
the package description more readable IMO.

And why does it look like that in the error message it was actually able 
to evaluate #$name to a string (cfdemcoupling; the package name) but 
still fails with an error...?

Thanks again and best regards,

-- 
Reza Housseini

This message is signed with my GnuPG key:

     C0F3 0812 9AF2 80F4 0830 C2C1 C375 C6AF 0512 5C52


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 15557 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: G-expressions in native-search-paths
  2023-08-08  9:50   ` Reza Housseini
@ 2023-08-08 10:39     ` (
  0 siblings, 0 replies; 4+ messages in thread
From: ( @ 2023-08-08 10:39 UTC (permalink / raw)
  To: Reza Housseini; +Cc: help-guix

Reza Housseini <reza.housseini@gmail.com> writes:
> [[PGP Signed Part:Undecided]]
>> There's two issues here:
>> One, you can't use a gexp in FILES.  This will work fine:
>>    (files (list (string-append "share/" name "-" version)))
>
> "name" and "version" come directly from the package definition?
> How do I know where to use gexp's and where not?

Have a read of these:

  Dissecting Guix, Part 1: Derivations
    https://guix.gnu.org/en/blog/2023/dissecting-guix-part-1-derivations/

  Dissecting Guix, Part 2: The Store Monad
    https://guix.gnu.org/en/blog/2023/dissecting-guix-part-2-the-store-monad/

  Dissecting Guix, Part 3: G-Expressions
    https://guix.gnu.org/en/blog/2023/dissecting-guix-part-3-g-expressions/

  -- (


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-08 10:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-08  9:01 G-expressions in native-search-paths Reza Housseini
2023-08-08  9:36 ` (
2023-08-08  9:50   ` Reza Housseini
2023-08-08 10:39     ` (

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.