all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Reza Housseini <reza.housseini@gmail.com>
Cc: help-guix@gnu.org
Subject: Re: Run a system command in home configuration file
Date: Tue, 08 Mar 2022 11:33:17 +0100	[thread overview]
Message-ID: <87bkyg7mz6.fsf@gnu.org> (raw)
In-Reply-To: <CAGZc64GstfCeoatRXeMvB-38gHNbyEFRb7ZTeZKUbjxcJ60Jrg@mail.gmail.com> (Reza Housseini's message of "Fri, 25 Feb 2022 11:08:23 +0100")

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


  reply	other threads:[~2022-03-08 10:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 10:08 Run a system command in home configuration file Reza Housseini
2022-03-08 10:33 ` Ludovic Courtès [this message]
2022-03-08 14:38   ` Reza Housseini
2022-03-09  7:37     ` Efraim Flashner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bkyg7mz6.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=help-guix@gnu.org \
    --cc=reza.housseini@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.