diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d7c089..51e64e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/wordpress/bin/startup-wp b/wordpress/bin/startup-wp index 6c643ba..aec7595 100755 --- a/wordpress/bin/startup-wp +++ b/wordpress/bin/startup-wp @@ -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 diff --git a/wordpress/config/nginx.conf b/wordpress/config/nginx.conf index 139bc0a..64770a6 100644 --- a/wordpress/config/nginx.conf +++ b/wordpress/config/nginx.conf @@ -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; } diff --git a/wordpress/config/wp-config.php b/wordpress/config/wp-config.php index b973f5b..850e611 100644 --- a/wordpress/config/wp-config.php +++ b/wordpress/config/wp-config.php @@ -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' ) ) { diff --git a/wordpress/docker-compose.yml b/wordpress/docker-compose.yml index 0695fa9..daf3344 100644 --- a/wordpress/docker-compose.yml +++ b/wordpress/docker-compose.yml @@ -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: diff --git a/wordpress/flake.lock b/wordpress/flake.lock index 8016fe9..d8a6a75 100644 --- a/wordpress/flake.lock +++ b/wordpress/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1782847189, - "narHash": "sha256-twXPFqFsrrY5r28Zh7Homgcp2gUMBgQ6WDS98Q/3xFI=", - "owner": "nixos", + "lastModified": 1789424161, + "narHash": "sha256-U5jFE9Zy1CeOpLqpAkb0m+2wFU0ZpUwP5151eRQa6Wc=", + "owner": "sophiebsw", "repo": "nixpkgs", - "rev": "b6018f87da91d19d0ab4cf979885689b469cdd41", + "rev": "65c6dc5c31a9d28dd6d1160a062e600dc36ddbea", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-25.11", + "owner": "sophiebsw", + "ref": "wordpress-fix-overriding-26.05", "repo": "nixpkgs", "type": "github" } diff --git a/wordpress/flake.nix b/wordpress/flake.nix index 88d3b01..302914d 100644 --- a/wordpress/flake.nix +++ b/wordpress/flake.nix @@ -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 = { @@ -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 = @@ -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} @@ -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 ''; }); @@ -86,12 +106,15 @@ [ twentytwentyfive twentytwentyfour + hestia ] ); plugins = mkWpContent "plugins" ( with pkgs.wordpressPackages.plugins; [ - hello-dolly + elementor + gtranslate + header-footer-builder-for-elementor ] ); in diff --git a/wordpress/pkgs/extraPlugins.json b/wordpress/pkgs/extraPlugins.json new file mode 100644 index 0000000..9315c72 --- /dev/null +++ b/wordpress/pkgs/extraPlugins.json @@ -0,0 +1,20 @@ +{ + "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" + }, + "header-footer-builder-for-elementor": { + "path": "header-footer-builder-for-elementor/tags/1.3.3", + "rev": "3729643", + "sha256": "sha256-GTCuDsi+b0eidT45Gcy07cbHDGp/Lem0nzudF8JIsYA=", + "version": "1.3.3" + } +} diff --git a/wordpress/pkgs/extraThemes.json b/wordpress/pkgs/extraThemes.json new file mode 100644 index 0000000..b2fed12 --- /dev/null +++ b/wordpress/pkgs/extraThemes.json @@ -0,0 +1,8 @@ +{ + "hestia": { + "path": "hestia/3.3.6", + "rev": "348036", + "sha256": "0ymv2r1kbv8c4lkka46jypacc8fj4snf5hwqxfznrl0a15rp5qd2", + "version": "3.3.6" + } +}