2022-10-05 08:19:34 +02:00
|
|
|
(define-module (oni home services emacs)
|
2023-03-17 08:49:20 +01:00
|
|
|
#:use-module ((gnu services configuration)
|
|
|
|
#:select (serialize-package
|
2023-07-14 09:54:48 +02:00
|
|
|
define-configuration
|
2023-08-15 09:21:24 +02:00
|
|
|
define-configuration/no-serialization
|
2023-07-14 09:54:48 +02:00
|
|
|
text-config?
|
|
|
|
serialize-text-config))
|
2023-03-17 08:49:20 +01:00
|
|
|
#:use-module ((gnu packages emacs)
|
|
|
|
#:select (emacs))
|
2023-08-15 09:21:24 +02:00
|
|
|
#:use-module ((gnu packages emacs-xyz)
|
|
|
|
#:select (emacs-helpful))
|
2023-03-17 08:49:20 +01:00
|
|
|
#:use-module ((gnu home services)
|
|
|
|
#:select (service-type
|
|
|
|
service-extension
|
2023-03-17 09:04:03 +01:00
|
|
|
home-profile-service-type
|
|
|
|
home-files-service-type))
|
2023-03-17 08:49:20 +01:00
|
|
|
#:use-module ((gnu home services shepherd)
|
|
|
|
#:select (shepherd-service
|
|
|
|
home-shepherd-service-type))
|
|
|
|
#:use-module ((guix gexp)
|
|
|
|
#:select (gexp
|
2023-03-17 09:04:03 +01:00
|
|
|
file-append
|
2023-07-14 09:54:48 +02:00
|
|
|
local-file
|
|
|
|
mixed-text-file))
|
2023-03-17 08:49:20 +01:00
|
|
|
#:use-module ((guix packages)
|
|
|
|
#:select (package?))
|
2022-10-05 08:19:34 +02:00
|
|
|
|
2023-08-30 07:21:30 +02:00
|
|
|
#:use-module ((oni packages emacs)
|
|
|
|
#:select (emacs-yasnippet-capf))
|
|
|
|
|
2022-10-05 08:19:34 +02:00
|
|
|
#:export (home-emacs-service-type
|
2023-08-15 09:21:24 +02:00
|
|
|
home-emacs-configuration
|
|
|
|
|
|
|
|
home-emacs-helpful-service-type
|
2023-08-30 07:21:30 +02:00
|
|
|
home-emacs-helpful-configuration
|
|
|
|
|
|
|
|
home-emacs-yasnippet-capf-service-type
|
|
|
|
home-emacs-yasnippet-capf-configuration))
|
2023-08-15 09:21:24 +02:00
|
|
|
|
|
|
|
(define-configuration/no-serialization home-emacs-extension
|
|
|
|
(configurations
|
|
|
|
(text-config '())
|
|
|
|
"The configuration for the extension."))
|
2022-10-05 08:19:34 +02:00
|
|
|
|
|
|
|
(define-configuration home-emacs-configuration
|
|
|
|
(package
|
2023-08-15 09:21:24 +02:00
|
|
|
(package emacs)
|
|
|
|
"Package to use for setting Emacs")
|
2023-07-14 09:54:48 +02:00
|
|
|
(configurations
|
|
|
|
(text-config '())
|
|
|
|
"A list of other configuration files to autoload"))
|
2022-10-05 08:19:34 +02:00
|
|
|
|
|
|
|
(define (add-emacs-packages config)
|
|
|
|
(list (home-emacs-configuration-package config)))
|
|
|
|
|
2023-08-15 09:21:24 +02:00
|
|
|
(define (home-emacs-extensions original-config extension-configs)
|
|
|
|
(home-emacs-configuration
|
|
|
|
(inherit original-config)
|
|
|
|
(configurations
|
|
|
|
(apply append (home-emacs-configuration-configurations original-config)
|
|
|
|
(map home-emacs-extension-configurations extension-configs)))))
|
|
|
|
|
2022-10-05 08:19:34 +02:00
|
|
|
(define (home-emacs-shepherd-service config)
|
|
|
|
(list
|
|
|
|
(shepherd-service
|
|
|
|
(documentation "Start Emacs")
|
|
|
|
(provision '(emacs))
|
|
|
|
(auto-start? #t)
|
|
|
|
(start
|
|
|
|
#~(make-forkexec-constructor
|
|
|
|
(list #$(file-append (home-emacs-configuration-package config) "/bin/emacs")
|
|
|
|
"--fg-daemon")
|
|
|
|
#:log-file (format #f "~a/.local/var/log/xbindkeys.log" (getenv "HOME"))))
|
|
|
|
(stop #~(make-kill-destructor)))))
|
|
|
|
|
2023-03-17 09:04:03 +01:00
|
|
|
(define (home-emacs-config-files config)
|
2023-07-14 09:54:48 +02:00
|
|
|
`((".emacs.d/init.el"
|
|
|
|
,(mixed-text-file
|
|
|
|
"init.el"
|
|
|
|
(serialize-text-config config (home-emacs-configuration-configurations config))))))
|
2023-03-17 09:04:03 +01:00
|
|
|
|
2022-10-05 08:19:34 +02:00
|
|
|
(define home-emacs-service-type
|
|
|
|
(service-type
|
|
|
|
(name 'home-emacs)
|
|
|
|
(extensions
|
|
|
|
(list (service-extension
|
|
|
|
home-profile-service-type
|
|
|
|
add-emacs-packages)
|
|
|
|
(service-extension
|
|
|
|
home-shepherd-service-type
|
2023-03-17 09:04:03 +01:00
|
|
|
home-emacs-shepherd-service)
|
|
|
|
(service-extension
|
|
|
|
home-files-service-type
|
|
|
|
home-emacs-config-files)))
|
2022-10-05 08:19:34 +02:00
|
|
|
(compose identity)
|
2023-08-15 09:21:24 +02:00
|
|
|
(extend home-emacs-extensions)
|
2022-10-05 08:19:34 +02:00
|
|
|
(default-value (home-emacs-configuration))
|
|
|
|
(description "Install and configure Emacs.")))
|
2023-08-15 09:21:24 +02:00
|
|
|
|
|
|
|
(define-configuration/no-serialization home-emacs-helpful-configuration
|
|
|
|
(package
|
|
|
|
(package emacs-helpful)
|
|
|
|
"Package to use for setting emacs-helpful.")
|
|
|
|
(configurations
|
|
|
|
(text-config '())
|
|
|
|
"Configuration for emacs-helpful."))
|
|
|
|
|
|
|
|
(define (add-emacs-helpful config)
|
|
|
|
(home-emacs-extension
|
|
|
|
(configurations (home-emacs-helpful-configuration-configurations config))))
|
|
|
|
|
|
|
|
(define (add-emacs-helpful-packages config)
|
|
|
|
(list (home-emacs-helpful-configuration-package config)))
|
|
|
|
|
|
|
|
(define home-emacs-helpful-service-type
|
|
|
|
(service-type
|
|
|
|
(name 'home-emacs-helpful)
|
|
|
|
(extensions
|
|
|
|
(list (service-extension
|
|
|
|
home-emacs-service-type
|
|
|
|
add-emacs-helpful)
|
|
|
|
(service-extension
|
|
|
|
home-profile-service-type
|
|
|
|
add-emacs-helpful-packages)))
|
|
|
|
(compose identity)
|
|
|
|
(default-value (home-emacs-helpful-configuration))
|
|
|
|
(description "Install and configure emacs-helpful.")))
|
2023-08-30 07:21:30 +02:00
|
|
|
|
|
|
|
(define-configuration/no-serialization home-emacs-yasnippet-capf-configuration
|
|
|
|
(package
|
|
|
|
(package emacs-yasnippet-capf)
|
|
|
|
"Package to use for setting emacs-yasnippet-capf.")
|
|
|
|
(configurations
|
|
|
|
(text-config '())
|
|
|
|
"Configuration for emacs-yasnippet-capf."))
|
|
|
|
|
|
|
|
(define (add-emacs-yasnippet-capf config)
|
|
|
|
(home-emacs-extension
|
|
|
|
(configurations
|
|
|
|
(append
|
|
|
|
(list (mixed-text-file "yasnippet-capf-config"
|
2023-08-30 07:23:09 +02:00
|
|
|
"(with-eval-after-load 'minibuffer (add-to-list 'completion-at-point-functions #'yasnippet-capf))\n"))
|
2023-08-30 07:21:30 +02:00
|
|
|
(home-emacs-yasnippet-capf-configuration-configurations config)))))
|
|
|
|
|
|
|
|
(define (add-emacs-yasnippet-capf-packages config)
|
|
|
|
(list (home-emacs-yasnippet-capf-configuration-package config)))
|
|
|
|
|
|
|
|
(define home-emacs-yasnippet-capf-service-type
|
|
|
|
(service-type
|
|
|
|
(name 'home-yasnippet-capf)
|
|
|
|
(extensions
|
|
|
|
(list (service-extension
|
|
|
|
home-emacs-service-type
|
|
|
|
add-emacs-yasnippet-capf)
|
|
|
|
(service-extension
|
|
|
|
home-profile-service-type
|
|
|
|
add-emacs-yasnippet-capf-packages)))
|
|
|
|
(compose identity)
|
|
|
|
(default-value (home-emacs-yasnippet-capf-configuration))
|
|
|
|
(description "Install and configure emacs-yasnippet-capf.")))
|