[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Add path to a guix package into CMakeLists.txt
From: |
James Smith |
Subject: |
Re: Add path to a guix package into CMakeLists.txt |
Date: |
Thu, 03 Oct 2024 18:12:23 -0700 |
Andreas Enge <andreas@enge.fr> writes:
> this is indeed quite a common action. For instance, I do something like this
> in the package vinci in gnu/packages/maths.scm:
>
> (modify-phases %standard-phases
> (replace 'configure
> ;; register the lrs location in the config file
> (lambda* (#:key inputs #:allow-other-keys)
> (let* ((lrs (assoc-ref inputs "lrslib"))
> (lrsexec (string-append lrs "/bin/lrs")))
> (substitute* "vinci.h"
> (("#define LRS_EXEC \"lrs\"")
> (string-append "#define LRS_EXEC \"" lrsexec "\""))))
> #t))
>
> So the function defining the phase needs to take the keyword parameter
> "inputs", and this is set to the inputs of the package.
> Then (assoc-ref inputs "lrslib") resolves to /gnu/store/...-lrslib-...,
> the store path corresponding to the input package.
>
> However, this is an "old style" package; for instance, phases do not end
> with #t anymore. I do not know whether one would do differently with the
> modern gexp style approach.
In case you're wondering, the example above when rewritten in the
current style would look something like this:
#~(modify-phases %standard-phases
(replace 'configure
;; Register the lrs location in the config file.
(lambda* (#:key inputs #:allow-other-keys)
(substitute* "vinci.h"
(("#define LRS_EXEC \"lrs\"")
(string-append "#define LRS_EXEC \""
(search-input-file inputs "/bin/lrs") "\""))))))
Hope that helps,
James