Indent generated G-expression scripts

Indent generated G-expression scripts

Published by Arun Isaac on

In other languages: தமிழ்

Tags: guix, software, scheme, lisp

Indent generated G-expression scripts with this trick to aid in debugging!

Quick tip!

Scripts generated from G-expressions (such as using program-file or gexp->script) often need to be inspected and debugged. But, they are written to the store as a gibberish tangled ball of parentheses. Indent them using guix-scheme-mode in Emacs. guix-scheme-mode is part of Emacs-Guix.

Emacs with a generated G-expression script; guix-scheme-mode indents it.

Figure 1: guix-scheme-mode indents tangled ball of parentheses

If you're not an Emacs user, you're not entirely out of luck. You can use this guile one-liner:

cat /gnu/store/…-foo | guile -c '((@ (ice-9 pretty-print) pretty-print) (read))'