Mysql: allow user to start/stop service
This commit is contained in:
parent
e67ace042d
commit
c47e8216d5
1 changed files with 15 additions and 0 deletions
|
|
@ -11,5 +11,20 @@
|
||||||
# Don't autostart MySQL
|
# Don't autostart MySQL
|
||||||
systemd.services.mysql.wantedBy = lib.mkForce [];
|
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 ];
|
environment.systemPackages = [ pkgs.mysql-workbench ];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue