The Perfect Setup to hack on Guix is basically the perfect setup used for Guile hacking (see Using Guile in Emacs in Guile Reference Manual). First, you need more than an editor, you need Emacs, empowered by the wonderful Geiser. To set that up, run:
guix package -i emacs guile emacs-geiser
Geiser allows for interactive and incremental development from within Emacs: code compilation and evaluation from within buffers, access to on-line documentation (docstrings), context-sensitive completion, M-. to jump to an object definition, a REPL to try out your code, and more (see Introduction in Geiser User Manual). For convenient Guix development, make sure to augment Guile’s load path so that it finds source files from your checkout:
;; Assuming the Guix checkout is in ~/src/guix. (with-eval-after-load 'geiser-guile (add-to-list 'geiser-guile-load-path "~/src/guix"))
To actually edit the code, Emacs already has a neat Scheme mode. But in addition to that, you must not miss Paredit. It provides facilities to directly operate on the syntax tree, such as raising an s-expression or wrapping it, swallowing or rejecting the following s-expression, etc.
We also provide templates for common git commit messages and package definitions in the etc/snippets directory. These templates can be used with YASnippet to expand short trigger strings to interactive text snippets. You may want to add the snippets directory to the yas-snippet-dirs variable in Emacs.
;; Assuming the Guix checkout is in ~/src/guix. (with-eval-after-load 'yasnippet (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets"))
The commit message snippets depend on Magit to
display staged files. When editing a commit message type
followed by TAB to insert a commit message template for adding a
update followed by TAB to insert a template
for updating a package; type
https followed by TAB to
insert a template for changing the home page URI of a package to HTTPS.
The main snippet for
scheme-mode is triggered by typing
package... followed by TAB. This snippet also inserts the
origin..., which can be expanded further. The
origin snippet in turn may insert other trigger strings ending on
..., which also can be expanded further.
Additionaly we provide insertion and automatic update of a copyright in etc/copyright.el. You may want to set your full name, mail, and load a file.
(setq user-full-name "Alice Doe") (setq user-mail-address "email@example.com") ;; Assuming the Guix checkout is in ~/src/guix. (load-file "~/src/guix/etc/copyright.el")
To insert a copyright at the current line invoke
To update a copyright you need to specify a
(setq copyright-names-regexp (format "%s <%s>" user-full-name user-mail-address))
You can check if your copyright is up to date by evaluating
copyright-update. If you want to do it automatically after each buffer
save then add
(add-hook 'after-save-hook 'copyright-update) in