summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonas Heinrich <onny@project-insanity.org>2022-09-13 17:17:26 +0200
committerYt <happysalada@proton.me>2022-10-01 00:44:32 +0900
commitb881869205e82652b4c5ce7ebff3b3fea5a4817b (patch)
tree9548e0ac65d5e25f0c51f2207f6e35837401a9ff
parent7f3b66af6d7904d6e41703c7903f08b65b302f4f (diff)
downloadnixpkgs-b881869205e82652b4c5ce7ebff3b3fea5a4817b.tar
nixpkgs-b881869205e82652b4c5ce7ebff3b3fea5a4817b.tar.gz
nixpkgs-b881869205e82652b4c5ce7ebff3b3fea5a4817b.tar.bz2
nixpkgs-b881869205e82652b4c5ce7ebff3b3fea5a4817b.tar.lz
nixpkgs-b881869205e82652b4c5ce7ebff3b3fea5a4817b.tar.xz
nixpkgs-b881869205e82652b4c5ce7ebff3b3fea5a4817b.tar.zst
nixpkgs-b881869205e82652b4c5ce7ebff3b3fea5a4817b.zip
nixos/wordpress: Add language support
-rw-r--r--nixos/doc/manual/from_md/release-notes/rl-2211.section.xml7
-rw-r--r--nixos/doc/manual/release-notes/rl-2211.section.md2
-rw-r--r--nixos/modules/services/web-apps/wordpress.nix29
3 files changed, 37 insertions, 1 deletions
diff --git a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
index bfe04d89fa8..8494b62e6ff 100644
--- a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
+++ b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
@@ -769,6 +769,13 @@
       </listitem>
       <listitem>
         <para>
+          The Wordpress module got support for installing language packs
+          through
+          <literal>services.wordpress.sites.&lt;site&gt;.languages</literal>.
+        </para>
+      </listitem>
+      <listitem>
+        <para>
           There is a new module for the <literal>thunar</literal>
           program (the Xfce file manager), which depends on the
           <literal>xfconf</literal> dbus service, and also has a dbus
diff --git a/nixos/doc/manual/release-notes/rl-2211.section.md b/nixos/doc/manual/release-notes/rl-2211.section.md
index dcbe545a626..a5ba4841f54 100644
--- a/nixos/doc/manual/release-notes/rl-2211.section.md
+++ b/nixos/doc/manual/release-notes/rl-2211.section.md
@@ -254,6 +254,8 @@ Available as [services.patroni](options.html#opt-services.patroni.enable).
 
 - There is a new module for AMD SEV CPU functionality, which grants access to the hardware.
 
+- The Wordpress module got support for installing language packs through `services.wordpress.sites.<site>.languages`.
+
 - There is a new module for the `thunar` program (the Xfce file manager), which depends on the `xfconf` dbus service, and also has a dbus service and a systemd unit. The option `services.xserver.desktopManager.xfce.thunarPlugins` has been renamed to `programs.thunar.plugins`, and in a future release it may be removed.
 
 - There is a new module for the `xfconf` program (the Xfce configuration storage system), which has a dbus service.
diff --git a/nixos/modules/services/web-apps/wordpress.nix b/nixos/modules/services/web-apps/wordpress.nix
index f2e78d02855..d3dda27c3d6 100644
--- a/nixos/modules/services/web-apps/wordpress.nix
+++ b/nixos/modules/services/web-apps/wordpress.nix
@@ -30,9 +30,10 @@ let
       # requests that look like: https://example.com/wp-content//nix/store/...plugin/path/some-file.js
       # Since hard linking directories is not allowed, copying is the next best thing.
 
-      # copy additional plugin(s) and theme(s)
+      # 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}
+      ${concatMapStringsSep "\n" (language: "cp -r ${language} $out/share/wordpress/wp-content/languages/") cfg.languages}
     '';
   };
 
@@ -154,6 +155,32 @@ let
           '';
         };
 
+        languages = mkOption {
+          type = types.listOf types.path;
+          default = [];
+          description = lib.mdDoc ''
+            List of path(s) to respective language(s) which are copied from the 'languages' directory.
+          '';
+          example = literalExpression ''
+            [(
+              # Let's package the German language.
+              # For other languages try to replace language and country code in the download URL with your desired one.
+              # Reference https://translate.wordpress.org for available translations and
+              # codes.
+              language-de = pkgs.stdenv.mkDerivation {
+                name = "language-de";
+                src = pkgs.fetchurl {
+                  url = "https://de.wordpress.org/wordpress-''${pkgs.wordpress.version}-de_DE.tar.gz";
+                  # Name is required to invalidate the hash when wordpress is updated
+                  name = "wordpress-''${pkgs.wordpress.version}-language-de"
+                  sha256 = "sha256-dlas0rXTSV4JAl8f/UyMbig57yURRYRhTMtJwF9g8h0=";
+                };
+                installPhase = "mkdir -p $out; cp -r ./wp-content/languages/* $out/";
+              };
+            )];
+          '';
+        };
+
         database = {
           host = mkOption {
             type = types.str;