about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorJonas Heinrich <onny@project-insanity.org>2022-05-19 15:48:13 +0200
committerYt <happysalada@proton.me>2022-10-07 00:23:06 +0900
commitd6c658f34fee0f1d75592e4420abd4d1100ca8cd (patch)
tree1354962ba93637eee2c59a9ef9d0f0e1cb263740 /pkgs
parente724f20ed5094faaa94ccfdd2d1f864f294381eb (diff)
wordpress: Add wordpressPackages
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/servers/web-apps/wordpress/packages/README.md46
-rw-r--r--pkgs/servers/web-apps/wordpress/packages/default.nix85
-rwxr-xr-xpkgs/servers/web-apps/wordpress/packages/generate.sh26
-rw-r--r--pkgs/servers/web-apps/wordpress/packages/languages.json14
-rw-r--r--pkgs/servers/web-apps/wordpress/packages/plugins.json122
-rw-r--r--pkgs/servers/web-apps/wordpress/packages/themes.json14
-rw-r--r--pkgs/servers/web-apps/wordpress/packages/wordpress-languages.json4
-rw-r--r--pkgs/servers/web-apps/wordpress/packages/wordpress-plugins.json22
-rw-r--r--pkgs/servers/web-apps/wordpress/packages/wordpress-themes.json4
-rw-r--r--pkgs/top-level/all-packages.nix6
10 files changed, 343 insertions, 0 deletions
diff --git a/pkgs/servers/web-apps/wordpress/packages/README.md b/pkgs/servers/web-apps/wordpress/packages/README.md
new file mode 100644
index 0000000000000..bb9dc033f3b32
--- /dev/null
+++ b/pkgs/servers/web-apps/wordpress/packages/README.md
@@ -0,0 +1,46 @@
+= Adding plugin, theme or language =
+
+To extend the wordpressPackages set, add a new line to the corresponding json
+file with the codename of the package:
+
+- `wordpress-languages.json` for language packs
+- `wordpress-themes.json` for themes
+- `wordpress-plugins.json` for plugins
+
+The codename is the last part in the url of the plugin or theme page, for
+example `cookie-notice` in in the url
+`https://wordpress.org/plugins/cookie-notice/` or `twentytwenty` in
+`https://wordpress.org/themes/twentytwenty/`.
+
+In case of language packages, the name consists of country and language codes.
+For example `de_DE` for country code `de` (Germany) and language `DE` (German).
+For available translations and language codes see [upstream translation repository](https://translate.wordpress.org).
+
+To regenerate the nixpkgs wordpressPackages set, run:
+
+``` 
+./generate.sh
+``` 
+
+After that you can commit and submit the changes.
+
+= Usage with the Wordpress module =
+
+The plugins will be available in the namespace `wordpressPackages.plugins`.
+Using it together with the Wordpress module could look like this:
+
+``` 
+services.wordpress = {
+  sites."blog.${config.networking.domain}" = {
+    plugins = with pkgs.wordpressPackages.plugins; [
+      anti-spam-bee
+      code-syntax-block
+      cookie-notice
+      lightbox-with-photoswipe
+      wp-gdpr-compliance
+    ];
+  };
+};
+```
+
+The same scheme applies to `themes` and `languages`.
diff --git a/pkgs/servers/web-apps/wordpress/packages/default.nix b/pkgs/servers/web-apps/wordpress/packages/default.nix
new file mode 100644
index 0000000000000..d8968de20c397
--- /dev/null
+++ b/pkgs/servers/web-apps/wordpress/packages/default.nix
@@ -0,0 +1,85 @@
+# Source: https://git.helsinki.tools/helsinki-systems/wp4nix/-/blob/master/default.nix
+# Licensed under: MIT
+# Slightly modified
+
+{ lib, newScope, plugins, themes, languages }:
+
+let packages = self:
+  let
+    generatedJson = {
+      inherit plugins themes languages;
+    };
+
+  in {
+    # Create a generic WordPress package. Most arguments are just passed
+    # to `mkDerivation`. The version is automatically filtered for weird characters.
+    mkWordpressDerivation = self.callPackage ({ stdenvNoCC, lib, filterWPString, gettext, wp-cli }:
+      { type, pname, version, ... }@args:
+        assert lib.any (x: x == type) [ "plugin" "theme" "language" ];
+        stdenvNoCC.mkDerivation ({
+          pname = "wordpress-${type}-${pname}";
+          version = filterWPString version;
+
+          dontConfigure = true;
+          dontBuild = true;
+
+          installPhase = ''
+            runHook preInstall
+            cp -R ./. $out
+            runHook postInstall
+          '';
+
+          passthru = {
+            wpName = pname;
+          } // (args.passthru or {});
+        } // lib.optionalAttrs (type == "language") {
+          nativeBuildInputs = [ gettext wp-cli ];
+          dontBuild = false;
+          buildPhase = ''
+            runHook preBuild
+
+            find -name '*.po' -print0 | while IFS= read -d "" -r po; do
+              msgfmt -o $(basename "$po" .po).mo "$po"
+            done
+            wp i18n make-json .
+            rm *.po
+
+            runHook postBuild
+          '';
+        } // removeAttrs args [ "type" "pname" "version" "passthru" ])) {};
+
+    # Create a derivation from the official wordpress.org packages.
+    # This takes the type, the pname and the data generated from the go tool.
+    mkOfficialWordpressDerivation = self.callPackage ({ mkWordpressDerivation, fetchWordpress }:
+      { type, pname, data }:
+      mkWordpressDerivation {
+        inherit type pname;
+        version = data.version;
+
+        src = fetchWordpress type data;
+      }) {};
+
+    # Filter out all characters that might occur in a version string but that that are not allowed
+    # in store paths.
+    filterWPString = builtins.replaceStrings [ " " "," "/" "&" ";" ''"'' "'" "$" ":" "(" ")" "[" "]" "{" "}" "|" "*" "\t" ] [ "_" "." "." "" "" "" "" "" "" "" "" "" "" "" "" "-" "" "" ];
+
+    # Fetch a package from the official wordpress.org SVN.
+    # The data supplied is the data straight from the go tool.
+    fetchWordpress = self.callPackage ({ fetchsvn }: type: data: fetchsvn {
+      inherit (data) rev sha256;
+      url = if type == "plugin" || type == "theme" then
+        "https://" + type + "s.svn.wordpress.org/" + data.path
+      else if type == "language" then
+        "https://i18n.svn.wordpress.org/core/" + data.version + "/" + data.path
+      else if type == "pluginLanguage" then
+        "https://i18n.svn.wordpress.org/plugins/" + data.path
+      else if type == "themeLanguage" then
+        "https://i18n.svn.wordpress.org/themes/" + data.path
+      else
+        throw "fetchWordpress: invalid package type ${type}";
+    }) {};
+
+  } // lib.mapAttrs (type: pkgs: lib.makeExtensible (_: lib.mapAttrs (pname: data: self.mkOfficialWordpressDerivation { type = lib.removeSuffix "s" type; inherit pname data; }) pkgs)) generatedJson;
+
+# This creates an extensible scope.
+in (lib.makeExtensible (_: (lib.makeScope newScope packages))).extend (selfWP: superWP: {})
diff --git a/pkgs/servers/web-apps/wordpress/packages/generate.sh b/pkgs/servers/web-apps/wordpress/packages/generate.sh
new file mode 100755
index 0000000000000..ebe58f526982f
--- /dev/null
+++ b/pkgs/servers/web-apps/wordpress/packages/generate.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env nix-shell
+#! nix-shell -I nixpkgs=../../../../.. -i bash -p wp4nix
+
+set -e
+set -u
+set -o pipefail
+set -x
+
+NIX_VERSION=$(nix --version|cut -d ' ' -f 3|cut -c -3)
+if [[ "$NIX_VERSION" > 2.3 ]]; then
+  nixFlags="--option experimental-features nix-command eval --raw --impure --expr"
+else
+  nixFlags="eval --raw"
+fi
+
+export WP_VERSION=$(nix $nixFlags '(import <nixpkgs> {}).wordpress.version')
+
+PLUGINS=`cat wordpress-plugins.json | jq -r '.[]' | sed -z 's/\n/,/g;s/,$/\n/'`
+THEMES=`cat wordpress-themes.json | jq -r '.[]' | sed -z 's/\n/,/g;s/,$/\n/'`
+LANGUAGES=`cat wordpress-languages.json | jq -r '.[]' | sed -z 's/\n/,/g;s/,$/\n/'`
+
+wp4nix -p $PLUGINS -pl en
+wp4nix -t $THEMES -tl en
+wp4nix -l $LANGUAGES
+
+rm *.log themeLanguages.json pluginLanguages.json
diff --git a/pkgs/servers/web-apps/wordpress/packages/languages.json b/pkgs/servers/web-apps/wordpress/packages/languages.json
new file mode 100644
index 0000000000000..f5847cad4c9be
--- /dev/null
+++ b/pkgs/servers/web-apps/wordpress/packages/languages.json
@@ -0,0 +1,14 @@
+{
+  "de_DE": {
+    "path": "de_DE",
+    "rev": "932483",
+    "sha256": "1n4rf1bkr8xr6yqxd7c6s4ha3ll819fbfiqln57is9knfpdd6fnq",
+    "version": "5.8"
+  },
+  "fr_FR": {
+    "path": "fr_FR",
+    "rev": "932480",
+    "sha256": "0lmbalcvwfc6331vdazmhr2lp3w418rsp78mrj1rs7a44y8f1igj",
+    "version": "5.8"
+  }
+}
diff --git a/pkgs/servers/web-apps/wordpress/packages/plugins.json b/pkgs/servers/web-apps/wordpress/packages/plugins.json
new file mode 100644
index 0000000000000..4370eab7851a1
--- /dev/null
+++ b/pkgs/servers/web-apps/wordpress/packages/plugins.json
@@ -0,0 +1,122 @@
+{
+  "add-widget-after-content": {
+    "path": "add-widget-after-content/tags/2.4.4",
+    "rev": "2671853",
+    "sha256": "0snrkd783f1qxry01858l3r0ll9381xhsig7wlmrvi1zm5jf2drc",
+    "version": "2.4.4"
+  },
+  "antispam-bee": {
+    "path": "antispam-bee/tags/2.11.1",
+    "rev": "2748316",
+    "sha256": "1hjq1yazvypc84lwcjq7za1n3s7vcxd9mc50adpinkwjjph1cgxn",
+    "version": "2.11.1"
+  },
+  "async-javascript": {
+    "path": "async-javascript/tags/2.21.08.31",
+    "rev": "2760769",
+    "sha256": "1yf3pj0nn4gyl0a2wfvznpwb7y0glxg19rgny3bh38k4pj9mli49",
+    "version": "2.21.08.31"
+  },
+  "breeze": {
+    "path": "breeze/tags/2.0.9",
+    "rev": "2786857",
+    "sha256": "0nn3kalwb50kyd563jiixc134hiygkbzs8zkxgsbgmsi511vfzkz",
+    "version": "2.0.9"
+  },
+  "co-authors-plus": {
+    "path": "co-authors-plus/tags/3.5.2",
+    "rev": "2735979",
+    "sha256": "0ph3iskixi2j6bsnlpd4x8wixzm2hbdzchnyfz9mxzzys93qb41k",
+    "version": "3.5.2"
+  },
+  "code-syntax-block": {
+    "path": "code-syntax-block/tags/3.1.1",
+    "rev": "2747615",
+    "sha256": "0dqdsl7f3ihshvly6cqd5l4cbimx5skmips514wvifspwggwmmjm",
+    "version": "3.1.1"
+  },
+  "cookie-notice": {
+    "path": "cookie-notice/tags/2.4.1",
+    "rev": "2790369",
+    "sha256": "1a1qnmi81z8c30d6zgcd5xqd08cxkq71g2hzb6xcbdv04036nf77",
+    "version": "2.4.1"
+  },
+  "disable-xml-rpc": {
+    "path": "disable-xml-rpc/tags/1.0.1",
+    "rev": "2561901",
+    "sha256": "04x5dj79bx5avx8db991nlhrpd3qv3maniqmzwnyd8ab2zblzx83",
+    "version": "1.0.1"
+  },
+  "jetpack": {
+    "path": "jetpack/tags/11.4",
+    "rev": "2794223",
+    "sha256": "123kfn6wn23sz7zv8yk8rszrxwnjgjfrm0cqpwmrs3h1plfqv7kg",
+    "version": "11.4"
+  },
+  "jetpack-lite": {
+    "path": "jetpack-lite/tags/3.0.3",
+    "rev": "1895157",
+    "sha256": "04wq8cnhzgzrhm5pjwicsnavc46n6wdmb6xf8gz4wwl1di2hl471",
+    "version": "3.0.3"
+  },
+  "lightbox-photoswipe": {
+    "path": "lightbox-photoswipe/tags/5.0.16",
+    "rev": "2790158",
+    "sha256": "1pd83v7nz2l002z1y27h97gmhcdcbvsfi8x7llrg9vzijrx0vf18",
+    "version": "5.0.16"
+  },
+  "mailpoet": {
+    "path": "mailpoet/tags/3.100.1",
+    "rev": "2795092",
+    "sha256": "0wgzmicf6mmkmkwsxxaz2d8sylvq6v0a98nbc2yswd11l4igc8ld",
+    "version": "3.100.1"
+  },
+  "opengraph": {
+    "path": "opengraph/tags/1.11.0",
+    "rev": "2730257",
+    "sha256": "133mzlccbdpppps1aq83n2az4xzikak61k4rdzg9aax23l5ggss6",
+    "version": "1.11.0"
+  },
+  "simple-login-captcha": {
+    "path": "simple-login-captcha/tags/1.3.3",
+    "rev": "2729196",
+    "sha256": "1wy9cbibbngjarc8c9qn4bil3qc8i0h2kz0k364zcsnfpwi8jk3c",
+    "version": "1.3.3"
+  },
+  "webp-converter-for-media": {
+    "path": "webp-converter-for-media/tags/5.2.4",
+    "rev": "2791011",
+    "sha256": "18y0yrngywz0zlxd67cn16nvzypb395rhsfavfyl6pq0ygymcxnm",
+    "version": "5.2.4"
+  },
+  "wp-change-email-sender": {
+    "path": "wp-change-email-sender/trunk",
+    "rev": "2655179",
+    "sha256": "0dv5604mn4ly2zm6mwqf5y8vp9cfiw70v66bimvgbahxz4i2w23q",
+    "version": "1.0"
+  },
+  "wp-gdpr-compliance": {
+    "path": "wp-gdpr-compliance/tags/2.0.20",
+    "rev": "2793947",
+    "sha256": "1vvwmi03hjyqw566m75m8lxbhnl3y4h461531a26xwsbmjgbmf9a",
+    "version": "2.0.20"
+  },
+  "wp-mail-smtp": {
+    "path": "wp-mail-smtp/tags/3.6.1",
+    "rev": "2795051",
+    "sha256": "14ry7302c4h7d7lrasiql9jiy3x54ylim3y7j5b633g5lyzadynl",
+    "version": "3.6.1"
+  },
+  "wp-statistics": {
+    "path": "wp-statistics/tags/13.2.6",
+    "rev": "2781181",
+    "sha256": "0vzlhlnna2dx4kyi24rqhbrx5n5zsw51hqgsaslfiyyir64dkzgz",
+    "version": "13.2.6"
+  },
+  "wp-user-avatars": {
+    "path": "wp-user-avatars/trunk",
+    "rev": "2540784",
+    "sha256": "1g21nl6xs9zyq0ainjwa06wl90975l8f9rj0fa20zkmw17w2mdgl",
+    "version": "1.4.1"
+  }
+}
diff --git a/pkgs/servers/web-apps/wordpress/packages/themes.json b/pkgs/servers/web-apps/wordpress/packages/themes.json
new file mode 100644
index 0000000000000..a67d0d9818ae5
--- /dev/null
+++ b/pkgs/servers/web-apps/wordpress/packages/themes.json
@@ -0,0 +1,14 @@
+{
+  "twentytwentyone": {
+    "path": "twentytwentyone/1.6",
+    "rev": "168450",
+    "sha256": "0wfqdyd59hifnncjv59ywjak050gaggsvjx7r01agh44nzkr84fs",
+    "version": "1.6"
+  },
+  "twentytwentytwo": {
+    "path": "twentytwentytwo/1.2",
+    "rev": "168451",
+    "sha256": "0ry7h5bd9h97q38jmsgymm05dfml0ycdhqn7iskpdlc1nnrjrk04",
+    "version": "1.2"
+  }
+}
diff --git a/pkgs/servers/web-apps/wordpress/packages/wordpress-languages.json b/pkgs/servers/web-apps/wordpress/packages/wordpress-languages.json
new file mode 100644
index 0000000000000..53227cfa0fcf0
--- /dev/null
+++ b/pkgs/servers/web-apps/wordpress/packages/wordpress-languages.json
@@ -0,0 +1,4 @@
+[
+  "de_DE"
+, "fr_FR"
+]
diff --git a/pkgs/servers/web-apps/wordpress/packages/wordpress-plugins.json b/pkgs/servers/web-apps/wordpress/packages/wordpress-plugins.json
new file mode 100644
index 0000000000000..5cf542b457c64
--- /dev/null
+++ b/pkgs/servers/web-apps/wordpress/packages/wordpress-plugins.json
@@ -0,0 +1,22 @@
+[
+  "add-widget-after-content"
+, "antispam-bee"
+, "async-javascript"
+, "breeze"
+, "code-syntax-block"
+, "cookie-notice"
+, "co-authors-plus"
+, "disable-xml-rpc"
+, "jetpack"
+, "jetpack-lite"
+, "lightbox-photoswipe"
+, "mailpoet"
+, "opengraph"
+, "simple-login-captcha"
+, "webp-converter-for-media"
+, "wp-mail-smtp"
+, "wp-gdpr-compliance"
+, "wp-statistics"
+, "wp-user-avatars"
+, "wp-change-email-sender"
+]
diff --git a/pkgs/servers/web-apps/wordpress/packages/wordpress-themes.json b/pkgs/servers/web-apps/wordpress/packages/wordpress-themes.json
new file mode 100644
index 0000000000000..80141817ee9b3
--- /dev/null
+++ b/pkgs/servers/web-apps/wordpress/packages/wordpress-themes.json
@@ -0,0 +1,4 @@
+[
+  "twentytwentytwo"
+, "twentytwentyone"
+]
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 3cbcb3076ca45..872a4bd4eba6d 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -36902,6 +36902,12 @@ with pkgs;
 
   wordpress = callPackage ../servers/web-apps/wordpress { };
 
+  wordpressPackages = ( callPackage ../servers/web-apps/wordpress/packages {
+    plugins = lib.importJSON ../servers/web-apps/wordpress/packages/plugins.json;
+    themes = lib.importJSON ../servers/web-apps/wordpress/packages/themes.json;
+    languages = lib.importJSON ../servers/web-apps/wordpress/packages/languages.json;
+  });
+
   wprecon = callPackage ../tools/security/wprecon { };
 
   wraith = callPackage ../applications/networking/irc/wraith {