[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Run a system command in home configuration file

From: Reza Housseini
Subject: Re: Run a system command in home configuration file
Date: Tue, 8 Mar 2022 15:38:19 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1

On 3/8/22 11:33, Ludovic Courtès wrote:

Reza Housseini <> 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
  (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)

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.


Hi Ludo

Thanks for the reply, it really looks kinda wild :)

Isn't there a general need to run certain commands for  specific user especially in the context of guix home?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]