From ac93ed4d29dd85409fb4c0cd9c2af266e90777c1 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 19 Oct 2024 10:04:14 +0200 Subject: initial commit --- ...ix-shell-with-php-composer-nodejs-npm-mysql.nix | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 nix/nix-shell-with-php-composer-nodejs-npm-mysql.nix (limited to 'nix/nix-shell-with-php-composer-nodejs-npm-mysql.nix') diff --git a/nix/nix-shell-with-php-composer-nodejs-npm-mysql.nix b/nix/nix-shell-with-php-composer-nodejs-npm-mysql.nix new file mode 100644 index 0000000..27249eb --- /dev/null +++ b/nix/nix-shell-with-php-composer-nodejs-npm-mysql.nix @@ -0,0 +1,30 @@ +with (import {}); +mkShell { + buildInputs = [ + php + phpPackages.composer + nodejs + mysql80 + ]; + + shellHook = '' + MYSQL_DIR=$(pwd)/.nix/mysql + MYSQL_SOCKET=$(pwd)/.nix/mysql/mysql.sock + MYSQL_ROOT_PASSWORD=123456 + + export MYSQL_UNIX_PORT=$MYSQL_SOCKET + + if [ ! -d $MYSQL_DIR ]; then + mysqld --initialize-insecure --datadir=$MYSQL_DIR + fi + + if ! mysqladmin status --user=root -p$MYSQL_ROOT_PASSWORD; then + mysqld --datadir=$MYSQL_DIR --skip-networking & + + sleep 3 + if ! mysql --user=root -p$MYSQL_ROOT_PASSWORD >> "SELECT 1"; then + mysql --user=root <<< "ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';" + fi + fi + ''; +} -- cgit v1.2.3