Add shepherd configuration with Emacs service
This commit is contained in:
parent
976a2c7c28
commit
5e9c6362e4
4 changed files with 81 additions and 23 deletions
63
GNUmakefile
63
GNUmakefile
|
@ -1,16 +1,28 @@
|
||||||
include dotfiles.mk
|
MODULES=xmodmap emacs xdg shepherd
|
||||||
|
|
||||||
MODULES=xmodmap emacs picom cower mowedline herbstluftwm xdg
|
STOW = stow
|
||||||
STOW=stow
|
EMACS = emacs
|
||||||
|
SCHEME_IMPLEMENTATION = guile
|
||||||
|
|
||||||
|
define tangle =
|
||||||
|
@echo -e "\e[35mOBT\e[0m" $<
|
||||||
|
@$(EMACS) -quick -batch \
|
||||||
|
-eval "(package-initialize)" \
|
||||||
|
-load ob-tangle \
|
||||||
|
-eval "(setq sh-make-vars-local nil)" \
|
||||||
|
-eval "(setq geiser-default-implementation '$(SCHEME_IMPLEMENTATION))" \
|
||||||
|
-eval "(org-babel-tangle-file \"$<\" \"$(PWD)/$@\" \"$(1)\")"
|
||||||
|
endef
|
||||||
|
|
||||||
.PHONY: all clean $(MODULES) zsh
|
.PHONY: all clean $(MODULES) zsh
|
||||||
|
|
||||||
all: $(MODULES)
|
all: $(MODULES)
|
||||||
|
|
||||||
build:
|
install:
|
||||||
mkdir build
|
cp --recursive --verbose build/. ~/
|
||||||
|
|
||||||
clean: $(addsuffix -clean,$(MODULES))
|
clean:
|
||||||
|
rm -r build
|
||||||
|
|
||||||
zsh:
|
zsh:
|
||||||
$(MAKE) -C $@
|
$(MAKE) -C $@
|
||||||
|
@ -41,14 +53,17 @@ picom-clean:
|
||||||
# Emacs #
|
# Emacs #
|
||||||
#########
|
#########
|
||||||
|
|
||||||
emacs-install: emacs-stow
|
emacs: build/.config/shepherd/init.d/ build/.config/shepherd/init.d/emacs.scm \
|
||||||
xdg-settings set default-url-scheme-handler org-protocol EmacsClient.desktop
|
emacs/.config/emacs/init.elc
|
||||||
|
|
||||||
|
build/.config/shepherd/init.d/emacs.scm: emacs/.config/shepherd/init.d/emacs.org
|
||||||
|
$(call tangle)
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# Xmodmap #
|
# Xmodmap #
|
||||||
###########
|
###########
|
||||||
|
|
||||||
xmodmap: build build/.Xmodmap
|
xmodmap: build/ build/.Xmodmap
|
||||||
|
|
||||||
build/.Xmodmap: xmodmap/Xmodmap.org
|
build/.Xmodmap: xmodmap/Xmodmap.org
|
||||||
$(call tangle,fundamental)
|
$(call tangle,fundamental)
|
||||||
|
@ -104,10 +119,36 @@ x11/dot-x11-0-1-any.pkg.tar.xz: x11/PKGBUILD
|
||||||
# XDG #
|
# XDG #
|
||||||
#######
|
#######
|
||||||
|
|
||||||
xdg: xdg/.config/mimeapps.list xdg/.config/user-dirs.dirs \
|
xdg: build/.config/ build/.config/mimeapps.list build/.config/user-dirs.dirs \
|
||||||
xdg/.config/user-dirs.locale
|
build/.config/user-dirs.locale
|
||||||
|
|
||||||
|
build/.config/mimeapps.list: xdg/.config/mimeapps.list.org
|
||||||
|
$(call tangle)
|
||||||
|
|
||||||
|
build/.config/user-dirs.dirs: xdg/.config/user-dirs.dirs.org
|
||||||
|
$(call tangle)
|
||||||
|
|
||||||
|
build/.config/user-dirs.locale: xdg/.config/user-dirs.locale.org
|
||||||
|
$(call tangle)
|
||||||
|
|
||||||
|
# Shepherd
|
||||||
|
|
||||||
|
shepherd: build/.config/shepherd/ build/.config/shepherd/init.scm
|
||||||
|
|
||||||
|
build/.config/shepherd/init.scm: shepherd/.config/shepherd/init.org
|
||||||
|
$(call tangle)
|
||||||
|
|
||||||
# Helper
|
# Helper
|
||||||
|
|
||||||
|
%.el: %.org
|
||||||
|
$(call tangle,emacs-lisp)
|
||||||
|
|
||||||
|
%.elc: %.el
|
||||||
|
@echo -e "\e[36mELC\e[0m" $<
|
||||||
|
$(EMACS) -batch -f batch-byte-compile $<
|
||||||
|
|
||||||
%: %.org
|
%: %.org
|
||||||
$(call tangle)
|
$(call tangle)
|
||||||
|
|
||||||
|
%/:
|
||||||
|
mkdir -p $@
|
||||||
|
|
12
dotfiles.mk
12
dotfiles.mk
|
@ -1,12 +0,0 @@
|
||||||
EMACS = /usr/bin/emacs
|
|
||||||
SCHEME_IMPLEMENTATION = guile
|
|
||||||
|
|
||||||
define tangle =
|
|
||||||
@echo -e "\e[35mOBT\e[0m" $<
|
|
||||||
@$(EMACS) -batch \
|
|
||||||
-eval "(package-initialize)" \
|
|
||||||
-load ob-tangle \
|
|
||||||
-eval "(setq sh-make-vars-local nil)" \
|
|
||||||
-eval "(setq geiser-default-implementation '$(SCHEME_IMPLEMENTATION))" \
|
|
||||||
-eval "(org-babel-tangle-file \"$<\" \"$(notdir $@)\" \"$(1)\")"
|
|
||||||
endef
|
|
16
emacs/.config/shepherd/init.d/emacs.org
Normal file
16
emacs/.config/shepherd/init.d/emacs.org
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
Define a service for shepherd that starts up Emacs.
|
||||||
|
|
||||||
|
#+begin_src scheme
|
||||||
|
(define emacs
|
||||||
|
(make <service>
|
||||||
|
#:provides '(emacs)
|
||||||
|
#:docstring "Run `emacs --daemon'"
|
||||||
|
#:start (make-forkexec-constructor
|
||||||
|
'("emacs" "--fg-daemon")
|
||||||
|
#:log-file (string-append (getenv "HOME") "/.logs/emacs.log"))
|
||||||
|
#:stop (make-kill-destructor)))
|
||||||
|
|
||||||
|
(register-services emacs)
|
||||||
|
|
||||||
|
(start emacs)
|
||||||
|
#+end_src
|
13
shepherd/.config/shepherd/init.org
Normal file
13
shepherd/.config/shepherd/init.org
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[[info:shepherd][The Shepherd manual]] suggests that you use a single =init.scm=, but as is pointed out by this article about [[https://guix.gnu.org/en/blog/2020/gnu-shepherd-user-services/][GNU Shepherd user services]] it might be better to have the services in separate files so you can restart them individually if you make any changes to them. So I just put a loading script into =init.scm= that goes through the =init.d= directory and loads each service defined in there.
|
||||||
|
|
||||||
|
#+begin_src scheme
|
||||||
|
(use-modules (shepherd service)
|
||||||
|
((ice-9 ftw) #:select (scandir)))
|
||||||
|
|
||||||
|
(for-each
|
||||||
|
(λ (file) (load (string-append "init.d/" file)))
|
||||||
|
(scandir (string-append (dirname (current-filename)) "/init.d")
|
||||||
|
(λ (file) (string-suffix? ".scm" file))))
|
||||||
|
|
||||||
|
(action 'shepherd 'daemonize)
|
||||||
|
#+end_src
|
Loading…
Reference in a new issue