* Auto-start service
@ 2021-07-08 22:28 excalamus--- via
2021-07-09 12:21 ` Ekaitz Zarraga
2021-07-09 21:03 ` jbranso
0 siblings, 2 replies; 7+ messages in thread
From: excalamus--- via @ 2021-07-08 22:28 UTC (permalink / raw)
To: Help Guix
I'm setting up the Emacs daemon following a thread on the mailing list: https://lists.gnu.org/archive/html/help-guix/2019-11/msg00148.html. I have services.scm and init.scm defined. I can call `shepherd -c ~/.config/shepherd/init.scm` and the service starts. I can kill the terminal and connect a client with `emacsclient -c`. Trouble is, I can't figure out how to start the service on boot.
The config files I'm using are:
;; services.scm
(define emacsd
(make <service>
#:provides '(emacsd)
#:start (make-system-constructor "emacs --daemon")
#:stop (make-system-destructor "emacsclient --eval \"(kill-emacs)\"")))
;; init.scm
;;; Shepherd User Services
(load "/home/ahab/.config/shepherd/services.scm")
(register-services
emacsd)
;; Send shepherd into the background.
(action 'shepherd 'daemonize)
;; Services to start when shepherd starts:
(for-each start '(emacsd))
Based on what (shepherd) Jump Start paragraph 3 says, I'm confused about why Shepard doesn't find the config files. Is it because Shepherd starts as superuser on boot?
Meanwhile, I was advised to define a service in my config. I'm in the process of reading the documentation (really, figuring out how to set Geiser up to read the documentation) so that I can understand the relevant parts. Is the config the generally recommended approach for Guix SD versus the $HOME/.config/shepherd directory?
Surely someone else has set up an Emacs daemon service? The linked thread mentioned this being a good idea for a cookbook recipe. I'd be happy to contribute to that as I'm confident I'm not alone in wanting an Emacs daemon service defined.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Auto-start service
2021-07-08 22:28 Auto-start service excalamus--- via
@ 2021-07-09 12:21 ` Ekaitz Zarraga
2021-07-10 4:13 ` excalamus--- via
2021-07-09 21:03 ` jbranso
1 sibling, 1 reply; 7+ messages in thread
From: Ekaitz Zarraga @ 2021-07-09 12:21 UTC (permalink / raw)
To: excalamus; +Cc: Help Guix
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, July 9th, 2021 at 12:28 AM, excalamus--- via <help-guix@gnu.org> wrote:
> I'm setting up the Emacs daemon following a thread on the mailing list: https://lists.gnu.org/archive/html/help-guix/2019-11/msg00148.html. I have services.scm and init.scm defined. I can call `shepherd -c ~/.config/shepherd/init.scm` and the service starts. I can kill the terminal and connect a client with `emacsclient -c`. Trouble is, I can't figure out how to start the service on boot.
>
> The config files I'm using are:
>
> ;; services.scm
>
> (define emacsd
>
> (make <service>
>
> #:provides '(emacsd)
>
> #:start (make-system-constructor "emacs --daemon")
>
> #:stop (make-system-destructor "emacsclient --eval \"(kill-emacs)\"")))
>
> ;; init.scm
>
> ;;; Shepherd User Services
>
> (load "/home/ahab/.config/shepherd/services.scm")
>
> (register-services
>
> emacsd)
>
> ;; Send shepherd into the background.
>
> (action 'shepherd 'daemonize)
>
> ;; Services to start when shepherd starts:
>
> (for-each start '(emacsd))
>
> Based on what (shepherd) Jump Start paragraph 3 says, I'm confused about why Shepard doesn't find the config files. Is it because Shepherd starts as superuser on boot?
>
> Meanwhile, I was advised to define a service in my config. I'm in the process of reading the documentation (really, figuring out how to set Geiser up to read the documentation) so that I can understand the relevant parts. Is the config the generally recommended approach for Guix SD versus the $HOME/.config/shepherd directory?
>
> Surely someone else has set up an Emacs daemon service? The linked thread mentioned this being a good idea for a cookbook recipe. I'd be happy to contribute to that as I'm confident I'm not alone in wanting an Emacs daemon service defined.
There's a blog post in Guix's blog about this configuration:
https://guix.gnu.org/en/blog/2020/gnu-shepherd-user-services/
I remember to have followed that and I have it working. I had to activate the user-level Shepherd by hand in any file that is executed when the system is started. In my case I have it in my i3 config. You can put it in .xsession like the thread you shared suggests.
Hope this helps.
Ekaitz
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Auto-start service
2021-07-08 22:28 Auto-start service excalamus--- via
2021-07-09 12:21 ` Ekaitz Zarraga
@ 2021-07-09 21:03 ` jbranso
2021-07-10 4:15 ` excalamus--- via
2021-07-10 19:53 ` jbranso
1 sibling, 2 replies; 7+ messages in thread
From: jbranso @ 2021-07-09 21:03 UTC (permalink / raw)
To: excalamus, Help Guix
July 8, 2021 6:29 PM, "excalamus--- via" <help-guix@gnu.org> wrote:
> Meanwhile, I was advised to define a service in my config. I'm in the process of reading the
> documentation (really, figuring out how to set Geiser up to read the documentation) so that I can
> understand the relevant parts. Is the config the generally recommended approach for Guix SD versus
> the $HOME/.config/shepherd directory?
When Guix Home is merged, you could probably define much of your user services in your home.scm file.
> Surely someone else has set up an Emacs daemon service? The linked thread mentioned this being a
> good idea for a cookbook recipe. I'd be happy to contribute to that as I'm confident I'm not alone
> in wanting an Emacs daemon service defined.
I'd be happy to help you write a cookbook recipe. I've written a few cookbook sections, and I'd be
happy to help you with the markup. :)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Auto-start service
2021-07-09 12:21 ` Ekaitz Zarraga
@ 2021-07-10 4:13 ` excalamus--- via
0 siblings, 0 replies; 7+ messages in thread
From: excalamus--- via @ 2021-07-10 4:13 UTC (permalink / raw)
To: Ekaitz Zarraga; +Cc: Help Guix
> I had to activate the user-level Shepherd by hand in any file that is executed when the system is started. In my case I have it in my i3 config. You can put it in .xsession like the thread you shared suggests.
>
*expletives* Call 'shepherd'. That's it. Call 'shepherd'. Goodness gracious...thank you.
I see now the docs mention this. Yet, because user error (pun intended) is never my fault (sarcasm), I wonder if the docs might express it more clearly.
The information I overlooked is that Shepherd may (and likely will) be run concurrently by two or more users (e.g. 'root' and 'Joe Shmoe').
The relevant docs are:
1. The (shepherd) Introduction says,
"""The Shepherd is the “init system” of the GNU operating system—it is the first user process that gets started, typically with PID 1, and runs as ‘root’."""
I believe the phrase "the first user process" might be better as "the first process".
Are there processes which are not "user processes" within userland? The kernel starts the init process (i.e. Shepherd). However, because users can access it as 'root', it can be considered a userland process. Therefore, the edit could happen without loss of meaning.
When reading the phrase "the first user process", the word "user" stuck with me. Maybe I read too much Hacker News, but when developers speak of "users", I interpret it as "a non-developer or someone without access to controls, such as admin privileges". I read "user" and thought of "unprivileged", despite the sentence literally saying Shepherd runs as 'root'!
2. The (shepherd) Jump Start says,
"""When ‘shepherd’ gets started, it reads and evaluates a configuration file. When it is started with superuser privileges, it tries to use ‘/etc/shepherd.scm’. When started as normal user, it looks for a file called ‘$XDG_CONFIG_HOME/shepherd/init.scm’. If the ‘XDG_CONFIG_HOME’ environment variable is not defined, ‘$HOME/.config/shepherd/init.scm’ is used instead. With the option ‘--config’ (or, for short, ‘-c’), you can specify where to look instead. So if you want to start ‘shepherd’ with an alternative file, use one of the following commands:
shepherd --config=/etc/shepherd.scm.old
shepherd -c /etc/shepherd.scm.old
"""
I followed the first and second paragraphs well enough. I placed my init.scm in the 'normal user' location. I expressly didn't put it in /etc/shepherd.scm because I knew I was non-root. Although Shepherd starts on init, I overlooked that it's *not* started for unprivileged users.
Expecting Shepherd to auto-start for unprivileged users comes, in part, from my experience with systemd. On Debian, I recall being able to run `systemctl --user restart emacsd` without sudo. There's the --user option, sure. However, I could manage a service as a non-privileged user and didn't explicitly need to start systemd. Is there a reason why Shepherd must be explicitly started as a non-privileged user?
This expectation, and the confusion, was reinforced by the paragraph immediately following in the docs,
"""As the final “d” suggests, ‘shepherd’ is just a daemon that (usually) runs in the background, so you will not interact with it directly. After it is started, ‘shepherd’ will listen on a socket special file, usually ‘/var/run/shepherd/socket’, for further commands. You use the tool “herd” to send these commands to ‘shepherd’."""
The important fact that Shepherd must be 1) started by an unprivileged user 2) using the 'shepherd' command is hidden in the conjunction(?) "After it is started". The manual emphasizes to use 'herd' and that interacting with Shepherd through the 'shepherd' command is unusual. Yet, isn't starting Shepherd as a regular user with 'shepherd' the usual approach?
This again begs the question, why isn't Shepherd started for non-privileged users?
3. Section (shepherd) herd and shepherd says,
"""Thus, you start ‘shepherd’ once, and then always use herd whenever
you want to do something service-related."""
Looking at it now, I see this describes a procedure:
1. Run 'shepherd'
2. Always use 'herd'
It's not mentioned that 'shepherd' isn't automatically started for non-privileged users. The sentence is also buried in Section 3. Section 2 explicitly says, "It [Section 2] is enough if
you just need the basic features of it [Shepherd]". Is it enough?
I'm happy to provide language suggestions for improving the docs. I feel I need to understand things a little better first. Maybe the manual needs to clarify that 'shepherd' must be run by non-privileged users before they can use services and 'herd'? Maybe 'shepherd' should be setup to automatically run for non-privileged users so that 'herd' is available immediately?
Thoughts?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Auto-start service
2021-07-09 21:03 ` jbranso
@ 2021-07-10 4:15 ` excalamus--- via
2021-07-10 19:53 ` jbranso
1 sibling, 0 replies; 7+ messages in thread
From: excalamus--- via @ 2021-07-10 4:15 UTC (permalink / raw)
To: jbranso; +Cc: Help Guix
> When Guix Home is merged, you could probably define much of your user services in your home.scm file.
>
Where is the best place to keep an eye on this? Is there a dedicated branch?
> I'd be happy to help you write a cookbook recipe. I've written a few cookbook sections, and I'd be happy to help you with the markup. :)
>
Thank you, I'd like that.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Auto-start service
2021-07-09 21:03 ` jbranso
2021-07-10 4:15 ` excalamus--- via
@ 2021-07-10 19:53 ` jbranso
2021-07-10 23:18 ` excalamus--- via
1 sibling, 1 reply; 7+ messages in thread
From: jbranso @ 2021-07-10 19:53 UTC (permalink / raw)
To: excalamus; +Cc: Help Guix
July 10, 2021 12:15 AM, excalamus@tutanota.com wrote:
>> When Guix Home is merged, you could probably define much of your user services in your home.scm
>> file.
>
> Where is the best place to keep an eye on this? Is there a dedicated branch?
https://sr.ht/~abcdw/rde/
https://lists.sr.ht/~abcdw/rde-discuss/%3CCABrWRW2xCCbWSE3DAcWns01CmDyoGVAywL6dwyQoAENTrUZqhw%40mail.gmail.com%3E
There was some rumblings in the guix-devel mailing list as well. Apparently Ludo has tried it out!
>> I'd be happy to help you write a cookbook recipe. I've written a few cookbook sections, and I'd be
>> happy to help you with the markup. :)
>
> Thank you, I'd like that.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Auto-start service
2021-07-10 19:53 ` jbranso
@ 2021-07-10 23:18 ` excalamus--- via
0 siblings, 0 replies; 7+ messages in thread
From: excalamus--- via @ 2021-07-10 23:18 UTC (permalink / raw)
To: Jbranso; +Cc: Help Guix
> https://sr.ht/~abcdw/rde/
> https://lists.sr.ht/~abcdw/rde-discuss/%3CCABrWRW2xCCbWSE3DAcWns01CmDyoGVAywL6dwyQoAENTrUZqhw%40mail.gmail.com%3E>
>
Cool, glad I asked. Looks like one of the two people doing videos about Guix. Thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-07-10 23:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-08 22:28 Auto-start service excalamus--- via
2021-07-09 12:21 ` Ekaitz Zarraga
2021-07-10 4:13 ` excalamus--- via
2021-07-09 21:03 ` jbranso
2021-07-10 4:15 ` excalamus--- via
2021-07-10 19:53 ` jbranso
2021-07-10 23:18 ` excalamus--- via
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.