Hello, I'm trying to start redshift [0] as a shepherd service, and this is how I defined the redshift service in my /etc/config.scm: (define evry-geolocation "48.63681:2.42777") (define redshift-service (shepherd-service (provision '(redshift)) (requirement '(xorg-server)) (documentation "Start Redshift as a service") (start #~(make-forkexec-constructor `("redshift" "-l" ,evry-geolocation))) (stop #~(make-kill-destructor)))) However, I can't find a way to add this to the services field of the operating-system declaration. When I try: (services (append (list redshift-service (service xfce-desktop-service-type) (set-xorg-configuration (xorg-configuration (keyboard-layout keyboard-layout)))) %desktop-services)) I get the message "Wrong type argument #<<shepherd-service> ...". I understand that I should somehow construct a <service> (?) from my <shepherd-service>, but I don't see a way to do it. I've also seen a couple mailing list discussions [1,2] and a blog post [3] about doing what I want in "pure shepherd", i.e. independently of Guix, but these solutions seem to be doing more than what I need. How can I add a custom shepherd service to the operating-system definition in /etc/config.scm? - Sergiu [0] http://jonls.dk/redshift/ [1] https://lists.gnu.org/archive/html/guix-devel/2018-02/msg00047.html [2] https://www.mail-archive.com/guix-devel@gnu.org/msg46278.html [3] https://guix.gnu.org/blog/2020/gnu-shepherd-user-services/
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Sunday, January 24, 2021 8:09 PM, Sergiu Ivanov <sivanov@colimite.fr> wrote: > Hello, > > I'm trying to start redshift [0] as a shepherd service, and this is how > I defined the redshift service in my /etc/config.scm: > > (define evry-geolocation "48.63681:2.42777") > (define redshift-service > (shepherd-service > (provision '(redshift)) > (requirement '(xorg-server)) > (documentation "Start Redshift as a service") > (start #~(make-forkexec-constructor > `("redshift" "-l" ,evry-geolocation))) > (stop #~(make-kill-destructor)))) > > However, I can't find a way to add this to the services field of the > operating-system declaration. > > When I try: > > (services (append > (list redshift-service > (service xfce-desktop-service-type) > (set-xorg-configuration > (xorg-configuration (keyboard-layout keyboard-layout)))) > %desktop-services)) > > I get the message "Wrong type argument #<<shepherd-service> ...". > > I understand that I should somehow construct a <service> (?) from my > <shepherd-service>, but I don't see a way to do it. > > I've also seen a couple mailing list discussions [1,2] and a blog post > [3] about doing what I want in "pure shepherd", i.e. independently of > Guix, but these solutions seem to be doing more than what I need. > > How can I add a custom shepherd service to the operating-system > definition in /etc/config.scm? > > ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > Sergiu > > [0] http://jonls.dk/redshift/ > [1] https://lists.gnu.org/archive/html/guix-devel/2018-02/msg00047.html > [2] https://www.mail-archive.com/guix-devel@gnu.org/msg46278.html > [3] https://guix.gnu.org/blog/2020/gnu-shepherd-user-services/ Hi Sergiu, I recently made my redshift configuration using shepherd user services, which is what people in IRC recommended me. You can find it here: https://github.com/ekaitz-zarraga/dotfiles/tree/guix/shepherd/shepherd Also, it forces me to run the shepherd as a user using my i3 config. I also wanted to configure it in my config.scm file but people convinced me not to do so. I'm not sure why your case shouldn't work though. Best, Ekaitz
Hi Ekaitz, Thank you for your very fast answer! Thus quoth Ekaitz Zarraga on Sun Jan 24 2021 at 20:19 (+0100): > > I recently made my redshift configuration using shepherd user > services, which is what people in IRC recommended me. > > You can find it here: > https://github.com/ekaitz-zarraga/dotfiles/tree/guix/shepherd/shepherd I see, this is what I saw here as well https://guix.gnu.org/blog/2020/gnu-shepherd-user-services/ , but I didn't know whether I should prefer this solution over other possibilities. > Also, it forces me to run the shepherd as a user using my i3 config. OK, so I note that I'll have to include shepherd in my startup scripts. > I also wanted to configure it in my config.scm file but people > convinced me not to do so. Ah, interesting, good to know. Thank you for the feedback! > I'm not sure why your case shouldn't work though. Maybe somebody here will have the time to explain the details, but for the time being I will go with your solution, as it has the benediction of the IRC herd :-) - Sergiu > Best, > Ekaitz
Hi Sergiu!
On Mon, Jan 25 2021, Sergiu Ivanov wrote:
> I understand that I should somehow construct a <service> (?)
> from my <shepherd-service>, but I don't see a way to do it.
Unfortunately Guix overloads the word "service", where we have (a)
services that consist of structured modifications to an operating
system, and (b) shepherd services that define a process that will
run on the resulting system. Shepherd services cannot be used
directly, but need to be added to an instance of the
shepherd-root-service-type service. The easiest way to do this is
to use simple-service (documented in "(guix) Service Reference" in
the manual).
Putting it together, this should return a service object which
runs your redshift shepherd service:
(simple-service 'redshift-service 'shepherd-root-service-type
(list redshift-service))
I hope that helps!
Carlo
Hi Carlo, Thanks a lot for your answer ! Thus quoth Carlo Zancanaro on Sun Jan 24 2021 at 23:25 (+0100): > On Mon, Jan 25 2021, Sergiu Ivanov wrote: >> I understand that I should somehow construct a <service> (?) from my >> <shepherd-service>, but I don't see a way to do it. > > Unfortunately Guix overloads the word "service", where we have (a) > services that consist of structured modifications to an operating > system, and (b) shepherd services that define a process that will run > on the resulting system. A-ha, OK, I vaguely felt this distinction, but I wasn't sure. > Shepherd services cannot be used directly, but need to be added to an > instance of the shepherd-root-service-type service. The easiest way to > do this is to use simple-service (documented in "(guix) Service > Reference" in the manual). > > Putting it together, this should return a service object which runs > your redshift shepherd service: > > (simple-service 'redshift-service 'shepherd-root-service-type (list > redshift-service)) > > I hope that helps! This helped indeed: my redshift-service got integrated into the system service tree. You solved my frustration: I thought I understood almost everything I needed from the documentation, but I couldn't put the pieces together. Invoking simple-service in this way made the pieces click; I'm happy. Still, I'll go with Shepherd user services: https://guix.gnu.org/blog/2020/gnu-shepherd-user-services/ Running redshift as a system service, even as my user, prevents it from easily detecting my X session. Also, I realized that I could even run mcron as a user service, which actually makes several things somewhat easier. I initially hoped to cram as much as I could into /etc/config.scm (in particular because guix-home-manager looks a lot less evolved than Nix's home-manager (and that's an opportunity to contribute, but I need to get a better grasp on Guix first)), but after all having a couple user files written in Guile is not a big issue, because the uniformity of the configuration language is more important for me. - Sergiu