From: "Clément Lassieur" <clement@lassieur.org>
To: Richard Sent <richard@freakingpenguin.com>
Cc: help-guix@gnu.org
Subject: Re: Using gexps in wireguard-service-type postup
Date: Sun, 28 Jan 2024 15:04:32 +0100 [thread overview]
Message-ID: <87wmrttuz3.fsf@lassieur.org> (raw)
In-Reply-To: <93b89074d790b8554de4c10434fc6be2@freakingpenguin.com> (Richard Sent's message of "Sat, 27 Jan 2024 21:19:54 -0500")
Hi Richard,
On Sat, Jan 27 2024, Richard Sent wrote:
> Hi all,
>
> I'm trying to create a wireguard service, but I've encountered an issue
> that I'm pretty sure I can only resolve using gexps and am having
> trouble with the syntax (or if it's even possible to use them in this
> case).
>
> I want to fetch my private key from password-store when running the
> service, and a PostUp command seems the best way of implementing
> that. Using the wg-quick manual as a base, I get a naive solution like:
I think, here you can just add
(use-modules (gnu packages admin))
> (define* (get-secret-command key #:optional (user (sudo-user)))
> "Returns the shell command needed to read KEY from USER."
> (string-append "sudo -u " user " pass ls " key))
>
> (service wireguard-service-type
> (wireguard-configuration
(private-key (file-append sudo "/bin/sudo -u user <(pass ...)"))
which would be se same as
(private-key #~(string-append #$sudo "/bin/sudo -u user <(pass ...)"))
> ...
> (post-up (list
> ;; Returns "wg set wg-nickleslan private-key <(sudo pass
> ;; ls wireguard-nickleslan-private-key-key)"
> (string-append "wg set " interface " private-key <("
> (get-secret-command
> wireguard-nickleslan-private-key-key) ")")
> (string-append "wg set " interface " peer "
> wireguard-nickleslan-public-key
> " preshared-key <("
> (get-secret-command
> wireguard-nickleslan-preshared-key-key) ")")))))
This will add another "PostUp" field.
Clément
next prev parent reply other threads:[~2024-01-28 14:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-28 2:19 Using gexps in wireguard-service-type postup Richard Sent
2024-01-28 12:51 ` Marek Paśnikowski
2024-01-28 14:04 ` Clément Lassieur [this message]
2024-01-28 18:36 ` Richard Sent
2024-01-28 22:59 ` Clément Lassieur
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wmrttuz3.fsf@lassieur.org \
--to=clement@lassieur.org \
--cc=help-guix@gnu.org \
--cc=richard@freakingpenguin.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).