Hi,
Reza Housseini <reza.housseini@gmail.com> skribis:
I want to run a system command and use the output inside my ssh config
file. Below is the service configuration I'm talking about and my current
implementation which does not work, probably because the command is run
from the daemon, but I need it to run from the current user. Has anyone an
idea how to achieve this?
(simple-service 'ssh-config
home-files-service-type
(list `("ssh/config"
,(mixed-text-file "config" "
Host *
IdentityAgent " #~(system* #$(file-append gnupg "/bin/gpgconf")
"--list-dirs" "agent-ssh-socket")"
"))))
Instead of #~(system* …) above, you could do something like:
(let* ((pipe (open-input-pipe "gpgconf" …))
(data (get-string-all pipe)))
(close-pipe pipe)
data)
The effect will be that ‘gpgconf’ will run when you invoke ‘guix system
reconfigure’, as the user who invokes it. (You need the (ice-9 popen)
and (rnrs io bytevectors) modules.)
I can’t necessarily recommend it because it’s kinda wild, but it should
do the trick.
HTH,
Ludo’.