-- Leo's gemini proxy

-- Connecting to gem.librehacker.com:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Guix REPL in Emacs (publ. 2024-01-24)


Part of my quest for world domin... err, automating more of my local computer processes, is being able to control Guix directly through lisp commands. The "guix repl" command is intended for that purpose, bringing up a guile prompt inside guix-user module, with everything initialized for interacting with your profile.


Of course, it isn't fun until you can interact with it through Emacs. Conveniently, "guix repl" has a --listen parameter for connecting to listening on either a tcp port or a Unix-domain socket.


‘--listen=ENDPOINT’
     By default, ‘guix repl’ reads from standard input and writes to
     standard output.  When this option is passed, it will instead
     listen for connections on ENDPOINT.  Here are examples of valid
     options:

     ‘--listen=tcp:37146’
          Accept connections on localhost on port 37146.

     ‘--listen=unix:/tmp/socket’
          Accept connections on the Unix-domain socket ‘/tmp/socket’.

And inside Emacs, geiser can connect to either a tcp port or a unix socket through geiser-connect or geiser-connect-local, respectively. I threw together this for starting it up in Emacs:


(defun launch-guix-repl ()
  "Tries to launch guix repl in a shell and then connect to it with geiser. Assumes nothing is already using port 37146."
  (interactive)
  (shell-command "guix repl --listen=tcp:37146 &")
  (sleep-for 2)
  (geiser-connect 'guile "localhost" 37146))

This works but has a bug that, for some unknown reason, geiser does not start receiving input from "guix repl" until you press C-g (in Emacs). After that it behaves normally. I'm mildly curious to try this using a domain socket instead, maybe with a random filename so I can have more than one REPL at a time.


Copyright


This work © 2024 by Christopher Howard is licensed under Attribution-ShareAlike 4.0 International.

CC BY-SA 4.0 Deed

-- Response ended

-- Page fetched on Tue May 21 14:21:58 2024