guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating an Emacs Home Configuration Service


From: Zain Jabbar
Subject: Creating an Emacs Home Configuration Service
Date: Sun, 16 Oct 2022 16:34:00 -1000

Aloha Guix Development Team,

Running =guix home search emacs= returns nothing. I also could not find an email using =C-u M-x debbugs-gnu= about an Emacs configuration service.

This is my first email to this mailing address. Please give me pointers on formatting and further improvements.

I have attempted to make an =emacs-home-service-type= so that it is possible to configure Emacs using Guix home. This code is extremely preliminary hence I don't even think it is worth sending as a patch. Also I have never worked on a multi person Git project before and do not know how to solve the keyring error I get when using guix pull. I will outline what my code does and what features I would like to add.

#+BEGIN_SRC scheme
(define* (emacs-configuration-service name #:key (init '()) (early-init '()) (emacs-packages '()))
  (service-type (name (symbol-append 'emacs- name '-configuration))
(extensions
(list (service-extension
home-profile-service-type
(lambda (config) emacs-packages))
      (service-extension
home-files-service-type
(lambda (config)
 (list
  `(,(string-append
      ".config/emacs/services/" (symbol->string name) ".el")
    ,(scheme-file (string-append (symbol->string name) ".el")
  init #:splice? #t))
  `(,(string-append
      ".config/emacs/early-services/" (symbol->string name) ".el")
    ,(scheme-file (string-append "early-" (symbol->string name) ".el")
  early-init #:splice? #t)))))))
(default-value #f)
(description "Configures Emacs init.el")))


(define-public emacs-init-service-type
  (service-type (name 'home-emacs)
(extensions
(list (service-extension
home-profile-service-type
(lambda (config) (list emacs-next)))
      (service-extension
home-files-service-type
(lambda (config)
 (list
  `(".config/emacs/early-init.el"
    ,(scheme-file
      "early-init.el"
      '((mapc
 'load (file-expand-wildcards
"~/.config/emacs/early-services/*.el")))
      #:splice? #t))
  `(".config/emacs/init.el"
    ,(scheme-file
      "init.el"
      '((mapc
 'load (file-expand-wildcards
"~/.config/emacs/services/*.el")))
      #:splice? #t)))))))
(default-value #f)
(description "Configures Emacs init.el")))
#+END_SRC

I define a general configuration service generator which takes in four things:
1. The =name= of the service
2. The configuration to be ran in =init.el=
3. The configuration to be ran in =early-init.el=
4. The packages in Guix to be added to the =home-profile="">
After giving the =name=, =packages=, and =config.el= files we get a new service type that we can add to our home declaration. This service will then add a file in =~/.config/emacs/services/emacs-{NAME}-configuration.el=. I then have another service that places an =init.el= which loads everything in the service directory.

If we want to install and configure =evil-mode= using this =home-service= we may define the following somewhere.

#+BEGIN_SRC scheme
(define-public emacs-evil-service-type
  (emacs-configuration-service
   'evil #:emacs-packages (list emacs-evil)
   #:init '((evil-mode 1))))
#+END_SRC

Within our =home-environment= we may add the service using:

#+BEGIN_SRC scheme
(home-environment
 ;; ...Things in the home-environment...
 (services
  (list
   ;; ...Other Services...
   (service emacs-evil-service-type))))
#+END_SRC

There are some missing features I want to add.

1. Have the =home-emacs-*-service-type= service-types add to the =init.el= directly rather than within a folder to be loaded. I couldn't add two files with the same name to the store. So I have emacs-evil.el in the store to be placed separately later rather than appending to the existing init.el file.

2. Have Emacs update whenever the =home-environment= is updated. Meaning, if I did not add =(service emacs-evil-service-type)= in my =home-environment= then obviously =M-x evil-mode= should not work. But after adding the service then I want =M-x evil-mode= to work without having to restart Emacs. I do not understand the Emacs loading system on Guix well enough to know why it does not work. Skipping all of the =home-service= stuff, running =guix install emacs-evil-mode= then =(guix-emacs-autoload-packages)= does not let emacs know that =evil-mode= is installed. I would need to close Emacs and start Emacs again for Emacs to know about =evil-mode= being installed.

3. Use configurations somehow. I have completely neglected this feature in my system. I do not know what would be useful there.

--
Thank you,
Zain Jabbar

reply via email to

[Prev in Thread] Current Thread [Next in Thread]