2020-05-26 19:42:16 +02:00
|
|
|
{ pkgs ? import <nixpkgs> { } }:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
2020-11-29 19:03:13 +01:00
|
|
|
let
|
|
|
|
sql_file = "database/db.sql";
|
|
|
|
data_dir = "$(pwd)/.mysql";
|
|
|
|
socket = "${data_dir}/mysql.sock";
|
|
|
|
|
|
|
|
in mkShell {
|
2020-05-26 19:42:16 +02:00
|
|
|
buildInputs = [ mysql57 ];
|
|
|
|
|
|
|
|
shellHook = ''
|
2020-11-29 19:03:13 +01:00
|
|
|
trap "kill 0" EXIT
|
|
|
|
[ -d ${data_dir} ] || mkdir ${data_dir}
|
2020-05-26 19:42:16 +02:00
|
|
|
|
2020-11-29 19:03:13 +01:00
|
|
|
mysqld --datadir="${data_dir}" --socket="${socket}" --initialize-insecure
|
|
|
|
mysqld --datadir="${data_dir}" --socket="${socket}" --skip-networking &
|
2020-05-26 19:42:16 +02:00
|
|
|
sleep 1
|
|
|
|
|
2020-11-29 19:03:13 +01:00
|
|
|
mysql --socket="${socket}" -u root < ${sql_file}
|
2020-05-26 19:42:16 +02:00
|
|
|
|
2020-11-29 19:03:13 +01:00
|
|
|
alias mysql='mysql --socket="${socket}" -u root'
|
2020-05-26 19:42:16 +02:00
|
|
|
'';
|
|
|
|
}
|