Skip to content

Commit 25de147

Browse files
jefftartemklevtsovgcurtisloretomikeland73
authored
Use the nix path for mysql/mariadb 'basedir'. Fixes #2524 (#2525)
## Summary As described on #2524, `mysqld` are using the local `/usr` for `basedir` (e.g. reading `/usr/lib/mysql/plugins` if present), when it should be using the nix equivalent. ## How was it tested? Warning: this is untested. I don't know how to recompile flake.nix, so I cheated and edited the `mysqld` wrapper with `sudo vim $(which mysqld)`. This patch may be wrong, e.g. I'm not sure if `$out` will be expanded in those single-quotes. But if the patch does what I hope, this is the effect it should have: ``` cd /tmp devbox create mysqltest --template mysql devbox run mysqld --verbose --help | grep ^basedir ``` With this patch, the command above should print something like: ``` basedir /nix/store/15pzxq00jcraacaxancf3zm6h444azpm-mysql-wrapped/ ``` previously it would print: ``` basedir /usr/ ``` Also, one can fully launch mysqld, connect with mysql and show the basedir with: ```sql mysql> SHOW VARIABLES LIKE '%dir'; +-----------------------------+---------------------------------------------------------------------------------+ | Variable_name | Value | +-----------------------------+---------------------------------------------------------------------------------+ | basedir | /nix/store/15pzxq00jcraacaxancf3zm6h444azpm-mysql-wrapped/ | | character_sets_dir | /nix/store/15pzxq00jcraacaxancf3zm6h444azpm-mysql-wrapped/share/mysql/charsets/ | | datadir | /tmp/mysqltest/.devbox/virtenv/mysql80/data/ | | innodb_data_home_dir | | | innodb_doublewrite_dir | | | innodb_log_group_home_dir | ./ | | innodb_temp_tablespaces_dir | ./#innodb_temp/ | | innodb_tmpdir | | | lc_messages_dir | /nix/store/15pzxq00jcraacaxancf3zm6h444azpm-mysql-wrapped/share/mysql/ | | plugin_dir | /nix/store/15pzxq00jcraacaxancf3zm6h444azpm-mysql-wrapped/lib/mysql/plugin/ | | replica_load_tmpdir | /tmp | | slave_load_tmpdir | /tmp | | tmpdir | /tmp | +-----------------------------+---------------------------------------------------------------------------------+ 13 rows in set (0.00 sec) ``` The basedir and related paths are now correctly pointing to `/nix/store` paths, and everything still works! --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: John Lago <[email protected]> Co-authored-by: Artem Klevtsov <[email protected]> Co-authored-by: Greg Curtis <[email protected]> Co-authored-by: Daniel Loreto <[email protected]> Co-authored-by: Mike Landau <[email protected]> Co-authored-by: John Lago <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Brennan <[email protected]>
1 parent 07afb36 commit 25de147

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

plugins/mariadb/flake.nix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@
1515
postBuild = ''
1616
1717
wrapProgram $out/bin/mysqld \
18-
--add-flags '--datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
18+
--add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
1919
2020
wrapProgram $out/bin/mariadbd \
21-
--add-flags '--datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
21+
--add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
2222
2323
wrapProgram $out/bin/mysqld_safe \
24-
--add-flags '--datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
24+
--add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
2525
2626
if [-f $out/bin/mariadbd-safe]; then
2727
wrapProgram $out/bin/mariadbd_safe \
28-
--add-flags '--datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
28+
--add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
2929
fi
3030
3131
wrapProgram "$out/bin/mysql_install_db" \
32-
--add-flags '--datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --basedir=''$MYSQL_BASEDIR';
32+
--add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --basedir=''$MYSQL_BASEDIR';
3333
3434
if [-f $out/bin/mariadb-install-db]; then
3535
wrapProgram "$out/bin/mariadb_install_db" \
36-
--add-flags '--datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --basedir=''$MYSQL_BASEDIR';
36+
--add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --basedir=''$MYSQL_BASEDIR';
3737
fi
3838
'';
3939
};

plugins/mysql/flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
postBuild = ''
1616
1717
wrapProgram $out/bin/mysqld \
18-
--add-flags '--datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
18+
--add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
1919
2020
wrapProgram $out/bin/mysqld_safe \
21-
--add-flags '--datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
21+
--add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT';
2222
'';
2323
};
2424
in{

0 commit comments

Comments
 (0)