Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/app/docs/devbox_examples/databases/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ MYSQL_BASEDIR=.devbox/nix/profile/default
MYSQL_HOME=./.devbox/virtenv/mysql/run
MYSQL_DATADIR=./.devbox/virtenv/mysql/data
MYSQL_UNIX_PORT=./.devbox/virtenv/mysql/run/mysql.sock
MYSQL_PID_FILE=./.devbox/mysql/run/mysql.pid
MYSQL_PID_FILE=./.devbox/virtenv/mysql/run/mysql.pid
MYSQL_CONF=./devbox.d/mysql/my.cnf
```

### Files

The following helper file will be created in your project directory:

* \{PROJECT_DIR\}/devbox.d/mysql/my.cnf

The plugin will also create the following helper files in your project's `.devbox/virtenv` folder:

* mysql/flake.nix
Expand Down
4 changes: 2 additions & 2 deletions plugins/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var builtInMap = map[*regexp.Regexp]string{
regexp.MustCompile(`^(apache|apacheHttpd)$`): "apacheHttpd",
regexp.MustCompile(`^(gradle|gradle_[0-9])$`): "gradle",
regexp.MustCompile(`^(ghc|haskell\.compiler\.(.*))$`): "haskell",
regexp.MustCompile(`^mariadb(-embedded)?_?[0-9]*$`): "mariadb",
regexp.MustCompile(`^mysql?[0-9]*$`): "mysql",
regexp.MustCompile(`(^mariadb(-embedded)?_?[0-9]*$|^mysql$)`): "mariadb",
regexp.MustCompile(`^mysql(80|57|50)$`): "mysql",
regexp.MustCompile(`^nodejs(-slim)?_?[0-9]*$`): "nodejs",
regexp.MustCompile(`^php[0-9]*$`): "php",
regexp.MustCompile(`^python3[0-9]*Packages.pip$`): "pip",
Expand Down
2 changes: 1 addition & 1 deletion plugins/builtins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestBuiltInMap(t *testing.T) {
"mariadb": "mariadb",
"mariadb_1011": "mariadb",
"mariadb-embedded": "mariadb",
"mysql": "mysql",
"mysql": "mariadb",
"mysql80": "mysql",
"python3Packages.pip": "pip",
"python": "python",
Expand Down
3 changes: 2 additions & 1 deletion plugins/mariadb.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"{{ .Virtenv }}/run": "",
"{{ .Virtenv }}/flake/flake.nix": "mariadb/flake.nix",
"{{ .Virtenv }}/setup_db.sh": "mariadb/setup_db.sh",
"{{ .Virtenv }}/process-compose.yaml": "mariadb/process-compose.yaml"
"{{ .Virtenv }}/process-compose.yaml": "mariadb/process-compose.yaml",
"{{ .DevboxDir }}/my.cnf": "mariadb/my.cnf"
},
"packages": {
"path:{{ .Virtenv }}/flake": {},
Expand Down
4 changes: 4 additions & 0 deletions plugins/mariadb/my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# MySQL configuration file

[mariadb]
log_error=mysql.log
4 changes: 4 additions & 0 deletions plugins/mariadb/setup_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ if [ ! -d "$MYSQL_DATADIR" ]; then
--datadir=$MYSQL_DATADIR --basedir=$MYSQL_BASEDIR \
--pid-file=$MYSQL_PID_FILE
fi

if [ -e "$MYSQL_CONF" ]; then
ln -fs "$MYSQL_CONF" "$MYSQL_HOME/my.cnf"
fi
56 changes: 28 additions & 28 deletions plugins/mysql.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "mysql",
"version": "0.0.3",
"description": "* This plugin wraps mysqld and mysql_install_db to work in your local project\n* This plugin will create a new database for your project in MYSQL_DATADIR if one doesn't exist on shell init. This DB will be started in `insecure` mode, so be sure to add a root password after creation if needed.\n* Use mysqld to manually start the server, and `mysqladmin -u root shutdown` to manually stop it",
"env": {
"MYSQL_BASEDIR": "{{ .DevboxProfileDefault }}",
"MYSQL_HOME": "{{ .Virtenv }}/run",
"MYSQL_DATADIR": "{{ .Virtenv }}/data",
"MYSQL_UNIX_PORT": "{{ .Virtenv }}/run/mysql.sock",
"MYSQL_PID_FILE": "{{ .Virtenv }}/run/mysql.pid"
},
"create_files": {
"{{ .Virtenv }}/run": "",
"{{ .Virtenv }}/flake/flake.nix": "mysql/flake.nix",
"{{ .Virtenv }}/setup_db.sh": "mysql/setup_db.sh",
"{{ .Virtenv }}/process-compose.yaml": "mysql/process-compose.yaml"
},
"packages": {
"path:{{ .Virtenv }}/flake": {},
"glibcLocales": {
"version": "latest",
"platforms": ["x86_64-linux", "aarch64-linux"]
}
},
"__remove_trigger_package": true,
"shell": {
"init_hook": [
"bash {{ .Virtenv }}/setup_db.sh"
]
"name": "mysql",
"version": "0.0.4",
"description": "* This plugin wraps mysqld and mysql_install_db to work in your local project\n* This plugin will create a new database for your project in MYSQL_DATADIR if one doesn't exist on shell init. This DB will be started in `insecure` mode, so be sure to add a root password after creation if needed.\n* Use mysqld to manually start the server, and `mysqladmin -u root shutdown` to manually stop it",
"env": {
"MYSQL_BASEDIR": "{{ .DevboxProfileDefault }}",
"MYSQL_HOME": "{{ .Virtenv }}/run",
"MYSQL_DATADIR": "{{ .Virtenv }}/data",
"MYSQL_UNIX_PORT": "{{ .Virtenv }}/run/mysql.sock",
"MYSQL_PID_FILE": "{{ .Virtenv }}/run/mysql.pid",
"MYSQL_CONF": "{{ .DevboxDir }}/my.cnf"
},
"create_files": {
"{{ .Virtenv }}/run": "",
"{{ .Virtenv }}/flake/flake.nix": "mysql/flake.nix",
"{{ .Virtenv }}/setup_db.sh": "mysql/setup_db.sh",
"{{ .Virtenv }}/process-compose.yaml": "mysql/process-compose.yaml",
"{{ .DevboxDir }}/my.cnf": "mysql/my.cnf"
},
"packages": {
"path:{{ .Virtenv }}/flake": {},
"glibcLocales": {
"version": "latest",
"platforms": ["x86_64-linux", "aarch64-linux"]
}
},
"__remove_trigger_package": true,
"shell": {
"init_hook": ["bash {{ .Virtenv }}/setup_db.sh"]
}
}
4 changes: 4 additions & 0 deletions plugins/mysql/my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# MySQL configuration file

# [mysqld]
# skip-log-bin
10 changes: 7 additions & 3 deletions plugins/mysql/setup_db.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#! bash

if [ ! -d "$MYSQL_DATADIR" ]; then
# Install the Database
mkdir $MYSQL_DATADIR
mysqld --initialize-insecure
# Install the Database
mkdir $MYSQL_DATADIR
mysqld --initialize-insecure
fi

if [ -e "$MYSQL_CONF" ]; then
ln -fs "$MYSQL_CONF" "$MYSQL_HOME/my.cnf"
fi