diff options
author | Tom Willemse | 2022-03-06 15:11:45 -0800 |
---|---|---|
committer | Tom Willemse | 2022-05-10 19:38:02 -0700 |
commit | 2313102c2bc5161e0d82a753b0f614e539e37eca (patch) | |
tree | d5a25d39c926be476994bbb6ad5e9dd56d80eac7 /shepherd/.config | |
parent | 13f4427ed91fa85d683242f04c1a3a421633c8b4 (diff) | |
download | new-dotfiles-2313102c2bc5161e0d82a753b0f614e539e37eca.tar.gz new-dotfiles-2313102c2bc5161e0d82a753b0f614e539e37eca.zip |
[shepherd] Fix init file
‘current-filename’ is the real file name of the file, not the symbolic link that
it's accessed through, so any relative references will be wrong.
Diffstat (limited to 'shepherd/.config')
-rw-r--r-- | shepherd/.config/shepherd/init.scm.org | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/shepherd/.config/shepherd/init.scm.org b/shepherd/.config/shepherd/init.scm.org index 05c9d6e..ef21166 100644 --- a/shepherd/.config/shepherd/init.scm.org +++ b/shepherd/.config/shepherd/init.scm.org @@ -1,13 +1,28 @@ [[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))) + (use-modules (shepherd service) + ((ice-9 ftw) #:select (scandir))) +#+end_src + +I can't use ~(current-filename)~ here because this file will be symlinked into the =$XDG_CONFIG_DIR/shepherd/init.scm= and the =current-filename= function will return the actual path, not the path of the symbolic link. + +#+begin_src scheme + (define init-directory + (string-append (getenv "XDG_CONFIG_HOME") "/shepherd/init.d")) +#+end_src -(for-each - (λ (file) (load (string-append "init.d/" file))) - (scandir (string-append (dirname (current-filename)) "/init.d") - (λ (file) (string-suffix? ".scm" file)))) +With that in place, we can loop over each =*.scm= file in the =init-directory= and load them. -(action 'shepherd 'daemonize) +#+begin_src scheme + (for-each + (λ (file) (load (string-append "init.d/" file))) + (scandir init-directory + (λ (file) (string-suffix? ".scm" file)))) +#+end_src + +Now turn shepherd into a daemon. + +#+begin_src scheme + (action 'shepherd 'daemonize) #+end_src |