Hi, Tomas Volf <~@wolfsden.cz> skribis:
> Would something like the attached work? I placed the procedure directly > into the (shepherd service) module, since the point is to reduce > boilerplate, I thought it better to not having to specify (modules > '((shepherd support))) every time someone wants to use it, but I can > move it if you prefer. Yeah, it’s fine this way. > +@deffn {Procedure} user-environment-variables @ > + [name-or-id (getuid)] @ > + [environment-variables (default-environment-variables)] > + > +Take the list of environment variables, replace @env{HOME} with home “Take the list @var{environment-variables}, …” > +(define-module (test-service) > + #:use-module (shepherd service) > + #:use-module (srfi srfi-64)) > + > + > +(test-begin "user-environment-variables") (test-begin "service"), to create ‘service.log’. > +(let ((environment-variables '("USER=foo" > + "HOME=/foo" > + "USER=bar" > + "HOME=/bar"))) > + ;; Pretty much any system should have root in /etc/passwd. > + (test-equal "name sets variables" > + '("HOME=/root" "USER=root") > + (user-environment-variables "root" environment-variables)) Use (passwd:name (getpwuid (getuid))) rather than “root” because /etc/passwd in the Guix build environment does not have “root”. (You can test with ‘guix build -f guix.scm’.) OK with these changes, thank you! Ludo’.