2020-05-26 19:42:16 +02:00
|
|
|
{ pkgs ? import <nixpkgs> { } }:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
2020-11-29 19:03:13 +01:00
|
|
|
let
|
2020-12-17 15:57:59 +01:00
|
|
|
sql_file = "data/db.sql";
|
2020-11-29 19:03:13 +01:00
|
|
|
data_dir = "$(pwd)/.mysql";
|
|
|
|
socket = "${data_dir}/mysql.sock";
|
|
|
|
|
|
|
|
in mkShell {
|
2020-11-30 20:45:42 +01:00
|
|
|
buildInputs = [ mysql80 ];
|
2020-05-26 19:42:16 +02:00
|
|
|
|
|
|
|
shellHook = ''
|
2020-11-29 19:03:13 +01:00
|
|
|
trap "kill 0" EXIT
|
2020-05-26 19:42:16 +02:00
|
|
|
|
2021-01-08 01:22:02 +01:00
|
|
|
|
|
|
|
if [ ! -d ${data_dir} ]; then
|
|
|
|
mysqld --datadir="${data_dir}" --socket="${socket}" --initialize-insecure
|
|
|
|
fi
|
|
|
|
|
2020-11-30 20:45:42 +01:00
|
|
|
mysqld --datadir="${data_dir}" --socket="${socket}" --skip-networking --skip-mysqlx &
|
2020-05-26 19:42:16 +02:00
|
|
|
sleep 1
|
|
|
|
|
2021-05-06 00:08:56 +02:00
|
|
|
if [ ! -d ${data_dir} ]; then
|
|
|
|
mysql --socket="${socket}" -u root < ${sql_file}
|
|
|
|
fi
|
2020-05-26 19:42:16 +02:00
|
|
|
|
2020-11-29 19:03:13 +01:00
|
|
|
alias mysql='mysql --socket="${socket}" -u root'
|
2021-02-05 19:00:50 +01:00
|
|
|
alias nuke='rm -rf ${data_dir}'
|
2020-05-26 19:42:16 +02:00
|
|
|
'';
|
|
|
|
}
|