From 66e0e5ad74497c114784cb5db8344a2d4b757fe9 Mon Sep 17 00:00:00 2001 From: Colin Arnott Date: Sat, 14 Jan 2023 10:26:45 +0000 Subject: nixos/wordpress: plugins and themes as attrs In an effort to better encode version strings and use descriptive pnames that do not conflict with top level pkgs, we currently use wordpress-${type}-${pname} for pname. This is good for the nix store, but when we synthesize the wordpress derivation in our module, we reuse this pname for the output directory. Internally wordpress can handle this fine, since plugins must register via php, not directory. Unfortunately, many plugins like civicrm and wpforms-lite are designed to rely upon the name of their install directory for homing or discovery. As such, we should follow both the upstream convention and services.nextcloud.extraApps and use an attribute set for these options. This allows us to not have to deal with the implementation details of plugins and themes, which differ from official and third party, but also give users the option to override the install location. The only issue is that it breaks the current api. --- .../from_md/release-notes/rl-2305.section.xml | 11 ++++ nixos/doc/manual/release-notes/rl-2305.section.md | 2 + nixos/modules/services/web-apps/wordpress.nix | 62 ++++++++-------------- 3 files changed, 35 insertions(+), 40 deletions(-) (limited to 'nixos') diff --git a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml index cf22e2dbb3f5..8679bb4b70ff 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml @@ -352,6 +352,17 @@ updated manually. + + + The + services.wordpress.sites.<name>.plugins + and + services.wordpress.sites.<name>.themes + options have been converted from sets to attribute sets to + allow for consumers to specify explicit install paths via + attribute name. + + In mastodon it is now necessary to specify diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index 1b031b716c84..db80ccc9b720 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -87,6 +87,8 @@ In addition to numerous new and upgraded packages, this release has the followin - Qt 5.12 and 5.14 have been removed, as the corresponding branches have been EOL upstream for a long time. This affected under 10 packages in nixpkgs, largely unmaintained upstream as well, however, out-of-tree package expressions may need to be updated manually. +- The [services.wordpress.sites.<name>.plugins](#opt-services.wordpress.sites._name_.plugins) and [services.wordpress.sites.<name>.themes](#opt-services.wordpress.sites._name_.themes) options have been converted from sets to attribute sets to allow for consumers to specify explicit install paths via attribute name. + - In `mastodon` it is now necessary to specify location of file with `PostgreSQL` database password. In `services.mastodon.database.passwordFile` parameter default value `/var/lib/mastodon/secrets/db-password` has been changed to `null`. - The `--target-host` and `--build-host` options of `nixos-rebuild` no longer treat the `localhost` value specially – to build on/deploy to local machine, omit the relevant flag. diff --git a/nixos/modules/services/web-apps/wordpress.nix b/nixos/modules/services/web-apps/wordpress.nix index 416ad8556bdd..a8788bf84403 100644 --- a/nixos/modules/services/web-apps/wordpress.nix +++ b/nixos/modules/services/web-apps/wordpress.nix @@ -32,8 +32,8 @@ let # Since hard linking directories is not allowed, copying is the next best thing. # copy additional plugin(s), theme(s) and language(s) - ${concatMapStringsSep "\n" (theme: "cp -r ${theme} $out/share/wordpress/wp-content/themes/${theme.name}") cfg.themes} - ${concatMapStringsSep "\n" (plugin: "cp -r ${plugin} $out/share/wordpress/wp-content/plugins/${plugin.name}") cfg.plugins} + ${concatStringsSep "\n" (mapAttrsToList (name: theme: "cp -r ${theme} $out/share/wordpress/wp-content/themes/${name}") cfg.themes)} + ${concatStringsSep "\n" (mapAttrsToList (name: plugin: "cp -r ${plugin} $out/share/wordpress/wp-content/plugins/${name}") cfg.plugins)} ${concatMapStringsSep "\n" (language: "cp -r ${language} $out/share/wordpress/wp-content/languages/") cfg.languages} ''; }; @@ -130,62 +130,44 @@ let }; plugins = mkOption { - type = types.listOf types.path; - default = []; + type = with types; coercedTo + (listOf path) + (l: warn "setting this option with a list is deprecated" + listToAttrs (map (p: nameValuePair (p.name or (throw "${p} does not have a name")) p) l)) + (attrsOf path); + default = {}; description = lib.mdDoc '' - List of path(s) to respective plugin(s) which are copied from the 'plugins' directory. + Path(s) to respective plugin(s) which are copied from the 'plugins' directory. ::: {.note} These plugins need to be packaged before use, see example. ::: ''; example = literalExpression '' - let - # Wordpress plugin 'embed-pdf-viewer' installation example - embedPdfViewerPlugin = pkgs.stdenv.mkDerivation { - name = "embed-pdf-viewer-plugin"; - # Download the theme from the wordpress site - src = pkgs.fetchurl { - url = "https://downloads.wordpress.org/plugin/embed-pdf-viewer.2.0.3.zip"; - sha256 = "1rhba5h5fjlhy8p05zf0p14c9iagfh96y91r36ni0rmk6y891lyd"; - }; - # We need unzip to build this package - nativeBuildInputs = [ pkgs.unzip ]; - # Installing simply means copying all files to the output directory - installPhase = "mkdir -p $out; cp -R * $out/"; - }; - # And then pass this theme to the themes list like this: - in [ embedPdfViewerPlugin ] + { + inherit (pkgs.wordpressPackages.plugins) embed-pdf-viewer-plugin; + } ''; }; themes = mkOption { - type = types.listOf types.path; - default = []; + type = with types; coercedTo + (listOf path) + (l: warn "setting this option with a list is deprecated" + listToAttrs (map (p: nameValuePair (p.name or throw "${p} does not have a name") p) l)) + (attrsOf path); + default = {}; description = lib.mdDoc '' - List of path(s) to respective theme(s) which are copied from the 'theme' directory. + Path(s) to respective theme(s) which are copied from the 'theme' directory. ::: {.note} These themes need to be packaged before use, see example. ::: ''; example = literalExpression '' - let - # Let's package the responsive theme - responsiveTheme = pkgs.stdenv.mkDerivation { - name = "responsive-theme"; - # Download the theme from the wordpress site - src = pkgs.fetchurl { - url = "https://downloads.wordpress.org/theme/responsive.3.14.zip"; - sha256 = "0rjwm811f4aa4q43r77zxlpklyb85q08f9c8ns2akcarrvj5ydx3"; - }; - # We need unzip to build this package - nativeBuildInputs = [ pkgs.unzip ]; - # Installing simply means copying all files to the output directory - installPhase = "mkdir -p $out; cp -R * $out/"; - }; - # And then pass this theme to the themes list like this: - in [ responsiveTheme ] + { + inherit (pkgs.wordpressPackages.themes) responsive-theme; + } ''; }; -- cgit v1.2.3 From aefbc9623b7855bb4a64ea874350d078925912be Mon Sep 17 00:00:00 2001 From: Colin Arnott Date: Fri, 27 Jan 2023 07:14:38 +0000 Subject: nextcloud26: init at 26.0.0beta1 Because nextcloud ships their prerelease versions on a different url, we are not parsing the version string to detect which path to use. We also enabled and validated this change via nixos module testing. --- nixos/tests/nextcloud/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos') diff --git a/nixos/tests/nextcloud/default.nix b/nixos/tests/nextcloud/default.nix index b8d3ba75b51a..350486e8c733 100644 --- a/nixos/tests/nextcloud/default.nix +++ b/nixos/tests/nextcloud/default.nix @@ -26,4 +26,4 @@ foldl }; }) { } - [ 24 25 ] + [ 24 25 26 ] -- cgit v1.2.3 From 748c2b416c96658254976061736237251d754fbc Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 27 Jan 2023 16:35:46 +0100 Subject: nixos/wordpress: fix minor syntax error --- nixos/modules/services/web-apps/wordpress.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos') diff --git a/nixos/modules/services/web-apps/wordpress.nix b/nixos/modules/services/web-apps/wordpress.nix index a8788bf84403..aabfb2261bb6 100644 --- a/nixos/modules/services/web-apps/wordpress.nix +++ b/nixos/modules/services/web-apps/wordpress.nix @@ -154,7 +154,7 @@ let type = with types; coercedTo (listOf path) (l: warn "setting this option with a list is deprecated" - listToAttrs (map (p: nameValuePair (p.name or throw "${p} does not have a name") p) l)) + listToAttrs (map (p: nameValuePair (p.name or (throw "${p} does not have a name")) p) l)) (attrsOf path); default = {}; description = lib.mdDoc '' -- cgit v1.2.3 From 1754920c76b6fd0142a680b74e887022b244f3e7 Mon Sep 17 00:00:00 2001 From: Colin Arnott Date: Sun, 15 Jan 2023 10:15:58 +0000 Subject: wordpress: remove bundled plugins and themes Wordpress bundles some non-essential plugins and themes, then pesters users to upgrade them. As we make the whole webroot readonly, it is not possible to trivially delete them. Instead we should have users explicitly install plugins via the existing nixos module. --- nixos/doc/manual/from_md/release-notes/rl-2305.section.xml | 8 ++++++++ nixos/doc/manual/release-notes/rl-2305.section.md | 2 ++ 2 files changed, 10 insertions(+) (limited to 'nixos') diff --git a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml index 8679bb4b70ff..54c7da4279a5 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml @@ -302,6 +302,14 @@ here. + + + The wordpress derivation no longer contains + any builtin plugins or themes; these can be found in + wordpressPackages.{plugins,themes}, + respectively. + + llvmPackages_rocm.llvm will not contain diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index db80ccc9b720..19b3d2f7e121 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -77,6 +77,8 @@ In addition to numerous new and upgraded packages, this release has the followin - `tut` has been updated from 1.0.34 to 2.0.0, and now uses the TOML format for the configuration file instead of INI. Additional information can be found [here](https://github.com/RasmusLindroth/tut/releases/tag/2.0.0). +- The `wordpress` derivation no longer contains any builtin plugins or themes; these can be found in `wordpressPackages.{plugins,themes}`, respectively. + - `llvmPackages_rocm.llvm` will not contain `clang` or `compiler-rt`. `llvmPackages_rocm.clang` will not contain `llvm`. `llvmPackages_rocm.clangNoCompilerRt` has been removed in favor of using `llvmPackages_rocm.clang-unwrapped`. - The EC2 image module previously detected and automatically mounted ext3-formatted instance store devices and partitions in stage-1 (initramfs), storing `/tmp` on the first discovered device. This behaviour, which only catered to very specific use cases and could not be disabled, has been removed. Users relying on this should provide their own implementation, and probably use ext4 and perform the mount in stage-2. -- cgit v1.2.3 From 64f3a304dbe68237f7fe172cb283e27f82da1ab9 Mon Sep 17 00:00:00 2001 From: Colin Arnott Date: Sun, 15 Jan 2023 11:43:27 +0000 Subject: nixos/wordpress: ensure default sites includes a theme --- nixos/doc/manual/from_md/release-notes/rl-2305.section.xml | 6 +++--- nixos/doc/manual/release-notes/rl-2305.section.md | 2 +- nixos/modules/services/web-apps/wordpress.nix | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'nixos') diff --git a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml index 54c7da4279a5..69a6ff4aac05 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml @@ -305,9 +305,9 @@ The wordpress derivation no longer contains - any builtin plugins or themes; these can be found in - wordpressPackages.{plugins,themes}, - respectively. + any builtin plugins or themes. If you need them you have to + add them back to prevent your site from breaking. You can find + them in wordpressPackages.{plugins,themes}. diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index 19b3d2f7e121..b33221714ab5 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -77,7 +77,7 @@ In addition to numerous new and upgraded packages, this release has the followin - `tut` has been updated from 1.0.34 to 2.0.0, and now uses the TOML format for the configuration file instead of INI. Additional information can be found [here](https://github.com/RasmusLindroth/tut/releases/tag/2.0.0). -- The `wordpress` derivation no longer contains any builtin plugins or themes; these can be found in `wordpressPackages.{plugins,themes}`, respectively. +- The `wordpress` derivation no longer contains any builtin plugins or themes. If you need them you have to add them back to prevent your site from breaking. You can find them in `wordpressPackages.{plugins,themes}`. - `llvmPackages_rocm.llvm` will not contain `clang` or `compiler-rt`. `llvmPackages_rocm.clang` will not contain `llvm`. `llvmPackages_rocm.clangNoCompilerRt` has been removed in favor of using `llvmPackages_rocm.clang-unwrapped`. diff --git a/nixos/modules/services/web-apps/wordpress.nix b/nixos/modules/services/web-apps/wordpress.nix index aabfb2261bb6..d4c987da1144 100644 --- a/nixos/modules/services/web-apps/wordpress.nix +++ b/nixos/modules/services/web-apps/wordpress.nix @@ -156,7 +156,8 @@ let (l: warn "setting this option with a list is deprecated" listToAttrs (map (p: nameValuePair (p.name or (throw "${p} does not have a name")) p) l)) (attrsOf path); - default = {}; + default = { inherit (pkgs.wordpressPackages.themes) twentytwentythree; }; + defaultText = literalExpression "{ inherit (pkgs.wordpressPackages.themes) twentytwentythree; }"; description = lib.mdDoc '' Path(s) to respective theme(s) which are copied from the 'theme' directory. -- cgit v1.2.3