wip: let olivetin access specific things

This commit is contained in:
Ranomier 2025-06-04 22:42:23 +02:00
parent abdddf1ba4
commit 0b79642f7e

View file

@ -1,19 +1,64 @@
{ pkgs, ... }: { { pkgs, lib, ... }: let
_pull = pkgs.writeShellScript "pull" ''
export GIT_SSH_COMMAND='ssh -i /var/lib/minetest/.ssh/id_ed25519_temp -o IdentitiesOnly=yes'
git -C /var/lib/minetest/.minetest/games/EinsDreiDreiSieben pull
'';
pull = _pull.outPath;
_restart = pkgs.writeShellScript "restart" ''
echo "before"
systemctl restart minetest-server.service
echo "after"
'';
restart = _restart.outPath;
in {
users.users."minetest".linger = true;
services.olivetin = { services.olivetin = {
enable = true; enable = true;
settings = { settings = {
actions = [ actions = [
{ {
title = "Hello world!"; title = "puuuull!";
shell = "echo 'Hello World!'"; shell = "/run/wrappers/bin/sudo -u minetest - ${pull}";
popupOnStart = "execution-dialog-stdout-only"; popupOnStart = "execution-dialog-stdout-only";
icon = "⬇";
}
{
title = "restart";
shell = "/run/wrappers/bin/sudo -u minetest - ${restart}";
popupOnStart = "execution-dialog-stdout-only";
icon = "⬇";
} }
]; ];
}; };
path = with pkgs; [ path = [
bash pkgs.git
git pkgs.openssh
]; ];
}; };
security.sudo-rs.extraRules = [
{
users = [ "olivetin" ];
runAs = "minetest";
commands = [
{
command = pull;
options = [ "NOPASSWD" ];
}
];
}
{
users = [ "olivetin" ];
runAs = "root";
commands = [
{
command = restart;
options = [ "NOPASSWD" ];
}
];
}
];
} }