summaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix')
-rw-r--r--nix/nix-shell-with-php-composer-nodejs-npm-mysql.nix30
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
+ '';
+}