WordPress: Difference between revisions
imported>Onny mNo edit summary |
imported>Onny Update information on wordpressPackages |
||
| Line 3: | Line 3: | ||
== Installation == | == Installation == | ||
{{Note|Parts of this instruction and module are not yet | {{Note|Parts of this instruction and module are not yet stable and will be available in the upcoming NixOS 22.11 release.}} | ||
A simple local setup of Wordpress can be enabled with the following setup | A simple local setup of Wordpress can be enabled with the following setup | ||
| Line 19: | Line 19: | ||
=== Language === | === Language === | ||
The default language of the Wordpress module will be English. It is possible to | The default language of the Wordpress module will be English. It is possible to enable additional language support for languages which are [https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=wordpressPackages.languages already packaged]. Using <code>extraConfig</code> you can configure the default language. In this example, we're going to enable the German language. | ||
<syntaxHighlight lang="nix"> | |||
services.wordpress.sites."localhost" = { | |||
languages = [ pkgs.wordpressPackages.languages.de_DE ]; | |||
virtualHost.adminAddr = "hello@example.org"; | |||
extraConfig = '' | |||
define ('WPLANG', 'de_DE'); | |||
''; | |||
}; | |||
</syntaxHighlight> | |||
Alternatively you can package your own language files following this example: | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
{ pkgs, ... }: let | { pkgs, ... }: let | ||
language-de = pkgs.stdenv.mkDerivation { | wordpress-language-de = pkgs.stdenv.mkDerivation { | ||
name = "wordpress-${pkgs.wordpress.version}-language-de"; | name = "wordpress-${pkgs.wordpress.version}-language-de"; | ||
src = pkgs.fetchurl { | src = pkgs.fetchurl { | ||
| Line 35: | Line 46: | ||
in { | in { | ||
services.wordpress.sites."localhost" | services.wordpress.sites."localhost".languages = [ wordpress-language-de ]; | ||
} | } | ||
| Line 48: | Line 53: | ||
Consult the [https://translate.wordpress.org translation portal] of Wordpress for the specific country and language codes available. This example is using the code <code>de_DE</code> (Germany/German) in the source URL and also the <code>extraConfig</code> part. | Consult the [https://translate.wordpress.org translation portal] of Wordpress for the specific country and language codes available. This example is using the code <code>de_DE</code> (Germany/German) in the source URL and also the <code>extraConfig</code> part. | ||
=== Themes === | === Themes and plugins === | ||
Themes and plugins which are [https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=wordpressPackages already packaged] can be integrated like this: | |||
<syntaxHighlight lang="nix"> | |||
services.wordpress.sites."localhost" = { | |||
themes = [ pkgs.wordpressPackages.themes.twentytwentytwo ]; | |||
plugins = with pkgs.wordpressPackages.plugins; [ | |||
antispam-bee | |||
opengraph | |||
]; | |||
virtualHost.adminAddr = "hello@example.org"; | |||
}; | |||
</syntaxHighlight> | |||
Manually package a Wordpress theme or plugin can be accomplished like this: | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
let | let | ||
responsive = pkgs.stdenv.mkDerivation { | wordpress-plugin-responsive = pkgs.stdenv.mkDerivation { | ||
name = "responsive"; | name = "responsive"; | ||
src = pkgs.fetchurl { | src = pkgs.fetchurl { | ||
| Line 68: | Line 85: | ||
services.wordpress.sites."localhost" = { | services.wordpress.sites."localhost" = { | ||
themes = [ responsive ]; | themes = [ wordpress-plugin-responsive ]; | ||
virtualHost.adminAddr = "hello@example.org"; | virtualHost.adminAddr = "hello@example.org"; | ||
}; | }; | ||
| Line 75: | Line 92: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
You can package any available Wordpress | You can package any available Wordpress extension, for example from the [https://wordpress.org/themes official theme] or [https://wordpress.org/plugins plugin repository]. Be sure to replace the ''name'', url and ''sha256'' part according to your desired theme. | ||
If you want to automatically enable the ''responsive'' theme, add this < | If you want to automatically enable the ''responsive'' theme, add this <code>extraConfig</code> line | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
| Line 84: | Line 101: | ||
define ('WP_DEFAULT_THEME', 'responsive'); | define ('WP_DEFAULT_THEME', 'responsive'); | ||
''; | ''; | ||
</syntaxHighlight> | </syntaxHighlight> | ||