From: heat from fire via <help-guix@gnu.org>
To: "help-guix@gnu.org" <help-guix@gnu.org>
Subject: Creating a service that runs a user-installed package as root
Date: Tue, 15 Aug 2023 19:16:11 -0500 (EST) [thread overview]
Message-ID: <1987440433.302101.1692144971020@office.mailbox.org> (raw)
Hi all,
First time posting on this forum.
I am trying to set up a service that runs "sudo mullvad-daemon" upon user login. The mullvad package is installed through Nix on a user profile.
I've tried creating a user service using Shepherd in a config file at "~/.config/shepherd/init.scm", but it doesn't seem possible to run the command as root.
Here's a snippet from the file:
(define mullvad
(service '(mullvad)
#:respawn? #t
#:start (make-forkexec-constructor '("mullvad-daemon" "-v"))
#:stop (make-kill-destructor)))
I read through here in hopes to find a solution, but to no avail:
https://www.gnu.org/software/shepherd/manual/shepherd.html#Services
Perhaps there is a service constructor with an option to run the command as root?
I know that I can define a Shepherd service in my system config file, which runs the command in it as root, but given that it depends on a user-installed Nix package, I'm not sure how I'll have to accommodate for that. The command is located at /home/user/.nix-profile/bin/mullvad-daemon.
I also tried creating a regular system service using service-type, but couldn't get it to work.
My only other alternative is to run sudo mullvad-daemon in ~/.profile and make an exception in the sudoers file to not require a password. This solution is messy so I wanna try to avoid it. I could also put the command in the Guix equivalent of "/etc/rc.local", but I don't think there is one in Guix.
Any ideas on how I can create a service that runs a command installed in a user profile as root? Or alternatively, a better way to run a command as root without password on user login, after sourcing ~/.profile?
Thanks!
next reply other threads:[~2023-08-29 7:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-16 0:16 heat from fire via [this message]
2023-08-29 13:19 ` Creating a service that runs a user-installed package as root wolf
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=1987440433.302101.1692144971020@office.mailbox.org \
--to=help-guix@gnu.org \
--cc=senkowo@mailbox.org \
/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).