{ pkgs ? import { } }: with pkgs; let sql_file = "database/db.sql"; data_dir = "$(pwd)/.mysql"; socket = "${data_dir}/mysql.sock"; in mkShell { buildInputs = [ mysql57 ]; shellHook = '' trap "kill 0" EXIT [ -d ${data_dir} ] || mkdir ${data_dir} mysqld --datadir="${data_dir}" --socket="${socket}" --initialize-insecure mysqld --datadir="${data_dir}" --socket="${socket}" --skip-networking & sleep 1 mysql --socket="${socket}" -u root < ${sql_file} alias mysql='mysql --socket="${socket}" -u root' ''; }