This commit is contained in:
2026-07-19 22:09:52 +02:00
commit 63bb636255
9 changed files with 257 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
# Devenv
.devenv*
devenv.local.nix
devenv.local.yaml
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "WordPress"]
path = WordPress
url = https://github.com/WordPress/WordPress.git

1
WordPress Submodule

Submodule WordPress added at 8a7bc99d93

65
devenv.lock Normal file
View File

@@ -0,0 +1,65 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1784325378,
"narHash": "sha256-Gof6j4d43yX2qSLLp78JILke346IggDFIxTgl3ecVQE=",
"owner": "cachix",
"repo": "devenv",
"rev": "5f1cf17be0fc48689bd0ecb810de6d2e06d259a1",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"nixpkgs": {
"inputs": {
"nixpkgs-src": "nixpkgs-src"
},
"locked": {
"lastModified": 1783345554,
"narHash": "sha256-LZhOm4kqjHUnwP4CNHpaqqEVcumGNd1PvOEOad8LkS0=",
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "6004ea8c229fe9d41b21c6f4c76bf6c2e10771dd",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-src": {
"flake": false,
"locked": {
"lastModified": 1783279667,
"narHash": "sha256-/NAkDSsve+GNM0Bt6tleJdCGfsTlK89nPjkVOzZMo0s=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f205b5574fd0cb7da5b702a2da51507b7f4fdd1b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

91
devenv.nix Normal file
View 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";
}
];
}

18
devenv.yaml Normal file
View File

@@ -0,0 +1,18 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
# If you're using non-OSS software, you can set allow_unfree to true.
allow_unfree: true
# If you're not willing to allow unsupported packages:
# allow_unsupported_system: false
# If you're willing to use a package that's vulnerable
# permitted_insecure_packages:
# - "openssl-1.1.1w"
# If you have more than one devenv you can merge them
#imports:
# - ./backend

View File

@@ -0,0 +1,23 @@
<?php
/**
* Plugin Name: Theme Directory
* Description: Registers the repo-root themes/ directory as an additional theme root.
*/
$repo_theme_root = dirname( ABSPATH ) . '/themes';
register_theme_directory( $repo_theme_root );
add_filter(
'theme_root_uri',
function ( $theme_root_uri, $siteurl ) use ( $repo_theme_root ) {
// Core falls back to the raw filesystem path for registered roots it
// cannot map to a URL; rewrite that to where nginx serves themes/.
if ( $theme_root_uri === $repo_theme_root ) {
return $siteurl . '/themes';
}
return $theme_root_uri;
},
10,
2
);

0
themes/.gitkeep Normal file
View File

46
wp-config.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
/**
* WordPress configuration for the local devenv setup.
*
* Tracked in git on purpose: this is a local learning environment,
* all credentials here are throwaway dev values.
*/
// ** Plugins live in the repo root, outside the WordPress core submodule ** //
define( 'WP_PLUGIN_DIR', __DIR__ . '/plugins' );
define( 'WP_PLUGIN_URL', 'http://localhost:8080/plugins' );
// ** Database settings (matches services.mysql in devenv.nix) ** //
define( 'DB_NAME', 'wp' );
define( 'DB_USER', 'wp' );
define( 'DB_PASSWORD', 'wp' );
define( 'DB_HOST', '127.0.0.1' );
define( 'DB_CHARSET', 'utf8mb4' );
define( 'DB_COLLATE', '' );
/**#@+
* Authentication unique keys and salts.
*/
define( 'AUTH_KEY', '86wUWH4GaRKEb3um2OCG1+IYzgMcYtCsgZIxlDtRsPW0pviesMF5AoIfWSj7+YnZ' );
define( 'SECURE_AUTH_KEY', '/z7gh8GFhsdnKMSt2tmGmgggiGtsy/IvYXinmE4PIatukxPR/M+5T90oeOdNXW+r' );
define( 'LOGGED_IN_KEY', 'cjHgRpkOjVwci1f0pKT8uCrnwRq+xwP7X1giPUyoixrqpZ/RJIfGnyTav+6Px5W4' );
define( 'NONCE_KEY', '9d9koxfp5eyY4UP8Bis3uyjD4ZJ5CZXhnk1Reo90grpq4fvdpu6C5PZiTQY04Zcg' );
define( 'AUTH_SALT', 'T7FWdS8KrqLKtQ5CzuYy3q4uDyz3qQDvY6XVHT5Te8VCiK0N7eqNDfXPGm73OF0E' );
define( 'SECURE_AUTH_SALT', 'vKhXxI+TrE/8DxiogbdVO4ZC/Po2f8ijLOgGuQi4TWy8I3AizL1L4H3VABY8aGg5' );
define( 'LOGGED_IN_SALT', '9ZRBx99oicNodcM9ayUzcr4zuV2w7W/q5EY+Fpa8zrcq8di1LTG1/pwXYnEsHLyZ' );
define( 'NONCE_SALT', '7U/impFiyFsTQe3WKgiqLjEH33V/i4+kDJKMf5HlTHGnf2TQvBwlnqCg+0KZRXSd' );
/**#@-*/
$table_prefix = 'wp_';
define( 'WP_DEBUG', true );
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/WordPress/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';