guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should Guix support writing CLI Common Lisp scripts? (Think Roswell)


From: Russell Sim
Subject: Re: Should Guix support writing CLI Common Lisp scripts? (Think Roswell)
Date: Tue, 27 Dec 2022 22:42:36 +0100

"jgart" <jgart@dismail.de> writes:

>> What about something like this?
>> 
>> --8<---------------cut here---------------start------------->8---
>> #!/bin/sh
>> #|-*- mode:lisp -*-|#
>> #|
>> exec guix shell sbcl -- sbcl --script $0 "$@"
>> |#
>> 
>> (format t "test~%")
>> --8<---------------cut here---------------end--------------->8---
>> 
>
> Yaaaaas!

I have found there are limitations with the `--script' option. Namely
that ASDF can't be used because it disable the userinit file.  I'm not
sure how to locate where that file is in guix.  So to avoid that the one
option is to emulate the behaviour, which is a bit more complicated. :/

so a full script example would be more like this

--8<---------------cut here---------------start------------->8---
#!/bin/bash
#|-*- mode:lisp -*-|#
#|
exec guix shell \
  -m $(dirname "${BASH_SOURCE[0]}")/../manifest.scm \
  -- sbcl \
   --noinform \
   --disable-ldb \
   --lose-on-corruption \
   --disable-debugger \
   --non-interactive \
   --eval "(set-dispatch-macro-character #\\# #\\! (lambda (stream char arg) 
(declare (ignore char arg)) (read-line stream)))" \
   --load $0 "$@"
|#

(unless (let ((*standard-output* (make-broadcast-stream))
              (*trace-output* (make-broadcast-stream))
              (*error-output* (make-broadcast-stream)))
          (asdf:load-system :balanced-parentheses))
  (warn "Failed to load balanced-parentheses")
  (uiop:quit 1))

(format t "Success~%")
--8<---------------cut here---------------end--------------->8---

This is using a guix manifest, because I want this for development with
a local project, but any guix shell options should work.  So I switched
it to bash, to support the manifest loading, but sh would work work if
you are happy listing the dependencies.

Cheers,
Russell



reply via email to

[Prev in Thread] Current Thread [Next in Thread]