Skip to content

Commit

Permalink
Merge pull request #975 from Nebucatnetzer/use-defaults-extra-files
Browse files Browse the repository at this point in the history
Add an option to toggle defautls-extra-file for mysql cli commands
  • Loading branch information
domenkozar authored Feb 11, 2024
2 parents d4f2849 + 4d85d01 commit 4c93ee7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/modules/services/mysql.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ with lib; let
isMariaDB = getName cfg.package == getName pkgs.mariadb;
format = pkgs.formats.ini { listsAsDuplicateKeys = true; };
configFile = format.generate "my.cnf" cfg.settings;
mysqlOptions = "--defaults-file=${configFile}";
mysqldOptions = "${mysqlOptions} --datadir=$MYSQL_HOME --basedir=${cfg.package}";
mysqlOptions =
if !cfg.useDefaulsExtraFile then
"--defaults-file=${configFile}"
else
"--defaults-extra-file=${configFile}";
mysqldOptions = "--defaults-file=${configFile} --datadir=$MYSQL_HOME --basedir=${cfg.package}";

initDatabaseCmd =
if isMariaDB
Expand Down Expand Up @@ -177,6 +181,17 @@ in
'';
};

useDefaulsExtraFile = lib.mkOption {
type = types.bool;
default = false;
description = ''
Whether to use defaults-exta-file for the mysql command instead of defaults-file.
This is useful if you want to provide a config file on the command line.
However this can problematic if you have MySQL installed globaly because its config might leak into your environment.
This option does not affect the mysqld command.
'';
};

ensureUsers = lib.mkOption {
type = types.listOf (types.submodule {
options = {
Expand Down

0 comments on commit 4c93ee7

Please sign in to comment.