From 06e9b80bb8912dac1c87d5480ffdff9169233d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Thu, 27 Apr 2023 10:28:50 +0100 Subject: [PATCH] add somme themes --- .woodpecker/update.yaml | 1 + default.nix | 1 + flake.nix | 1 + overlay.nix | 1 + web/wordpress-themes/default.nix | 33 ++++++++++++++++++++++++++++++ web/wordpress-themes/sempress.json | 7 +++++++ web/wordpress-themes/themes | 1 + web/wordpress-themes/update.sh | 12 +++++++++++ 8 files changed, 57 insertions(+) create mode 100644 web/wordpress-themes/default.nix create mode 100644 web/wordpress-themes/sempress.json create mode 100644 web/wordpress-themes/themes create mode 100755 web/wordpress-themes/update.sh diff --git a/.woodpecker/update.yaml b/.woodpecker/update.yaml index d7c39f9..987219e 100644 --- a/.woodpecker/update.yaml +++ b/.woodpecker/update.yaml @@ -119,4 +119,5 @@ matrix: - element-web - woodpecker-server - wordpress-plugins + - wordpress-themes skip_clone: true diff --git a/default.nix b/default.nix index 9e09de3..a0964d9 100644 --- a/default.nix +++ b/default.nix @@ -69,6 +69,7 @@ in hydra hydra-unstable wordpress-plugins + wordpress-themes ; } // ( diff --git a/flake.nix b/flake.nix index 5c53f94..978e4a0 100644 --- a/flake.nix +++ b/flake.nix @@ -112,6 +112,7 @@ hydra hydra-unstable wordpress-plugins + wordpress-themes ; } // ( diff --git a/overlay.nix b/overlay.nix index da2c9a0..5f3bd8f 100644 --- a/overlay.nix +++ b/overlay.nix @@ -83,6 +83,7 @@ system: self: super: let }); hydra-unstable = self.hydra; wordpress-plugins = self.callPackage ./web/wordpress-plugins {}; + wordpress-themes = self.callPackage ./web/wordpress-themes {}; }) riscv-overlay ]; diff --git a/web/wordpress-themes/default.nix b/web/wordpress-themes/default.nix new file mode 100644 index 0000000..615cd52 --- /dev/null +++ b/web/wordpress-themes/default.nix @@ -0,0 +1,33 @@ +{ + stdenv, + fetchurl, + lib, + unzip, +}: +with builtins; +with lib; let + themes = lists.init (splitString "\n" (readFile ./themes)); +in + listToAttrs (map (name: { + inherit name; + value = let + source = importJSON ./${name}.json; + in + stdenv.mkDerivation { + inherit (source) pname version; + src = fetchurl { + inherit (source) url sha256; + }; + nativeBuildInputs = [unzip]; + unpackPhase = '' + unzip $src + ''; + installPhase = "mkdir -p $out; cp -R $pname/* $out/"; + meta = {inherit (source) description;}; + passthru.updateScript = + if name == "activitypub" + then ./update.sh + else []; + }; + }) + themes) diff --git a/web/wordpress-themes/sempress.json b/web/wordpress-themes/sempress.json new file mode 100644 index 0000000..6dcdc86 --- /dev/null +++ b/web/wordpress-themes/sempress.json @@ -0,0 +1,7 @@ +{ + "version": "1.7.0", + "pname": "sempress", + "description": "SemPress", + "url": "https://downloads.wordpress.org/theme/sempress.1.7.0.zip", + "sha256": "130c9c76c1db0f54ec21c318dad11498777e6ccb73df0f3cd3554f7c2ca07ad2" +} diff --git a/web/wordpress-themes/themes b/web/wordpress-themes/themes new file mode 100644 index 0000000..5182500 --- /dev/null +++ b/web/wordpress-themes/themes @@ -0,0 +1 @@ +sempress diff --git a/web/wordpress-themes/update.sh b/web/wordpress-themes/update.sh new file mode 100755 index 0000000..cea911b --- /dev/null +++ b/web/wordpress-themes/update.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl jq + +cd web/workpress-themes + +set -ex + +for plugin in $(cat themes); do + META=$(curl https://api.wordpress.org/themes/info/1.1/?action\=theme_information\&request\\\[slug\\\]\=$plugin) + SHA256=$(curl $(echo $META | jq -r '.download_link') | sha256sum | awk '{print $1}') + echo $META | jq '{"version": .version, "pname": .slug, "description": .name, "url": .download_link, "sha256": $SHA256}' --arg SHA256 $SHA256 > $plugin.json +done