nix-stuff/roles/school/services/mysql.nix
2023-10-09 20:32:42 +02:00

33 lines
751 B
Nix

{ config, pkgs, lib, ... }:
{
services.mysql = {
enable = true;
package = pkgs.mysql80;
user = "toast";
group = "users";
};
# 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 = with pkgs; [
mysql-workbench
mycli
];
}