Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ defaults:

jobs:
check-flake:
runs-on: ci-ocf-wordpress
runs-on: ci-ocf-imprint
steps:
- uses: actions/checkout@v5
- uses: DeterminateSystems/flake-checker-action@v9

build:
runs-on: ci-ocf-wordpress
runs-on: ci-ocf-imprint
needs: check-flake
steps:
- uses: actions/checkout@v5
Expand Down
5 changes: 5 additions & 0 deletions wordpress/bin/startup-wp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/sh
set -e
#cp -rnT /share/wordpress/themes /content/themes
ln -snf /share/wordpress/themes /content/themes
ln -snf /share/wordpress/plugins /content/plugins
ln -snf /uploads /content/uploads
ln -snf /content /share/wordpress/wp-content
if ! wp core is-installed 2>/dev/null; then
wp core install --url="$PRIMARY_URL" --title="OCF WordPress Template" --admin_user=admin --admin_password="$(tr -dc '[:alnum:]' < /dev/urandom | head -c256)" --admin_email="wp-admin@ocf.berkeley.edu" --allow-root
fi
Expand Down
2 changes: 2 additions & 0 deletions wordpress/config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ http {

index index.php index.html index.htm;

client_max_body_size 100M;

upstream php {
server 127.0.0.1:9000;
}
Expand Down
7 changes: 5 additions & 2 deletions wordpress/config/wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@
define( 'WP_DEBUG_DISPLAY', false );

# Must be set, otherwise Wordpress tries to find it in the nix store
define( 'WP_CONTENT_DIR', '/share/wordpress/wp-content' );
define( 'WP_CONTENT_DIR', '/content' );
define( 'WP_PLUGIN_DIR', '/share/wordpress/plugins' );

# The install/themes/plugins are constant and cannot be updated by the user
define( 'AUTOMATIC_UPDATER_DISABLED', true );
define( 'WP_AUTO_UPDATE_CORE', false );
define( 'DISALLOW_FILE_MODS', true );

define( 'FS_METHOD', 'direct' );

# Requests to wordpress.org will fail and cause slowdowns otherwise
define( 'WP_HTTP_BLOCK_EXTERNAL', true );
#define( 'WP_HTTP_BLOCK_EXTERNAL', true );

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
Expand Down
2 changes: 1 addition & 1 deletion wordpress/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
DB_HOST: mariadb
PRIMARY_URL: http://localhost:8080
ports:
- 8080:8080
- 8080:443
volumes:
- wp-uploads:/share/wordpress/wp-content/uploads
tmpfs:
Expand Down
12 changes: 6 additions & 6 deletions wordpress/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 29 additions & 7 deletions wordpress/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
inputs = {
nixpkgs = {
type = "github";
owner = "nixos";
owner = "sophiebsw";
repo = "nixpkgs";
ref = "nixos-25.11";
ref = "wordpress-fix-overriding-26.05";
};

systems = {
Expand All @@ -25,18 +25,37 @@
...
}:
let
pkgsFor = system: import nixpkgs { inherit system; };
extraPlugins = builtins.fromJSON (builtins.readFile ./pkgs/extraPlugins.json);
extraPluginLicenses = nixpkgs.lib.genAttrs (nixpkgs.lib.attrNames extraPlugins) (name: "free");
extraThemes = builtins.fromJSON (builtins.readFile ./pkgs/extraThemes.json);
extraThemeLicenses = nixpkgs.lib.genAttrs (nixpkgs.lib.attrNames extraThemes) (name: "free");

overlays = nixpkgs.lib.singleton (
final: prev: {
wordpressPackages = prev.wordpressPackages.override (prev: {
plugins = prev.plugins // extraPlugins;
pluginLicenses = prev.pluginLicenses // extraPluginLicenses;
themes = prev.themes // extraThemes;
themeLicenses = prev.themeLicenses // extraThemeLicenses;
});
}
);

pkgsFor = system: import nixpkgs { inherit system overlays; };
forAllSystems = fn: nixpkgs.lib.genAttrs (import systems) (system: fn (pkgsFor system));

in
{
inherit extraPluginLicenses;
formatter = forAllSystems (pkgs: pkgs.nixfmt-tree);
wordpress = forAllSystems (pkgs: pkgs.wordpressPackages);

packages = forAllSystems (
pkgs:
let
timestamp = builtins.readFile (
pkgs.runCommand "timestamp" { } ''
date --date='@${builtins.toString self.lastModified}' --iso-8601=minutes > $out
date --date='@${toString self.lastModified}' --iso-8601=minutes > $out
''
);
mkShAppInputs =
Expand All @@ -56,7 +75,7 @@
mkWpContent =
name: pkgsToLink:
let
path = "share/wordpress/wp-content/${name}";
path = "share/wordpress/${name}";
in
pkgs.runCommand name { } ''
mkdir -p $out/${path}
Expand All @@ -71,9 +90,10 @@
# WordPress determines its install location via the ABSPATH php constant, which is set based
# on the location of the .php scripts. Overriding the WordPress package to add our config
# to it is the simplest and most consistent solution.
wpWithConfig = pkgs.wordpress.overrideAttrs (old: {
wpWithConfig = pkgs.wordpress_7_0.overrideAttrs (old: {
postInstall = ''
cp ${wpConfig}/share/wordpress/wp-config.php $out/share/wordpress/wp-config.php
rm -r $out/share/wordpress/wp-content
'';
});

Expand All @@ -86,12 +106,14 @@
[
twentytwentyfive
twentytwentyfour
hestia
]
);
plugins = mkWpContent "plugins" (
with pkgs.wordpressPackages.plugins;
[
hello-dolly
elementor
gtranslate
]
);
in
Expand Down
14 changes: 14 additions & 0 deletions wordpress/pkgs/extraPlugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"elementor": {
"path": "elementor/tags/4.2.4",
"rev": "3674525",
"sha256": "1hzwqsa1p2lddy034hhrfs1gkw3q20np90lvpxrm331hzz2f1jik",
"version": "4.2.4"
},
"gtranslate": {
"path": "gtranslate/tags/3.1.2",
"rev": "3674542",
"sha256": "1fp21g0kanq2sl6zcyhs46ah4y8y7p9sswn903m0y6cmi5i6g9sb",
"version": "3.1.2"
}
}
8 changes: 8 additions & 0 deletions wordpress/pkgs/extraThemes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"hestia": {
"path": "hestia/3.3.6",
"rev": "348036",
"sha256": "0ymv2r1kbv8c4lkka46jypacc8fj4snf5hwqxfznrl0a15rp5qd2",
"version": "3.3.6"
}
}
Loading