[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Run a system command in home configuration file
From: |
Ludovic Courtès |
Subject: |
Re: Run a system command in home configuration file |
Date: |
Tue, 08 Mar 2022 11:33:17 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
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’.
- Re: Run a system command in home configuration file,
Ludovic Courtès <=