summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAlexandre Mazari <alexandre.mazari@gmail.com>2019-03-09 16:57:39 +0100
committerDanylo Hlynskyi <abcz2.uprola@gmail.com>2019-03-09 17:57:39 +0200
commitd7f6cdeda4ea942b556677e1a590edd203c0c646 (patch)
treea68317f3f4df4dd839d00c726d0e1fcf54f36967 /nixos
parent32e9296244a697d12cfd7f56bae784f0d71e3624 (diff)
downloadnixpkgs-d7f6cdeda4ea942b556677e1a590edd203c0c646.tar
nixpkgs-d7f6cdeda4ea942b556677e1a590edd203c0c646.tar.gz
nixpkgs-d7f6cdeda4ea942b556677e1a590edd203c0c646.tar.bz2
nixpkgs-d7f6cdeda4ea942b556677e1a590edd203c0c646.tar.lz
nixpkgs-d7f6cdeda4ea942b556677e1a590edd203c0c646.tar.xz
nixpkgs-d7f6cdeda4ea942b556677e1a590edd203c0c646.tar.zst
nixpkgs-d7f6cdeda4ea942b556677e1a590edd203c0c646.zip
Fix locally created database (#56889)
* zoneminder: fix initial database creation

Move initialDatabases directive from the 'ensureUsers' scope to the correct outer 'mysql' one.

* zoneminder: Fix mysql username to match unix username

When database.createLocally is used, a mysql user is created with the ensureUsers directive.
It ensures that the unix user with the name provided exists and can connect to MySQL through socket.
Thus, the MySQL username used by php/perl scripts must match the unix user owning the server PID.

This patch sets the default mysql user to 'zoneminder' instead of 'zmuser'.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/misc/zoneminder.nix8
1 files changed, 4 insertions, 4 deletions
diff --git a/nixos/modules/services/misc/zoneminder.nix b/nixos/modules/services/misc/zoneminder.nix
index fb9c4c41ae2..04ddd3ca183 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"; }
-          ];
         }];
       };