From deda3b51b50a53b5001b1352db7eefd2692541c6 Mon Sep 17 00:00:00 2001 From: coolneng Date: Sun, 21 Jun 2020 15:58:43 +0200 Subject: [PATCH] Spawn a MySQL instance with a test database --- shell.nix | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/shell.nix b/shell.nix index a9e35d0..ca55b7d 100644 --- a/shell.nix +++ b/shell.nix @@ -1,28 +1,38 @@ { pkgs ? import { } }: -with pkgs.python37Packages; +with pkgs; -pkgs.mkShell { +mkShell { buildInputs = [ # Dependencies - fastapi - uvicorn - pydantic - email_validator - sqlalchemy - pymysql - databases - aiomysql - alembic - pytest - twilio + python38Packages.fastapi + python38Packages.uvicorn + python38Packages.pydantic + python38Packages.email_validator + python38Packages.sqlalchemy + python38Packages.pymysql + python38Packages.databases + python38Packages.aiomysql + python38Packages.alembic + python38Packages.pytest + python38Packages.twilio + mysql57 # Development tools - black - isort - pyflakes + python38Packages.black + python38Packages.isort + python38Packages.pyflakes python-language-server - pyls-black - pyls-isort - pyls-mypy ]; + + shellHook = '' + pkill mysql + rm -rf .mysql && mkdir .mysql + + mysqld --datadir="$(pwd)/.mysql" --socket="$(pwd)/.mysql/mysql.sock" --initialize-insecure + mysqld --datadir="$(pwd)/.mysql" --socket="$(pwd)/.mysql/mysql.sock" --skip-networking & sleep 1 + + mysql --socket="$(pwd)/.mysql/mysql.sock" -u root < $(pwd)/assets/test_db.sql + + alias mysql='mysql --socket="$(pwd)/.mysql/mysql.sock" -u root' + ''; }