all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Russell Sim <rsl@simopolis.xyz>
To: jgart <jgart@dismail.de>,
	John Kehayias <john.kehayias@protonmail.com>,
	guix-devel@gnu.org
Subject: Re: Should Guix support writing CLI Common Lisp scripts? (Think Roswell)
Date: Tue, 27 Dec 2022 22:42:36 +0100	[thread overview]
Message-ID: <87k02cwmk3.fsf@simopolis.xyz> (raw)
In-Reply-To: <cd7fab7407cae12d71b95f9618345971@dismail.de>

"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	other threads:[~2022-12-28 23:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27 18:14 Should Guix support writing CLI Common Lisp scripts? (Think Roswell) jgart
2022-12-27 18:25 ` John Kehayias
2023-01-16  1:01   ` Charles
2022-12-27 19:23 ` jgart
2022-12-27 19:58   ` Russell Sim
2022-12-27 21:06   ` jgart
2022-12-27 21:42     ` Russell Sim [this message]
2023-01-17 10:07       ` Attila Lendvai
2022-12-27 22:06   ` bokr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k02cwmk3.fsf@simopolis.xyz \
    --to=rsl@simopolis.xyz \
    --cc=guix-devel@gnu.org \
    --cc=jgart@dismail.de \
    --cc=john.kehayias@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.