On 03/08/2025 15:03, Tomas Volf wrote:
Hi Tristan,
Tristan <blobb...@ymail.com> writes:
I want to create a service that listens on an MQTT topic for messages
(i.e. "pull docker") and runs corresponding commands on the local machine.
For that to work I need guile-mqtt but I do to not understand how module
visibility works in Guix.
Coming from other languages I would assume that imports would check files next
to the starting point and then bubble up a predefined PATH until it finds some
module or fails.
However that is not what I am seeing or at least the shell command is not
working the way I am expecting to.
What am I missing?
guix shell guile-mqtt -- guile -c "(use-modules (mosquitto client)) (display
\"Module loaded successfully\n\")"
I think this is one of those things everyone runs into when starting
with Guix. In Guix, there is a concept of search paths, and they are
(typically) attached to specific *programs*. So, in your case, *guile*
knows how to find guile libraries, so you need also add the guile
package to the profile. Compare
--8<---------------cut here---------------start------------->8---
$ guix shell -C guile-mqtt --search-paths
--8<---------------cut here---------------end--------------->8---
with
--8<---------------cut here---------------start------------->8---
$ guix shell -C guile guile-mqtt --search-paths
export
PATH="/gnu/store/5cnjlww82k4w0bd2f6110v8x5mj9afiv-profile/bin${PATH:+:}$PATH"
export
GUILE_LOAD_PATH="/gnu/store/5cnjlww82k4w0bd2f6110v8x5mj9afiv-profile/share/guile/site/3.0${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
export
GUILE_LOAD_COMPILED_PATH="/gnu/store/5cnjlww82k4w0bd2f6110v8x5mj9afiv-profile/lib/guile/3.0/site-ccache:/gnu/store/5cnjlww82k4w0bd2f6110v8x5mj9afiv-profile/share/guile/site/3.0${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
--8<---------------cut here---------------end--------------->8---
There is a similar gotcha with the SSL certificates:
--8<---------------cut here---------------start------------->8---
$ guix shell -NC guile -- guile -c '(pk ((@ (web client)
x509-certificate-directory)))'
;;; ("/etc/ssl/certs")
$ guix shell -NC guile nss-certs -- guile -c '(pk ((@ (web client)
x509-certificate-directory)))'
;;; ("/etc/ssl/certs")
$ guix shell -NC guile nss-certs curl -- guile -c '(pk ((@ (web client)
x509-certificate-directory)))'
;;; ("/gnu/store/qbs8fbv9m0m456p717zkqjxlgmfjam7h-profile/etc/ssl/certs")
--8<---------------cut here---------------end--------------->8---
Notice how the file name of the certificates changes only after the
`curl' package is added to the profile. Neither `guile' nor `nss-certs'
has the search path for them, so it if often necessary to add `curl'
even when you do not plan to use it.
Hope this helps,
Tomas
That did the trick!
I was expecting since Guile was available inside the shell that the
existing environment was transferred over.
Thank you to Rutherter, Ekaitz and Thomas for the fast help!
All the best,
Tristan