Hi Tristan,

On Thu, May 23 2024, Tristan Kohl via wrote:

> I did not even think about using Guile as the executable :D

Congratulations!  Maybe you will stop writing shell scripts altogether.

> Wrong type to apply: #<unspecified>

For me, that error often means an extra pair of parentheses, such as
trying to evaluate a constant, but here the issue could be that http-get
returns two values. [1]

Maybe this works without an error?

    (use-module (gnu) (guix modules))
    (use-package-modules tls)
   
    (define smartd-send-ntfy
      (program-file "smartd-send-ntfy"
        (with-extensions (list gnutls)
          (with-imported-modules
            (source-module-closure '((ice-9 receive)
                                      (web client)))
            #~((use-modules (ice-9 receive)
                            (web client))
               (receive (_ body)
                   (http-get "https://example.com";)
                 body)))))

Instead of the string body, you could return a success value via
something like

    (not (string-null? body))

You can look at the values in the comfort of the Guile REPL, or in Emacs
Geiser.

Kind regards
Felix

[1] https://www.gnu.org/software/guile//manual/html_node/Multiple-Values.html

Reply via email to