Mysql: allow user to start/stop service

This commit is contained in:
Toast 2023-10-06 10:26:03 +02:00
parent e67ace042d
commit c47e8216d5

View file

@ -11,5 +11,20 @@
# Don't autostart MySQL
systemd.services.mysql.wantedBy = lib.mkForce [];
# Allow regular users to start/stop mysql
# https://stackoverflow.com/questions/61480914/using-policykit-to-allow-non-root-users-to-start-and-stop-a-service
security.polkit.extraConfig = ''
polkit.addRule(function(action, subject) {
if (
action.id == "org.freedesktop.systemd1.manage-units" &&
action.lookup("unit") == "mysql.service" &&
subject.user == "${config.services.mysql.user}"
)
{
return polkit.Result.YES;
}
})
'';
environment.systemPackages = [ pkgs.mysql-workbench ];
}