diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-10-19 10:04:14 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-10-19 10:04:14 +0200 |
commit | ac93ed4d29dd85409fb4c0cd9c2af266e90777c1 (patch) | |
tree | 6a0b4487439bfe068d4b7d412be70d4f90faa2a5 /nix |
Diffstat (limited to 'nix')
-rw-r--r-- | nix/nix-shell-with-php-composer-nodejs-npm-mysql.nix | 30 |
1 files changed, 30 insertions, 0 deletions
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 <nixpkgs> {}); +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 + ''; +} |