From 9f7315caf2dd28fbdc44c6eebe94f31ba63ffe24 Mon Sep 17 00:00:00 2001 From: Danylo Hlynskyi Date: Tue, 14 Nov 2017 03:08:15 +0200 Subject: [PATCH] mysql module: fix flaky check Comparing packages via equality will lead to different results when package and module are from different `nixpkgs` checkouts. Also, because MariaDB is actually supported, added a note to option description to make this knowledge more discover-able. --- nixos/modules/services/databases/mysql.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/databases/mysql.nix b/nixos/modules/services/databases/mysql.nix index c6c463bce7d..a3bf4f9ba92 100644 --- a/nixos/modules/services/databases/mysql.nix +++ b/nixos/modules/services/databases/mysql.nix @@ -7,6 +7,11 @@ let cfg = config.services.mysql; mysql = cfg.package; + + isMariaDB = + let + pName = _p: (builtins.parseDrvName (_p.name)).name; + in pName mysql == pName pkgs.mariadb; atLeast55 = versionAtLeast mysql.mysqlVersion "5.5"; @@ -59,7 +64,7 @@ in type = types.package; example = literalExample "pkgs.mysql"; description = " - Which MySQL derivation to use. + Which MySQL derivation to use. MariaDB packages are supported too. "; }; @@ -360,7 +365,7 @@ in ${concatMapStrings (user: '' - ( echo "CREATE USER IF NOT EXISTS '${user.name}'@'localhost' IDENTIFIED WITH ${if mysql == pkgs.mariadb then "unix_socket" else "auth_socket"};" + ( echo "CREATE USER IF NOT EXISTS '${user.name}'@'localhost' IDENTIFIED WITH ${if isMariaDB then "unix_socket" else "auth_socket"};" ${concatStringsSep "\n" (mapAttrsToList (database: permission: '' echo "GRANT ${permission} ON ${database} TO '${user.name}'@'localhost';" '') user.ensurePermissions)}