diff --git a/nixos/modules/services/misc/zoneminder.nix b/nixos/modules/services/misc/zoneminder.nix index fb9c4c41ae27..04ddd3ca183a 100644 --- a/nixos/modules/services/misc/zoneminder.nix +++ b/nixos/modules/services/misc/zoneminder.nix @@ -49,7 +49,7 @@ let # Database ZM_DB_TYPE=mysql ZM_DB_HOST=${cfg.database.host} - ZM_DB_NAME=${cfg.database.name} + ZM_DB_NAME=${if cfg.database.createLocally then user else cfg.database.username} ZM_DB_USER=${cfg.database.username} ZM_DB_PASS=${cfg.database.password} @@ -205,12 +205,12 @@ in { mysql = lib.mkIf cfg.database.createLocally { ensureDatabases = [ cfg.database.name ]; + initialDatabases = [{ + inherit (cfg.database) name; schema = "${pkg}/share/zoneminder/db/zm_create.sql"; + }]; ensureUsers = [{ name = cfg.database.username; ensurePermissions = { "${cfg.database.name}.*" = "ALL PRIVILEGES"; }; - initialDatabases = [ - { inherit (cfg.database) name; schema = "${pkg}/share/zoneminder/db/zm_create.sql"; } - ]; }]; };