Merge pull request #210686 from urandom2/wordpress2

nixos/wordpress: plugins and themes as attrs

authored by Jonas Heinrich and committed by GitHub 7a60b737 ebf6fc34

+35 -40
+11
nixos/doc/manual/from_md/release-notes/rl-2305.section.xml
··· 354 </listitem> 355 <listitem> 356 <para> 357 In <literal>mastodon</literal> it is now necessary to specify 358 location of file with <literal>PostgreSQL</literal> database 359 password. In
··· 354 </listitem> 355 <listitem> 356 <para> 357 + The 358 + <link linkend="opt-services.wordpress.sites._name_.plugins">services.wordpress.sites.&lt;name&gt;.plugins</link> 359 + and 360 + <link linkend="opt-services.wordpress.sites._name_.themes">services.wordpress.sites.&lt;name&gt;.themes</link> 361 + options have been converted from sets to attribute sets to 362 + allow for consumers to specify explicit install paths via 363 + attribute name. 364 + </para> 365 + </listitem> 366 + <listitem> 367 + <para> 368 In <literal>mastodon</literal> it is now necessary to specify 369 location of file with <literal>PostgreSQL</literal> database 370 password. In
+2
nixos/doc/manual/release-notes/rl-2305.section.md
··· 87 88 - 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. 89 90 - 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`. 91 92 - 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.
··· 87 88 - 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. 89 90 + - The [services.wordpress.sites.&lt;name&gt;.plugins](#opt-services.wordpress.sites._name_.plugins) and [services.wordpress.sites.&lt;name&gt;.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. 91 + 92 - 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`. 93 94 - 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.
+22 -40
nixos/modules/services/web-apps/wordpress.nix
··· 32 # Since hard linking directories is not allowed, copying is the next best thing. 33 34 # copy additional plugin(s), theme(s) and language(s) 35 - ${concatMapStringsSep "\n" (theme: "cp -r ${theme} $out/share/wordpress/wp-content/themes/${theme.name}") cfg.themes} 36 - ${concatMapStringsSep "\n" (plugin: "cp -r ${plugin} $out/share/wordpress/wp-content/plugins/${plugin.name}") cfg.plugins} 37 ${concatMapStringsSep "\n" (language: "cp -r ${language} $out/share/wordpress/wp-content/languages/") cfg.languages} 38 ''; 39 }; ··· 130 }; 131 132 plugins = mkOption { 133 - type = types.listOf types.path; 134 - default = []; 135 description = lib.mdDoc '' 136 - List of path(s) to respective plugin(s) which are copied from the 'plugins' directory. 137 138 ::: {.note} 139 These plugins need to be packaged before use, see example. 140 ::: 141 ''; 142 example = literalExpression '' 143 - let 144 - # Wordpress plugin 'embed-pdf-viewer' installation example 145 - embedPdfViewerPlugin = pkgs.stdenv.mkDerivation { 146 - name = "embed-pdf-viewer-plugin"; 147 - # Download the theme from the wordpress site 148 - src = pkgs.fetchurl { 149 - url = "https://downloads.wordpress.org/plugin/embed-pdf-viewer.2.0.3.zip"; 150 - sha256 = "1rhba5h5fjlhy8p05zf0p14c9iagfh96y91r36ni0rmk6y891lyd"; 151 - }; 152 - # We need unzip to build this package 153 - nativeBuildInputs = [ pkgs.unzip ]; 154 - # Installing simply means copying all files to the output directory 155 - installPhase = "mkdir -p $out; cp -R * $out/"; 156 - }; 157 - # And then pass this theme to the themes list like this: 158 - in [ embedPdfViewerPlugin ] 159 ''; 160 }; 161 162 themes = mkOption { 163 - type = types.listOf types.path; 164 - default = []; 165 description = lib.mdDoc '' 166 - List of path(s) to respective theme(s) which are copied from the 'theme' directory. 167 168 ::: {.note} 169 These themes need to be packaged before use, see example. 170 ::: 171 ''; 172 example = literalExpression '' 173 - let 174 - # Let's package the responsive theme 175 - responsiveTheme = pkgs.stdenv.mkDerivation { 176 - name = "responsive-theme"; 177 - # Download the theme from the wordpress site 178 - src = pkgs.fetchurl { 179 - url = "https://downloads.wordpress.org/theme/responsive.3.14.zip"; 180 - sha256 = "0rjwm811f4aa4q43r77zxlpklyb85q08f9c8ns2akcarrvj5ydx3"; 181 - }; 182 - # We need unzip to build this package 183 - nativeBuildInputs = [ pkgs.unzip ]; 184 - # Installing simply means copying all files to the output directory 185 - installPhase = "mkdir -p $out; cp -R * $out/"; 186 - }; 187 - # And then pass this theme to the themes list like this: 188 - in [ responsiveTheme ] 189 ''; 190 }; 191
··· 32 # Since hard linking directories is not allowed, copying is the next best thing. 33 34 # copy additional plugin(s), theme(s) and language(s) 35 + ${concatStringsSep "\n" (mapAttrsToList (name: theme: "cp -r ${theme} $out/share/wordpress/wp-content/themes/${name}") cfg.themes)} 36 + ${concatStringsSep "\n" (mapAttrsToList (name: plugin: "cp -r ${plugin} $out/share/wordpress/wp-content/plugins/${name}") cfg.plugins)} 37 ${concatMapStringsSep "\n" (language: "cp -r ${language} $out/share/wordpress/wp-content/languages/") cfg.languages} 38 ''; 39 }; ··· 130 }; 131 132 plugins = mkOption { 133 + type = with types; coercedTo 134 + (listOf path) 135 + (l: warn "setting this option with a list is deprecated" 136 + listToAttrs (map (p: nameValuePair (p.name or (throw "${p} does not have a name")) p) l)) 137 + (attrsOf path); 138 + default = {}; 139 description = lib.mdDoc '' 140 + Path(s) to respective plugin(s) which are copied from the 'plugins' directory. 141 142 ::: {.note} 143 These plugins need to be packaged before use, see example. 144 ::: 145 ''; 146 example = literalExpression '' 147 + { 148 + inherit (pkgs.wordpressPackages.plugins) embed-pdf-viewer-plugin; 149 + } 150 ''; 151 }; 152 153 themes = mkOption { 154 + type = with types; coercedTo 155 + (listOf path) 156 + (l: warn "setting this option with a list is deprecated" 157 + listToAttrs (map (p: nameValuePair (p.name or (throw "${p} does not have a name")) p) l)) 158 + (attrsOf path); 159 + default = {}; 160 description = lib.mdDoc '' 161 + Path(s) to respective theme(s) which are copied from the 'theme' directory. 162 163 ::: {.note} 164 These themes need to be packaged before use, see example. 165 ::: 166 ''; 167 example = literalExpression '' 168 + { 169 + inherit (pkgs.wordpressPackages.themes) responsive-theme; 170 + } 171 ''; 172 }; 173