From e39ea1708d5b7121cac9a9f6c7953c15633b01c0 Mon Sep 17 00:00:00 2001 From: Zain Jabbar Date: Fri, 21 Oct 2022 20:48:31 -1000 Subject: [PATCH] Adding =home-emacs-service-type= and =home-emacs-configuration=. A service to configure emacs using guix home. --- gnu/home/services/emacs.scm | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 gnu/home/services/emacs.scm diff --git a/gnu/home/services/emacs.scm b/gnu/home/services/emacs.scm new file mode 100644 index 0000000000..1da6987411 --- /dev/null +++ b/gnu/home/services/emacs.scm @@ -0,0 +1,72 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2022 Zain Jabbar +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu home services emacs) + #:use-module (gnu home) + #:use-module (gnu packages) + #:use-module (gnu services) + #:use-module (gnu home services) + #:use-module (gnu services) + #:use-module (gnu services configuration) + #:use-module (guix gexp) + + #:export (home-emacs-service-type + home-emacs-configuration)) + +(define file-likes? (list-of file-like?)) + +(define-configuration/no-serialization home-emacs-configuration + (emacs + (file-like (specification->package "emacs-next")) + "The Emacs package to use.") + (packages + (file-likes '()) + "The packages this configuration will add to home-profile. Usually these will be emacs-* packages.") + (early-init + (list '()) + "A list whose contents will inserted into @file{$XDG_CONFIG_HOME/emacs/early-init.el}") + (init + (list '()) + "A list whose contents will inserted into @file{$XDG_CONFIG_HOME/emacs/init.el}") + (extra-files + (file-likes '()) + "A list of files to be placed in @file{$XDG_CONFIG_HOME/emacs/}.")) + +(define home-emacs-service-type + (service-type (name 'emacs-configuration) + (extensions + (list (service-extension + home-profile-service-type + (lambda (config) `(,(home-emacs-configuration-emacs config) + ,@(home-emacs-configuration-packages config)))) + (service-extension + home-xdg-configuration-files-service-type + (lambda (config) + `(("emacs/early-init.el" + ,(scheme-file "early-init.el" + (home-emacs-configuration-early-init config) + #:splice? #:t)) + ("emacs/init.el" + ,(scheme-file "init.el" + (home-emacs-configuration-init config) + #:splice? #:t)) + ,@(map (lambda (file) (list (string-append "emacs/" (scheme-file-name file)) + file)) + (home-emacs-configuration-extra-files config))))))) + (default-value (home-emacs-configuration)) + (description "Configures Emacs and installs packages to home-profile."))) -- 2.38.0