2021-08-03 12:50:21 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2022-01-15 17:38:20 +00:00
|
|
|
with lib;
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2022-01-15 17:38:20 +00:00
|
|
|
let
|
|
|
|
cfg = config.services.dokuwiki;
|
2021-08-03 12:50:21 +00:00
|
|
|
eachSite = cfg.sites;
|
2020-04-04 10:46:50 +00:00
|
|
|
user = "dokuwiki";
|
2021-08-03 12:50:21 +00:00
|
|
|
webserver = config.services.${cfg.webserver};
|
|
|
|
stateDir = hostName: "/var/lib/dokuwiki/${hostName}/data";
|
|
|
|
|
|
|
|
dokuwikiAclAuthConfig = hostName: cfg: pkgs.writeText "acl.auth-${hostName}.php" ''
|
2019-12-25 22:04:55 +00:00
|
|
|
# acl.auth.php
|
|
|
|
# <?php exit()?>
|
|
|
|
#
|
|
|
|
# Access Control Lists
|
|
|
|
#
|
|
|
|
${toString cfg.acl}
|
|
|
|
'';
|
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
dokuwikiLocalConfig = hostName: cfg: pkgs.writeText "local-${hostName}.php" ''
|
2019-12-25 22:04:55 +00:00
|
|
|
<?php
|
2020-03-30 20:04:52 +00:00
|
|
|
$conf['savedir'] = '${cfg.stateDir}';
|
2019-12-25 22:04:55 +00:00
|
|
|
$conf['superuser'] = '${toString cfg.superUser}';
|
|
|
|
$conf['useacl'] = '${toString cfg.aclUse}';
|
2020-03-30 20:21:28 +00:00
|
|
|
$conf['disableactions'] = '${cfg.disableActions}';
|
2019-12-25 22:04:55 +00:00
|
|
|
${toString cfg.extraConfig}
|
|
|
|
'';
|
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
dokuwikiPluginsLocalConfig = hostName: cfg: pkgs.writeText "plugins.local-${hostName}.php" ''
|
2019-12-25 22:04:55 +00:00
|
|
|
<?php
|
|
|
|
${cfg.pluginsConfig}
|
|
|
|
'';
|
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
|
2020-03-29 20:39:14 +00:00
|
|
|
pkg = hostName: cfg: pkgs.stdenv.mkDerivation rec {
|
|
|
|
pname = "dokuwiki-${hostName}";
|
|
|
|
version = src.version;
|
|
|
|
src = cfg.package;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp -r * $out/
|
|
|
|
|
|
|
|
# symlink the dokuwiki config
|
2021-08-03 12:50:21 +00:00
|
|
|
ln -s ${dokuwikiLocalConfig hostName cfg} $out/share/dokuwiki/local.php
|
2020-03-29 20:39:14 +00:00
|
|
|
|
|
|
|
# symlink plugins config
|
2021-08-03 12:50:21 +00:00
|
|
|
ln -s ${dokuwikiPluginsLocalConfig hostName cfg} $out/share/dokuwiki/plugins.local.php
|
2020-03-29 20:39:14 +00:00
|
|
|
|
|
|
|
# symlink acl
|
2021-08-03 12:50:21 +00:00
|
|
|
ln -s ${dokuwikiAclAuthConfig hostName cfg} $out/share/dokuwiki/acl.auth.php
|
2020-03-30 11:08:16 +00:00
|
|
|
|
|
|
|
# symlink additional plugin(s) and templates(s)
|
|
|
|
${concatMapStringsSep "\n" (template: "ln -s ${template} $out/share/dokuwiki/lib/tpl/${template.name}") cfg.templates}
|
|
|
|
${concatMapStringsSep "\n" (plugin: "ln -s ${plugin} $out/share/dokuwiki/lib/plugins/${plugin.name}") cfg.plugins}
|
2020-03-29 20:39:14 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
siteOpts = { config, lib, name, ... }:
|
|
|
|
{
|
|
|
|
options = {
|
2021-09-30 18:12:07 +00:00
|
|
|
enable = mkEnableOption "DokuWiki web application.";
|
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.dokuwiki;
|
2021-10-03 16:06:03 +00:00
|
|
|
defaultText = literalExpression "pkgs.dokuwiki";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Which DokuWiki package to use.";
|
2021-08-03 12:50:21 +00:00
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
stateDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/dokuwiki/${name}/data";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Location of the DokuWiki state directory.";
|
2021-08-03 12:50:21 +00:00
|
|
|
};
|
2020-03-29 20:39:14 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
acl = mkOption {
|
|
|
|
type = types.nullOr types.lines;
|
|
|
|
default = null;
|
|
|
|
example = "* @ALL 8";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Access Control Lists: see <https://www.dokuwiki.org/acl>
|
2021-08-03 12:50:21 +00:00
|
|
|
Mutually exclusive with services.dokuwiki.aclFile
|
|
|
|
Set this to a value other than null to take precedence over aclFile option.
|
|
|
|
|
|
|
|
Warning: Consider using aclFile instead if you do not
|
|
|
|
want to store the ACL in the world-readable Nix store.
|
|
|
|
'';
|
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
aclFile = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = if (config.aclUse && config.acl == null) then "/var/lib/dokuwiki/${name}/acl.auth.php" else null;
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-08-03 12:50:21 +00:00
|
|
|
Location of the dokuwiki acl rules. Mutually exclusive with services.dokuwiki.acl
|
|
|
|
Mutually exclusive with services.dokuwiki.acl which is preferred.
|
2022-07-28 21:19:15 +00:00
|
|
|
Consult documentation <https://www.dokuwiki.org/acl> for further instructions.
|
|
|
|
Example: <https://github.com/splitbrain/dokuwiki/blob/master/conf/acl.auth.php.dist>
|
2021-08-03 12:50:21 +00:00
|
|
|
'';
|
|
|
|
example = "/var/lib/dokuwiki/${name}/acl.auth.php";
|
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
aclUse = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-08-03 12:50:21 +00:00
|
|
|
Necessary for users to log in into the system.
|
|
|
|
Also limits anonymous users. When disabled,
|
|
|
|
everyone is able to create and edit content.
|
|
|
|
'';
|
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
pluginsConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = ''
|
|
|
|
$plugins['authad'] = 0;
|
|
|
|
$plugins['authldap'] = 0;
|
|
|
|
$plugins['authmysql'] = 0;
|
|
|
|
$plugins['authpgsql'] = 0;
|
|
|
|
'';
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-08-03 12:50:21 +00:00
|
|
|
List of the dokuwiki (un)loaded plugins.
|
|
|
|
'';
|
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
superUser = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = "@admin";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-08-03 12:50:21 +00:00
|
|
|
You can set either a username, a list of usernames (“admin1,admin2”),
|
|
|
|
or the name of a group by prepending an @ char to the groupname
|
2022-07-28 21:19:15 +00:00
|
|
|
Consult documentation <https://www.dokuwiki.org/config:superuser> for further instructions.
|
2021-08-03 12:50:21 +00:00
|
|
|
'';
|
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
usersFile = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = if config.aclUse then "/var/lib/dokuwiki/${name}/users.auth.php" else null;
|
|
|
|
description = ''
|
|
|
|
Location of the dokuwiki users file. List of users. Format:
|
|
|
|
login:passwordhash:Real Name:email:groups,comma,separated
|
|
|
|
Create passwordHash easily by using:$ mkpasswd -5 password `pwgen 8 1`
|
|
|
|
Example: <link xlink:href="https://github.com/splitbrain/dokuwiki/blob/master/conf/users.auth.php.dist"/>
|
|
|
|
'';
|
|
|
|
example = "/var/lib/dokuwiki/${name}/users.auth.php";
|
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
disableActions = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = "";
|
|
|
|
example = "search,register";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-08-03 12:50:21 +00:00
|
|
|
Disable individual action modes. Refer to
|
2022-07-28 21:19:15 +00:00
|
|
|
<https://www.dokuwiki.org/config:action_modes>
|
2021-08-03 12:50:21 +00:00
|
|
|
for details on supported values.
|
2020-03-30 11:00:35 +00:00
|
|
|
'';
|
2021-08-03 12:50:21 +00:00
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
plugins = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
List of path(s) to respective plugin(s) which are copied from the 'plugin' directory.
|
|
|
|
<note><para>These plugins need to be packaged before use, see example.</para></note>
|
|
|
|
'';
|
2021-10-03 16:06:03 +00:00
|
|
|
example = literalExpression ''
|
|
|
|
let
|
|
|
|
# Let's package the icalevents plugin
|
|
|
|
plugin-icalevents = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "icalevents";
|
|
|
|
# Download the plugin from the dokuwiki site
|
|
|
|
src = pkgs.fetchurl {
|
|
|
|
url = "https://github.com/real-or-random/dokuwiki-plugin-icalevents/releases/download/2017-06-16/dokuwiki-plugin-icalevents-2017-06-16.zip";
|
|
|
|
sha256 = "e40ed7dd6bbe7fe3363bbbecb4de481d5e42385b5a0f62f6a6ce6bf3a1f9dfa8";
|
|
|
|
};
|
|
|
|
sourceRoot = ".";
|
|
|
|
# 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/";
|
2021-08-03 12:50:21 +00:00
|
|
|
};
|
|
|
|
# And then pass this theme to the plugin list like this:
|
2021-10-03 16:06:03 +00:00
|
|
|
in [ plugin-icalevents ]
|
2021-08-03 12:50:21 +00:00
|
|
|
'';
|
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
templates = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
List of path(s) to respective template(s) which are copied from the 'tpl' directory.
|
|
|
|
<note><para>These templates need to be packaged before use, see example.</para></note>
|
|
|
|
'';
|
2021-10-03 16:06:03 +00:00
|
|
|
example = literalExpression ''
|
|
|
|
let
|
|
|
|
# Let's package the bootstrap3 theme
|
|
|
|
template-bootstrap3 = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "bootstrap3";
|
|
|
|
# Download the theme from the dokuwiki site
|
|
|
|
src = pkgs.fetchurl {
|
|
|
|
url = "https://github.com/giterlizzi/dokuwiki-template-bootstrap3/archive/v2019-05-22.zip";
|
|
|
|
sha256 = "4de5ff31d54dd61bbccaf092c9e74c1af3a4c53e07aa59f60457a8f00cfb23a6";
|
|
|
|
};
|
|
|
|
# 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/";
|
2021-08-03 12:50:21 +00:00
|
|
|
};
|
|
|
|
# And then pass this theme to the template list like this:
|
2021-10-03 16:06:03 +00:00
|
|
|
in [ template-bootstrap3 ]
|
2021-08-03 12:50:21 +00:00
|
|
|
'';
|
|
|
|
};
|
2020-03-30 11:08:16 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
poolConfig = mkOption {
|
|
|
|
type = with types; attrsOf (oneOf [ str int bool ]);
|
|
|
|
default = {
|
|
|
|
"pm" = "dynamic";
|
|
|
|
"pm.max_children" = 32;
|
|
|
|
"pm.start_servers" = 2;
|
|
|
|
"pm.min_spare_servers" = 2;
|
|
|
|
"pm.max_spare_servers" = 4;
|
|
|
|
"pm.max_requests" = 500;
|
|
|
|
};
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Options for the DokuWiki PHP pool. See the documentation on `php-fpm.conf`
|
2021-08-03 12:50:21 +00:00
|
|
|
for details on configuration directives.
|
|
|
|
'';
|
2020-03-30 11:00:35 +00:00
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.nullOr types.lines;
|
|
|
|
default = null;
|
|
|
|
example = ''
|
|
|
|
$conf['title'] = 'My Wiki';
|
|
|
|
$conf['userewrite'] = 1;
|
|
|
|
'';
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-08-03 12:50:21 +00:00
|
|
|
DokuWiki configuration. Refer to
|
2022-07-28 21:19:15 +00:00
|
|
|
<https://www.dokuwiki.org/config>
|
2021-08-03 12:50:21 +00:00
|
|
|
for details on supported values.
|
|
|
|
'';
|
2020-03-30 11:00:35 +00:00
|
|
|
};
|
2021-08-03 12:50:21 +00:00
|
|
|
|
2019-12-25 22:04:55 +00:00
|
|
|
};
|
2021-08-03 12:50:21 +00:00
|
|
|
|
2019-12-25 22:04:55 +00:00
|
|
|
};
|
2020-03-29 20:39:14 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
# interface
|
|
|
|
options = {
|
2022-01-20 11:01:09 +00:00
|
|
|
services.dokuwiki = {
|
2021-08-03 12:50:21 +00:00
|
|
|
|
2022-01-20 11:01:09 +00:00
|
|
|
sites = mkOption {
|
|
|
|
type = types.attrsOf (types.submodule siteOpts);
|
|
|
|
default = {};
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Specification of one or more DokuWiki sites to serve";
|
2022-01-20 11:01:09 +00:00
|
|
|
};
|
2021-08-03 12:50:21 +00:00
|
|
|
|
2022-01-20 11:01:09 +00:00
|
|
|
webserver = mkOption {
|
|
|
|
type = types.enum [ "nginx" "caddy" ];
|
|
|
|
default = "nginx";
|
|
|
|
description = ''
|
|
|
|
Whether to use nginx or caddy for virtual host management.
|
2021-08-03 12:50:21 +00:00
|
|
|
|
2022-01-20 11:01:09 +00:00
|
|
|
Further nginx configuration can be done by adapting <literal>services.nginx.virtualHosts.<name></literal>.
|
|
|
|
See <xref linkend="opt-services.nginx.virtualHosts"/> for further information.
|
2021-08-03 12:50:21 +00:00
|
|
|
|
2022-01-20 11:01:09 +00:00
|
|
|
Further apache2 configuration can be done by adapting <literal>services.httpd.virtualHosts.<name></literal>.
|
|
|
|
See <xref linkend="opt-services.httpd.virtualHosts"/> for further information.
|
|
|
|
'';
|
2021-08-03 12:50:21 +00:00
|
|
|
};
|
|
|
|
|
2022-01-20 11:01:09 +00:00
|
|
|
};
|
2020-03-29 20:39:14 +00:00
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
|
|
|
# implementation
|
2021-08-03 12:50:21 +00:00
|
|
|
config = mkIf (eachSite != {}) (mkMerge [{
|
2020-03-29 20:39:14 +00:00
|
|
|
|
|
|
|
assertions = flatten (mapAttrsToList (hostName: cfg:
|
|
|
|
[{
|
|
|
|
assertion = cfg.aclUse -> (cfg.acl != null || cfg.aclFile != null);
|
2021-08-03 12:50:21 +00:00
|
|
|
message = "Either services.dokuwiki.sites.${hostName}.acl or services.dokuwiki.sites.${hostName}.aclFile is mandatory if aclUse true";
|
2020-03-29 20:39:14 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = cfg.usersFile != null -> cfg.aclUse != false;
|
2021-08-03 12:50:21 +00:00
|
|
|
message = "services.dokuwiki.sites.${hostName}.aclUse must must be true if usersFile is not null";
|
2020-03-30 18:50:32 +00:00
|
|
|
}
|
2020-03-30 20:04:52 +00:00
|
|
|
]) eachSite);
|
2020-03-29 20:39:14 +00:00
|
|
|
|
|
|
|
services.phpfpm.pools = mapAttrs' (hostName: cfg: (
|
|
|
|
nameValuePair "dokuwiki-${hostName}" {
|
|
|
|
inherit user;
|
2021-08-03 12:50:21 +00:00
|
|
|
group = webserver.group;
|
|
|
|
|
2022-05-25 16:36:38 +00:00
|
|
|
phpPackage = pkgs.php81;
|
2020-03-29 20:39:14 +00:00
|
|
|
phpEnv = {
|
2021-08-03 12:50:21 +00:00
|
|
|
DOKUWIKI_LOCAL_CONFIG = "${dokuwikiLocalConfig hostName cfg}";
|
|
|
|
DOKUWIKI_PLUGINS_LOCAL_CONFIG = "${dokuwikiPluginsLocalConfig hostName cfg}";
|
2020-04-04 12:01:23 +00:00
|
|
|
} // optionalAttrs (cfg.usersFile != null) {
|
2020-03-29 20:39:14 +00:00
|
|
|
DOKUWIKI_USERS_AUTH_CONFIG = "${cfg.usersFile}";
|
|
|
|
} //optionalAttrs (cfg.aclUse) {
|
2021-08-03 12:50:21 +00:00
|
|
|
DOKUWIKI_ACL_AUTH_CONFIG = if (cfg.acl != null) then "${dokuwikiAclAuthConfig hostName cfg}" else "${toString cfg.aclFile}";
|
2020-03-29 20:39:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
settings = {
|
2021-08-03 12:50:21 +00:00
|
|
|
"listen.owner" = webserver.user;
|
|
|
|
"listen.group" = webserver.group;
|
2020-03-29 20:39:14 +00:00
|
|
|
} // cfg.poolConfig;
|
2021-08-03 12:50:21 +00:00
|
|
|
}
|
|
|
|
)) eachSite;
|
2020-03-30 11:00:35 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
}
|
2020-03-30 11:00:35 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
{
|
|
|
|
systemd.tmpfiles.rules = flatten (mapAttrsToList (hostName: cfg: [
|
|
|
|
"d ${stateDir hostName}/attic 0750 ${user} ${webserver.group} - -"
|
|
|
|
"d ${stateDir hostName}/cache 0750 ${user} ${webserver.group} - -"
|
|
|
|
"d ${stateDir hostName}/index 0750 ${user} ${webserver.group} - -"
|
|
|
|
"d ${stateDir hostName}/locks 0750 ${user} ${webserver.group} - -"
|
|
|
|
"d ${stateDir hostName}/media 0750 ${user} ${webserver.group} - -"
|
|
|
|
"d ${stateDir hostName}/media_attic 0750 ${user} ${webserver.group} - -"
|
|
|
|
"d ${stateDir hostName}/media_meta 0750 ${user} ${webserver.group} - -"
|
|
|
|
"d ${stateDir hostName}/meta 0750 ${user} ${webserver.group} - -"
|
|
|
|
"d ${stateDir hostName}/pages 0750 ${user} ${webserver.group} - -"
|
|
|
|
"d ${stateDir hostName}/tmp 0750 ${user} ${webserver.group} - -"
|
|
|
|
] ++ lib.optional (cfg.aclFile != null) "C ${cfg.aclFile} 0640 ${user} ${webserver.group} - ${pkg hostName cfg}/share/dokuwiki/conf/acl.auth.php.dist"
|
|
|
|
++ lib.optional (cfg.usersFile != null) "C ${cfg.usersFile} 0640 ${user} ${webserver.group} - ${pkg hostName cfg}/share/dokuwiki/conf/users.auth.php.dist"
|
|
|
|
) eachSite);
|
2020-03-30 11:00:35 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
users.users.${user} = {
|
|
|
|
group = webserver.group;
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
}
|
2020-03-30 11:00:35 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
(mkIf (cfg.webserver == "nginx") {
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts = mapAttrs (hostName: cfg: {
|
|
|
|
serverName = mkDefault hostName;
|
|
|
|
root = "${pkg hostName cfg}/share/dokuwiki";
|
|
|
|
|
|
|
|
locations = {
|
|
|
|
"~ /(conf/|bin/|inc/|install.php)" = {
|
|
|
|
extraConfig = "deny all;";
|
|
|
|
};
|
|
|
|
|
|
|
|
"~ ^/data/" = {
|
|
|
|
root = "${stateDir hostName}";
|
|
|
|
extraConfig = "internal;";
|
|
|
|
};
|
|
|
|
|
|
|
|
"~ ^/lib.*\.(js|css|gif|png|ico|jpg|jpeg)$" = {
|
|
|
|
extraConfig = "expires 365d;";
|
|
|
|
};
|
|
|
|
|
|
|
|
"/" = {
|
|
|
|
priority = 1;
|
|
|
|
index = "doku.php";
|
|
|
|
extraConfig = ''try_files $uri $uri/ @dokuwiki;'';
|
|
|
|
};
|
|
|
|
|
|
|
|
"@dokuwiki" = {
|
|
|
|
extraConfig = ''
|
2019-12-25 22:04:55 +00:00
|
|
|
# rewrites "doku.php/" out of the URLs if you set the userwrite setting to .htaccess in dokuwiki config page
|
|
|
|
rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
|
|
|
|
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
|
|
|
|
rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
|
|
|
|
rewrite ^/(.*) /doku.php?id=$1&$args last;
|
2021-08-03 12:50:21 +00:00
|
|
|
'';
|
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
"~ \\.php$" = {
|
|
|
|
extraConfig = ''
|
2019-12-25 22:04:55 +00:00
|
|
|
try_files $uri $uri/ /doku.php;
|
2022-02-08 11:13:30 +00:00
|
|
|
include ${config.services.nginx.package}/conf/fastcgi_params;
|
2019-12-25 22:04:55 +00:00
|
|
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
|
|
fastcgi_param REDIRECT_STATUS 200;
|
2020-03-29 20:39:14 +00:00
|
|
|
fastcgi_pass unix:${config.services.phpfpm.pools."dokuwiki-${hostName}".socket};
|
2021-08-03 12:50:21 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-03-30 11:00:35 +00:00
|
|
|
};
|
2021-08-03 12:50:21 +00:00
|
|
|
}) eachSite;
|
2020-03-30 11:00:35 +00:00
|
|
|
};
|
2021-08-03 12:50:21 +00:00
|
|
|
})
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
(mkIf (cfg.webserver == "caddy") {
|
|
|
|
services.caddy = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts = mapAttrs' (hostName: cfg: (
|
|
|
|
nameValuePair "http://${hostName}" {
|
|
|
|
extraConfig = ''
|
|
|
|
root * ${pkg hostName cfg}/share/dokuwiki
|
|
|
|
file_server
|
2020-04-04 10:46:50 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
encode zstd gzip
|
|
|
|
php_fastcgi unix/${config.services.phpfpm.pools."dokuwiki-${hostName}".socket}
|
|
|
|
|
|
|
|
@restrict_files {
|
|
|
|
path /data/* /conf/* /bin/* /inc/* /vendor/* /install.php
|
|
|
|
}
|
|
|
|
|
|
|
|
respond @restrict_files 404
|
|
|
|
|
|
|
|
@allow_media {
|
|
|
|
path_regexp path ^/_media/(.*)$
|
|
|
|
}
|
|
|
|
rewrite @allow_media /lib/exe/fetch.php?media=/{http.regexp.path.1}
|
|
|
|
|
|
|
|
@allow_detail {
|
|
|
|
path /_detail*
|
|
|
|
}
|
|
|
|
rewrite @allow_detail /lib/exe/detail.php?media={path}
|
|
|
|
|
|
|
|
@allow_export {
|
|
|
|
path /_export*
|
|
|
|
path_regexp export /([^/]+)/(.*)
|
|
|
|
}
|
|
|
|
rewrite @allow_export /doku.php?do=export_{http.regexp.export.1}&id={http.regexp.export.2}
|
|
|
|
|
|
|
|
try_files {path} {path}/ /doku.php?id={path}&{query}
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
)) eachSite;
|
2020-04-04 10:46:50 +00:00
|
|
|
};
|
2021-08-03 12:50:21 +00:00
|
|
|
})
|
2020-07-29 10:54:49 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
]);
|
2020-07-29 10:54:49 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
meta.maintainers = with maintainers; [
|
|
|
|
_1000101
|
|
|
|
onny
|
2021-12-08 12:32:33 +00:00
|
|
|
dandellion
|
2021-08-03 12:50:21 +00:00
|
|
|
];
|
2019-12-25 22:04:55 +00:00
|
|
|
}
|