|
|
|
@ -1,20 +1,14 @@ |
|
|
|
|
{ config, pkgs, lib, ... }: |
|
|
|
|
|
|
|
|
|
let |
|
|
|
|
inherit (lib) mkDefault mkEnableOption mkForce mkIf mkMerge mkOption types; |
|
|
|
|
inherit (lib) any attrValues concatMapStringsSep flatten literalExpression; |
|
|
|
|
inherit (lib) filterAttrs mapAttrs mapAttrs' mapAttrsToList nameValuePair optional optionalAttrs optionalString; |
|
|
|
|
with lib; |
|
|
|
|
|
|
|
|
|
cfg = migrateOldAttrs config.services.wordpress; |
|
|
|
|
let |
|
|
|
|
cfg = config.services.wordpress; |
|
|
|
|
eachSite = cfg.sites; |
|
|
|
|
user = "wordpress"; |
|
|
|
|
webserver = config.services.${cfg.webserver}; |
|
|
|
|
stateDir = hostName: "/var/lib/wordpress/${hostName}"; |
|
|
|
|
|
|
|
|
|
# Migrate config.services.wordpress.<hostName> to config.services.wordpress.sites.<hostName> |
|
|
|
|
oldSites = filterAttrs (o: _: o != "sites" && o != "webserver"); |
|
|
|
|
migrateOldAttrs = cfg: cfg // { sites = cfg.sites // oldSites cfg; }; |
|
|
|
|
|
|
|
|
|
pkg = hostName: cfg: pkgs.stdenv.mkDerivation rec { |
|
|
|
|
pname = "wordpress-${hostName}"; |
|
|
|
|
version = src.version; |
|
|
|
@ -266,36 +260,29 @@ in |
|
|
|
|
{ |
|
|
|
|
# interface |
|
|
|
|
options = { |
|
|
|
|
services.wordpress = mkOption { |
|
|
|
|
type = types.submodule { |
|
|
|
|
# Used to support old interface |
|
|
|
|
freeformType = types.attrsOf (types.submodule siteOpts); |
|
|
|
|
|
|
|
|
|
# New interface |
|
|
|
|
options.sites = mkOption { |
|
|
|
|
type = types.attrsOf (types.submodule siteOpts); |
|
|
|
|
default = {}; |
|
|
|
|
description = "Specification of one or more WordPress sites to serve"; |
|
|
|
|
}; |
|
|
|
|
services.wordpress = { |
|
|
|
|
|
|
|
|
|
options.webserver = mkOption { |
|
|
|
|
type = types.enum [ "httpd" "nginx" "caddy" ]; |
|
|
|
|
default = "httpd"; |
|
|
|
|
description = '' |
|
|
|
|
Whether to use apache2 or nginx for virtual host management. |
|
|
|
|
sites = mkOption { |
|
|
|
|
type = types.attrsOf (types.submodule siteOpts); |
|
|
|
|
default = {}; |
|
|
|
|
description = "Specification of one or more WordPress sites to serve"; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Further nginx configuration can be done by adapting <literal>services.nginx.virtualHosts.<name></literal>. |
|
|
|
|
See <xref linkend="opt-services.nginx.virtualHosts"/> for further information. |
|
|
|
|
webserver = mkOption { |
|
|
|
|
type = types.enum [ "httpd" "nginx" "caddy" ]; |
|
|
|
|
default = "httpd"; |
|
|
|
|
description = '' |
|
|
|
|
Whether to use apache2 or nginx for virtual host management. |
|
|
|
|
|
|
|
|
|
Further apache2 configuration can be done by adapting <literal>services.httpd.virtualHosts.<name></literal>. |
|
|
|
|
See <xref linkend="opt-services.httpd.virtualHosts"/> for further information. |
|
|
|
|
''; |
|
|
|
|
}; |
|
|
|
|
Further nginx configuration can be done by adapting <literal>services.nginx.virtualHosts.<name></literal>. |
|
|
|
|
See <xref linkend="opt-services.nginx.virtualHosts"/> for further information. |
|
|
|
|
|
|
|
|
|
Further apache2 configuration can be done by adapting <literal>services.httpd.virtualHosts.<name></literal>. |
|
|
|
|
See <xref linkend="opt-services.httpd.virtualHosts"/> for further information. |
|
|
|
|
''; |
|
|
|
|
}; |
|
|
|
|
default = {}; |
|
|
|
|
description = "Wordpress configuration"; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
# implementation |
|
|
|
@ -312,8 +299,6 @@ in |
|
|
|
|
}) eachSite); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
warnings = mapAttrsToList (hostName: _: ''services.wordpress."${hostName}" is deprecated use services.wordpress.sites."${hostName}"'') (oldSites cfg); |
|
|
|
|
|
|
|
|
|
services.mysql = mkIf (any (v: v.database.createLocally) (attrValues eachSite)) { |
|
|
|
|
enable = true; |
|
|
|
|
package = mkDefault pkgs.mariadb; |
|
|
|
|