Difference between revisions of "Wordpress"

From NixOS Wiki
Jump to: navigation, search
(Remove pre-19.09 configuration using services.httpd.extraSubservices)
Line 34: Line 34:
 
in
 
in
 
{
 
{
   services.wordpress."webservice5" = {
+
# Note the .sites - the upstream module says this is the new syntax,
     database = {
+
# the old is only supported because of a hack at the very top of the module
      host = "127.0.0.1";
+
   services.wordpress.sites."webservice5" = {
      name = "wordpress";
+
     database.createLocally = true; # name is set to `wordpress` by default
      passwordFile = pkgs.writeText "wordpress-insecure-dbpass" "wordpress";
 
      createLocally = true;
 
    };
 
 
     themes = [ responsiveTheme ];
 
     themes = [ responsiveTheme ];
 
     plugins = [ akismetPlugin ];
 
     plugins = [ akismetPlugin ];

Revision as of 14:27, 13 January 2022

Since NixOS-19.09, it is possible to configure one or more wordpress instances using the services.wordpress module:

let

# For shits and giggles, let's package the responsive theme
responsiveTheme = pkgs.stdenv.mkDerivation {
  name = "responsive-theme";
  # Download the theme from the wordpress site
  src = pkgs.fetchurl {
    url = http://wordpress.org/themes/download/responsive.1.9.7.6.zip;
    sha256 = "06i26xlc5kdnx903b1gfvnysx49fb4kh4pixn89qii3a30fgd8r8";
  };
  # We need unzip to build this package
  buildInputs = [ pkgs.unzip ];
  # Installing simply means copying all files to the output directory
  installPhase = "mkdir -p $out; cp -R * $out/";
};

# Wordpress plugin 'akismet' installation example
akismetPlugin = pkgs.stdenv.mkDerivation {
  name = "akismet-plugin";
  # Download the theme from the wordpress site
  src = pkgs.fetchurl {
    url = https://downloads.wordpress.org/plugin/akismet.3.1.zip;
    sha256 = "1i4k7qyzna08822ncaz5l00wwxkwcdg4j9h3z2g0ay23q640pclg";
  };
  # We need unzip to build this package
  buildInputs = [ pkgs.unzip ];
  # Installing simply means copying all files to the output directory
  installPhase = "mkdir -p $out; cp -R * $out/";
};

in
{
 # Note the .sites - the upstream module says this is the new syntax,
 # the old is only supported because of a hack at the very top of the module
  services.wordpress.sites."webservice5" = {
    database.createLocally = true;  # name is set to `wordpress` by default
    themes = [ responsiveTheme ];
    plugins = [ akismetPlugin ];
    virtualHost = {
      adminAddr = "js@lastlog.de";
      serverAliases = [ "webservice5" "www.webservice5" ];
    };
  };
}