Configuring Rational Emacs with Guix Home


Configuring Rational Emacs with Guix Home

Today we’re going to try and combine two areas that are interesting to me: configuring Emacs and managing your dotfiles configuration with Guix Home.

We’ll attempt to make it possible to install and configure Rational Emacs using the functionality provided by Guix Home!


One of my goals with creating Rational Emacs was to make a base Emacs configuration that could be used both with and without Guix.

Configuring Rational Emacs with Guix has interesting implications:

  • Potentially easier to configure Rational Emacs, just include some code in your Guix Home config
  • You can much more easily roll back to a previous working version of Rational Emacs
  • You can customize aspects of your Emacs configuration across different machines at the Guix layer (faces, themes, loaded modules, etc)
  • You can even “containerize” your Emacs dev environment configurations

There are also possible downsides, but we can discuss those later.

If you want some more details on how you can use Guix to manage an Emacs configuration, check out Andrew Tropin’s latest video:


I’m not entirely sure yet what will be needed, but here’s what we’ll try to do:

  • Create a Guix package to install Rational Emacs from GitHub
  • Create a Guix Home service which places Rational Emacs in ~/.emacs.d
  • Add configuration parameters to the home service to create Rational Emacs configuration files in ~/.config/rational-emacs
  • Test it all out using guix home container

The files


This is an example home configuration that uses home-rational-emacs-service-type!

(define-module (rational home-config)
  #:use-module (gnu)
  #:use-module (gnu home)
  #:use-module (gnu home services)
  #:use-module (rational home services rational-emacs))

 (services (list
            ;; Set up desktop environment
            (service home-rational-emacs-service-type
                      (config-file "(require 'rational-ui)\n(require 'rational-editing)\n(require 'rational-evil)")
                      (early-config-file ""))))))


(define-module (rational packages emacs)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (guix build-system copy)
  #:use-module ((guix licenses) #:prefix license:))

(define-public rational-emacs
    (name "rational-emacs")
    (version "0.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "")
                    (commit "75020f247ab39e19d998319d0e84d3ab5386fb2d")))
    (build-system copy-build-system)
    (home-page "")
    (synopsis "Rational Emacs")
    (description "Rational Emacs")
    (license license:expat)))


(define-module (rational home services rational-emacs)
  #:use-module (gnu services)
  #:use-module (gnu services configuration)
  #:use-module (gnu home services)
  #:use-module (gnu home services shepherd)
  #:use-module (gnu home services utils)
  #:use-module (gnu packages certs)
  #:use-module (gnu packages emacs)
  #:use-module (guix gexp)
  #:use-module (guix packages)
  #:use-module (rational packages emacs)
  #:use-module (ice-9 format)

  #:export (home-rational-emacs-service-type

(define-configuration home-rational-emacs-configuration
    (package rational-emacs)
    "The Rational Emacs package to use.")
   (package emacs)
   "The Emacs package to use.")
   (text-config '())
   "The config.el file.")
   (text-config '())
   "The early-config.el file."))

(define package-user-dir "~/.cache/emacs/elpa")

(define (home-rational-emacs-files-service config)
  (list `(".emacs.d" ,rational-emacs)
          ,(mixed-text-file "config.el"
                            ";; Rational Emacs Config from Guix Home\n"
                            (home-rational-emacs-configuration-config-file config)))
          ,(mixed-text-file "early-config.el"
                            ";; Rational Emacs Early Config from Guix Home\n"
                            (format #f "(make-directory \"~a\" t)\n" package-user-dir)
                            (format #f "(setq package-user-dir \"~a\")\n" package-user-dir)
                            (home-rational-emacs-configuration-early-config-file config)))))

(define (home-rational-emacs-profile-service config)
  (list nss-certs
        (home-rational-emacs-configuration-package config)
        (home-rational-emacs-configuration-emacs-package config)))

(define home-rational-emacs-service-type
  (service-type (name 'home-rational-emacs)
                (description "The home service to confiure Rational Emacs.")
                 (list (service-extension
                (default-value (home-rational-emacs-configuration))))
Subscribe to the System Crafters Newsletter!
Stay up to date with the latest System Crafters news and updates! Read the Newsletter page for more information.
Name (optional)
Email Address