{ pkgs ? import { } }: with pkgs; let sql_file = "data/db.sql"; data_dir = "$(pwd)/.mysql"; socket = "${data_dir}/mysql.sock"; in mkShell { buildInputs = [ mysql80 ]; shellHook = '' trap "kill 0" EXIT if [ ! -d ${data_dir} ]; then mysqld --datadir="${data_dir}" --socket="${socket}" --initialize-insecure fi mysqld --datadir="${data_dir}" --socket="${socket}" --skip-networking --skip-mysqlx & sleep 1 if [ ! -d ${data_dir} ]; then mysql --socket="${socket}" -u root < ${sql_file} fi alias mysql='mysql --socket="${socket}" -u root' alias nuke='rm -rf ${data_dir}' ''; }