Re: Run a system command in home configuration file

2022-03-08 Thread Efraim Flashner
On Tue, Mar 08, 2022 at 03:38:19PM +0100, Reza Housseini wrote:
> 
> On 3/8/22 11:33, Ludovic Courtès wrote:
> > Hi,
> > 
> > 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
> > >   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.
> > 
> 
> 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?
> 

One option is a one-off shepherd service. For finding the
SSH_AUTH_SOCKET using gpgconf I stuck with the tried and true method of
setting it in .bash_profile¹.

¹ https://git.sr.ht/~efraim/guix-config/tree/master/item/efraim-home.scm#L694

-- 
Efraim Flashner  אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted


signature.asc
Description: PGP signature


Re: Run a system command in home configuration file

2022-03-08 Thread Reza Housseini



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

Hi,

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
  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’.



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?


Cheers,

Reza




Re: Run a system command in home configuration file

2022-03-08 Thread Ludovic Courtès
Hi,

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
>  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’.



Run a system command in home configuration file

2022-02-25 Thread Reza Housseini
Hello guix

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") "
"

Thanks and cheers,
Reza