init
This commit is contained in:
91
devenv.nix
Normal file
91
devenv.nix
Normal file
@@ -0,0 +1,91 @@
|
||||
{ pkgs, lib, config, inputs, ... }:
|
||||
|
||||
{
|
||||
packages = [pkgs.wp-cli pkgs.bun];
|
||||
languages.typescript.enable = true;
|
||||
languages.php.enable = true;
|
||||
languages.php.lsp.package = pkgs.intelephense;
|
||||
languages.php.fpm.pools.wordpress = {
|
||||
settings = {
|
||||
"pm" = "dynamic";
|
||||
"pm.max_children" = 5;
|
||||
"pm.start_servers" = 2;
|
||||
"pm.min_spare_servers" = 1;
|
||||
"pm.max_spare_servers" = 3;
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx.enable = true;
|
||||
services.nginx.httpConfig = ''
|
||||
include ${pkgs.nginx}/conf/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name localhost;
|
||||
|
||||
root ${config.env.DEVENV_ROOT}/WordPress;
|
||||
index index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
}
|
||||
|
||||
location /plugins/ {
|
||||
alias ${config.env.DEVENV_ROOT}/plugins/;
|
||||
}
|
||||
|
||||
location /themes/ {
|
||||
alias ${config.env.DEVENV_ROOT}/themes/;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
include ${pkgs.nginx}/conf/fastcgi.conf;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_pass unix:${config.languages.php.fpm.pools.wordpress.socket};
|
||||
}
|
||||
}
|
||||
'';
|
||||
|
||||
processes.wp-install = {
|
||||
exec = ''
|
||||
set -e
|
||||
flag="$DEVENV_STATE/.wpinstalled"
|
||||
if [ -e "$flag" ]; then
|
||||
echo "WordPress already installed, skipping ($flag exists)"
|
||||
exit 0
|
||||
fi
|
||||
wp core install \
|
||||
--path="$DEVENV_ROOT/WordPress" \
|
||||
--url="http://localhost:8080" \
|
||||
--title="Dev Site" \
|
||||
--admin_user=admin \
|
||||
--admin_password=admin \
|
||||
--admin_email=admin@example.com \
|
||||
--skip-email
|
||||
wp plugin activate theme-directory --path="$DEVENV_ROOT/WordPress"
|
||||
touch "$flag"
|
||||
'';
|
||||
after = [
|
||||
"devenv:processes:mysql"
|
||||
"devenv:mysql:configure"
|
||||
];
|
||||
};
|
||||
|
||||
services.mysql.enable = true;
|
||||
services.mysql.ensureUsers = [
|
||||
{
|
||||
name = "wp";
|
||||
password = "wp";
|
||||
ensurePermissions = {
|
||||
"wp.*" = "ALL PRIVILEGES";
|
||||
};
|
||||
}
|
||||
];
|
||||
services.mysql.initialDatabases = [
|
||||
{
|
||||
name = "wp";
|
||||
}
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user