Subject: Re: bug#77220: [shepherd]: Timers do not set HOME environment variable correctly

From: Ludovic Courtès <[email-masked]>
Date: Tue, 01 Apr 2025 12:18:19 +0200

Hi Tomas,

Tomas Volf <[email-masked]> skribis:

> In case anyone runs into this bug, below is a full version I ended up
> using (user, group, environment-variables are arguments to the wrapping
> function).
>
> #:user #$user
> #:group #$group
> #:environment-variables
> (let ((pw (getpw (or #$user (getuid)))))
>   (cons* (string-append "HOME=" (passwd:dir pw))
>          (string-append "USER=" (passwd:name pw))
>          (remove (lambda (x)
>                    (or (string-prefix? "HOME=" x)
>                        (string-prefix? "USER=" x)))
>                  (or '#$environment-variables
>                      (default-environment-variables)))))

What would be nice is to provide in (shepherd support) or similar a
‘home-environment-variables’ procedure (or similar) that would add HOME=
and USER= to the given list of environment variables.

That would avoid duplication of the boilerplate above.

If you’d like to submit such a patch, it’d be welcome!

Thanks,
Ludo’.