module.nix: render config to /etc

This commit is contained in:
2025-11-09 20:27:36 +09:00
parent 45fbec1ad4
commit a57eefa5be

View File

@@ -79,12 +79,13 @@ in
}; };
}; };
config = let config = lib.mkIf config.services.mysqladm-rs.enable {
nullStrippedConfig = lib.filterAttrsRecursive (_: v: v != null) cfg.settings;
configFile = format.generate "mysqladm-rs.conf" nullStrippedConfig;
in lib.mkIf config.services.mysqladm-rs.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
environment.etc."mysqladm/config.toml".source = let
nullStrippedConfig = lib.filterAttrsRecursive (_: v: v != null) cfg.settings;
in format.generate "mysqladm-rs.conf" nullStrippedConfig;
services.mysql.ensureUsers = lib.mkIf cfg.createLocalDatabaseUser [ services.mysql.ensureUsers = lib.mkIf cfg.createLocalDatabaseUser [
{ {
name = cfg.settings.mysql.username; name = cfg.settings.mysql.username;
@@ -98,9 +99,10 @@ in
systemd.services."mysqladm@" = { systemd.services."mysqladm@" = {
description = "MySQL administration tool for non-admin users"; description = "MySQL administration tool for non-admin users";
environment.RUST_LOG = "debug"; environment.RUST_LOG = "debug";
restartTriggers = [ config.environment.etc."mysqladm/config.toml".source ];
serviceConfig = { serviceConfig = {
Type = "notify"; Type = "notify";
ExecStart = "${lib.getExe cfg.package} ${cfg.logLevel} server --systemd socket-activate --config ${configFile}"; ExecStart = "${lib.getExe cfg.package} ${cfg.logLevel} server --systemd socket-activate";
WatchdogSec = 15; WatchdogSec = 15;
@@ -159,7 +161,6 @@ in
systemd.sockets."mysqladm" = { systemd.sockets."mysqladm" = {
description = "MySQL administration tool for non-admin users"; description = "MySQL administration tool for non-admin users";
wantedBy = [ "sockets.target" ]; wantedBy = [ "sockets.target" ];
restartTriggers = [ configFile ];
socketConfig = { socketConfig = {
ListenStream = cfg.settings.server.socket_path; ListenStream = cfg.settings.server.socket_path;
Accept = "yes"; Accept = "yes";