unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
Cc: 43921@debbugs.gnu.org, Efraim Flashner <efraim@flashner.co.il>
Subject: [bug#43921] [PATCH v3 2/2] Add User Service example.
Date: Fri, 23 Oct 2020 15:31:27 +0200	[thread overview]
Message-ID: <87h7qlnk5s.fsf@gnu.org> (raw)
In-Reply-To: <20201012051536.1609-1-janneke@gnu.org> (Jan Nieuwenhuizen's message of "Mon, 12 Oct 2020 07:15:36 +0200")

Hello!

"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:

> * modules/shepherd/support.scm: Export %user-cache-dir, %user-config-dir,
> %user-runtime-dir.
> * doc/shepherd.texi (User Service examples): Use them in new subsection with
> example.
>
> Co-authored-by: Efraim Flashner <efraim@flashner.co.il>

Good idea!

> +@menu
> +* User Service examples::
> +@end menu
> +
> +@node User Service examples
> +@subsection User Service examples

The subsection looks lonely.  :-)  How about making it a section, at the
same level as “Service Examples”?

Also, since “user services” are no different than “non-user” services,
perhaps the focus should be on using the Shepherd as an unprivileged
user.  Thus, I’d suggest calling the section “Managing User Services”,
or “Running the Shepherd as a User”, which do not imply that “user
services” are a new concept.

WDYT?

> +For starters, use a toplevel @code{$XDG_CONFIG_HOME/shepherd/init.scm}
> +that looks like this:

Maybe: “… we suggest the following top-level
@file{$XDG_CONFIG_HOME/shepherd/init.scm} file, which will automatically
load individual service definitions from
@file{~/.config/shepherd/init.d}:”

> +@lisp
> +;;; Commentary:
> +;;;
> +;;; Add to your ~/.bash_profile:
> +;;;
> +;;; if [[ ! -S ${XDG_RUNTIME_DIR-$HOME/.cache}/shepherd/socket ]]; then
> +;;;     shepherd
> +;;; fi

Maybe make it a paragraph in the text, above the ‘init.scm’ example:

  First, to use the Shepherd as an unprivileged user, you may want to
  ensure it is up and running every time you log in.  One way to
  accomplish that is by adding the following lines to @file{~/.bashrc}
  (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):

  …

> +Then, individual user services can be put in
> +@code{$XDG_CONFIG_HOME/shepherd/init.d/}, e.g., for ssh-agent

@command{ssh-agent} and period.  :-)

> +@lisp
> +;;; Commentary:
> +;;;
> +;;; Add to your ~/.bash_profile:
> +;;;
> +;;; SSH_AUTH_SOCK=${XDG_RUNTIME_DIR-$HOME/.cache}/ssh-agent/socket
> +;;; export SSH_AUTH_SOCK
> +;;;
> +;;; Code:
> +
> +(use-modules (shepherd support))
> +
> +(define ssh-agent
> +  (make <service>
> +    #:provides '(ssh-agent)
> +    #:docstring "Run `ssh-agent'"
> +    #:start (let ((socket-dir (string-append %user-runtime-dir "/ssh-agent")))
> +              (unless (file-exists? socket-dir)
> +                (mkdir-p socket-dir)
> +                (chmod socket-dir #o700))
> +              (make-forkexec-constructor
> +               `("ssh-agent" "-D" "-a" ,(string-append socket-dir "/socket"))
> +               #:log-file (string-append %user-cache-dir "/ssh-agent.log")))

This is misleading because the code to create the socket directory runs
from the top-level, i.e., when shepherd starts.  I’d write:

  #:start (lambda ()
            ;; make socket dir
            (fork+exec-command … #:log-file …))

(BTW, I use ‘gnupg-agent’, which I think is pretty nice because it’s
integrated with pinentry and all.  I run it as:

  eval `gpg-agent --daemon --enable-ssh-support`

… from ~/.xsession.)

Thanks,
Ludo’.




  reply	other threads:[~2020-10-23 13:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-11  9:40 [bug#43921] [Shepherd PATCH 0/2] Add User Service example Jan Nieuwenhuizen
2020-10-11  9:43 ` [bug#43921] [Shepherd PATCH 1/2] Use XDG_CACHE_HOME/shepherd for unprivileged users' log directory Jan (janneke) Nieuwenhuizen
2020-10-11  9:43   ` [bug#43921] [Shepherd PATCH 2/2] Add User Service example Jan (janneke) Nieuwenhuizen
2020-10-11 10:38     ` Jan Nieuwenhuizen
2020-10-11 12:10 ` [bug#43921] [Shepherd PATCH v2 " Jan (janneke) Nieuwenhuizen
2020-10-12  5:15 ` [bug#43921] [PATCH v3 " Jan (janneke) Nieuwenhuizen
2020-10-23 13:31   ` Ludovic Courtès [this message]
2020-10-23 16:37     ` Jan Nieuwenhuizen
2020-11-18 21:37       ` bug#43921: " Ludovic Courtès
2020-11-19  6:00         ` [bug#43921] " Jan Nieuwenhuizen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7qlnk5s.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=43921@debbugs.gnu.org \
    --cc=efraim@flashner.co.il \
    --cc=janneke@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).