#:use-module (gnu home services)
#:use-module (gnu home services shepherd)
#:use-module (gnu packages emacs)
+ #:use-module (gnu packages emacs-xyz)
#:use-module (gnu services)
#:use-module (guix gexp)
#:export (emacs-services))
(simple-service 'emacs-daemon-service
home-shepherd-service-type
(list emacs-daemon-shepherd-service)))
+
+(define emacs-package-service
+ (service home-program-service-type
+ (home-program-configuration
+ (packages
+ (list emacs-exec-path-from-shell
+ emacs-use-package))
+ (dotfiles
+ (list "emacs/.config/emacs/conf/conf-package.el")))))
(define emacs-service
(service home-program-service-type
(home-program-configuration
(define emacs-services
(list emacs-daemon-service
+ emacs-package-service
emacs-service))
--- /dev/null
+;; Copyright (c) 2022 Jakub Czajka <jakub@ekhem.eu.org>
+;; License: GPL-3.0 or later.
+;;
+;; conf-package.el - configuration for managing packages.
+
+(require 'package)
+(require 'conf-variables)
+
+(push '("melpa" . "https://melpa.org/packages/") package-archives)
+
+(defun conf:install-if-missing (package)
+ "Install PACKAGE if it is not already installed."
+ (unless (package-installed-p package)
+ (package-refresh-contents t)
+ (package-install package)))
+
+(conf:install-if-missing 'use-package)
+
+(eval-when-compile
+ (require 'use-package))
+;; Required by the `:bind' directive in `use-package'.
+(use-package bind-key)
+
+(defun conf:executables-p (execs)
+ "Returns `t' if all the names in EXECS can be found in `exec-path'. Otherwise \
+returns `nil'.
+EXECS should be a list of names of executables, with or without their full \
+path. Example:
+
+\(conf:executables-p \(list \"git\" \"pass\"\)\)"
+ (seq-every-p #'executable-find execs))
+
+(defun conf:libraries--lib-exists (lib)
+ (let* ((ld-path (concat (getenv "LD_LIBRARY_PATH") ":/usr/lib"))
+ (ld-paths (split-string ld-path ":" t)))
+ (seq-find (lambda (ld-path)
+ (file-exists-p (expand-file-name lib ld-path)))
+ ld-paths)))
+
+(defun conf:libraries-p (libs)
+ "Returns `t' if all the names in LIBS can be found in the shared library \
+linking path. Otherwise returns `nil'.
+LIBS should be a list of names of libraries, with or without their full path, \
+in the format `libexample.\{so,a\}'. `conf:with-libraries' looks for each \
+library in paths specified by `$LD_LIBRARY_PATH' and in `/usr/lib'. Example:
+
+\(conf:libraries-p \(list \"libcurl.so\" \"libX11.so\"\)\)"
+ (seq-every-p #'conf:libraries--lib-exists libs))
+
+;; == CUSTOM VARIABLES ==
+(use-package cus-edit
+ :init
+ (setq custom-file
+ (expand-file-name "custom-variables.el"
+ user-emacs-directory))
+ (load custom-file))
+
+;; == ENVIRONMENT VARIABLES ==
+;; https://emacs.stackexchange.com/a/18490
+(use-package exec-path-from-shell
+ :ensure t)
+
+(provide 'conf-package)