mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 20:25:32 +03:00
nixos/dokuwiki: refactor
This commit is contained in:
parent
dc7ed06615
commit
71baf4801c
1 changed files with 159 additions and 162 deletions
|
@ -53,148 +53,147 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
siteOpts = {lib, name, ...}:
|
siteOpts = {lib, name, ...}: {
|
||||||
{
|
options = {
|
||||||
options = {
|
enable = mkEnableOption "DokuWiki web application.";
|
||||||
enable = mkEnableOption "DokuWiki web application.";
|
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = pkgs.dokuwiki;
|
default = pkgs.dokuwiki;
|
||||||
description = "Which dokuwiki package to use.";
|
description = "Which dokuwiki package to use.";
|
||||||
};
|
};
|
||||||
|
|
||||||
hostName = mkOption {
|
hostName = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "localhost";
|
default = "localhost";
|
||||||
description = "FQDN for the instance.";
|
description = "FQDN for the instance.";
|
||||||
};
|
};
|
||||||
|
|
||||||
stateDir = mkOption {
|
stateDir = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
default = "/var/lib/dokuwiki/${name}/data";
|
default = "/var/lib/dokuwiki/${name}/data";
|
||||||
description = "Location of the dokuwiki state directory.";
|
description = "Location of the dokuwiki state directory.";
|
||||||
};
|
};
|
||||||
|
|
||||||
acl = mkOption {
|
acl = mkOption {
|
||||||
type = types.nullOr types.lines;
|
type = types.nullOr types.lines;
|
||||||
default = null;
|
default = null;
|
||||||
example = "* @ALL 8";
|
example = "* @ALL 8";
|
||||||
description = ''
|
description = ''
|
||||||
Access Control Lists: see <link xlink:href="https://www.dokuwiki.org/acl"/>
|
Access Control Lists: see <link xlink:href="https://www.dokuwiki.org/acl"/>
|
||||||
Mutually exclusive with services.dokuwiki.aclFile
|
Mutually exclusive with services.dokuwiki.aclFile
|
||||||
Set this to a value other than null to take precedence over aclFile option.
|
Set this to a value other than null to take precedence over aclFile option.
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
aclFile = mkOption {
|
|
||||||
type = types.nullOr types.path;
|
|
||||||
default = null;
|
|
||||||
description = ''
|
|
||||||
Location of the dokuwiki acl rules. Mutually exclusive with services.dokuwiki.acl
|
|
||||||
Mutually exclusive with services.dokuwiki.acl which is preferred.
|
|
||||||
Consult documentation <link xlink:href="https://www.dokuwiki.org/acl"/> for further instructions.
|
|
||||||
Example: <link xlink:href="https://github.com/splitbrain/dokuwiki/blob/master/conf/acl.auth.php.dist"/>
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
aclUse = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = true;
|
|
||||||
description = ''
|
|
||||||
Necessary for users to log in into the system.
|
|
||||||
Also limits anonymous users. When disabled,
|
|
||||||
everyone is able to create and edit content.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
pluginsConfig = mkOption {
|
|
||||||
type = types.lines;
|
|
||||||
default = ''
|
|
||||||
$plugins['authad'] = 0;
|
|
||||||
$plugins['authldap'] = 0;
|
|
||||||
$plugins['authmysql'] = 0;
|
|
||||||
$plugins['authpgsql'] = 0;
|
|
||||||
'';
|
|
||||||
description = ''
|
|
||||||
List of the dokuwiki (un)loaded plugins.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
superUser = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
default = "@admin";
|
|
||||||
description = ''
|
|
||||||
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
|
|
||||||
Consult documentation <link xlink:href="https://www.dokuwiki.org/config:superuser"/> for further instructions.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
usersFile = mkOption {
|
|
||||||
type = types.nullOr types.path;
|
|
||||||
default = 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"/>
|
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
|
|
||||||
extraConfig = mkOption {
|
|
||||||
type = types.nullOr types.lines;
|
|
||||||
default = null;
|
|
||||||
example = ''
|
|
||||||
$conf['title'] = 'My Wiki';
|
|
||||||
$conf['userewrite'] = 1;
|
|
||||||
'';
|
|
||||||
description = ''
|
|
||||||
DokuWiki configuration. Refer to
|
|
||||||
<link xlink:href="https://www.dokuwiki.org/config"/>
|
|
||||||
for details on supported values.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
description = ''
|
|
||||||
Options for the dokuwiki PHP pool. See the documentation on <literal>php-fpm.conf</literal>
|
|
||||||
for details on configuration directives.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
nginx = mkOption {
|
aclFile = mkOption {
|
||||||
type = types.submodule (
|
type = types.nullOr types.path;
|
||||||
recursiveUpdate
|
default = null;
|
||||||
(import ../web-servers/nginx/vhost-options.nix { inherit config lib; })
|
description = ''
|
||||||
{
|
Location of the dokuwiki acl rules. Mutually exclusive with services.dokuwiki.acl
|
||||||
# Enable encryption by default,
|
Mutually exclusive with services.dokuwiki.acl which is preferred.
|
||||||
options.forceSSL.default = true;
|
Consult documentation <link xlink:href="https://www.dokuwiki.org/acl"/> for further instructions.
|
||||||
options.enableACME.default = true;
|
Example: <link xlink:href="https://github.com/splitbrain/dokuwiki/blob/master/conf/acl.auth.php.dist"/>
|
||||||
}
|
'';
|
||||||
);
|
};
|
||||||
default = {forceSSL = true; enableACME = true;};
|
|
||||||
example = {
|
aclUse = mkOption {
|
||||||
serverAliases = [
|
type = types.bool;
|
||||||
"wiki.\${config.networking.domain}"
|
default = true;
|
||||||
];
|
description = ''
|
||||||
enableACME = false;
|
Necessary for users to log in into the system.
|
||||||
|
Also limits anonymous users. When disabled,
|
||||||
|
everyone is able to create and edit content.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
pluginsConfig = mkOption {
|
||||||
|
type = types.lines;
|
||||||
|
default = ''
|
||||||
|
$plugins['authad'] = 0;
|
||||||
|
$plugins['authldap'] = 0;
|
||||||
|
$plugins['authmysql'] = 0;
|
||||||
|
$plugins['authpgsql'] = 0;
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
List of the dokuwiki (un)loaded plugins.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
superUser = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "@admin";
|
||||||
|
description = ''
|
||||||
|
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
|
||||||
|
Consult documentation <link xlink:href="https://www.dokuwiki.org/config:superuser"/> for further instructions.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
usersFile = mkOption {
|
||||||
|
type = types.nullOr types.path;
|
||||||
|
default = 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"/>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = mkOption {
|
||||||
|
type = types.nullOr types.lines;
|
||||||
|
default = null;
|
||||||
|
example = ''
|
||||||
|
$conf['title'] = 'My Wiki';
|
||||||
|
$conf['userewrite'] = 1;
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
DokuWiki configuration. Refer to
|
||||||
|
<link xlink:href="https://www.dokuwiki.org/config"/>
|
||||||
|
for details on supported values.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Options for the dokuwiki PHP pool. See the documentation on <literal>php-fpm.conf</literal>
|
||||||
|
for details on configuration directives.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
nginx = mkOption {
|
||||||
|
type = types.submodule (
|
||||||
|
recursiveUpdate
|
||||||
|
(import ../web-servers/nginx/vhost-options.nix { inherit config lib; })
|
||||||
|
{
|
||||||
|
# Enable encryption by default,
|
||||||
|
options.forceSSL.default = true;
|
||||||
|
options.enableACME.default = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
default = {forceSSL = true; enableACME = true;};
|
||||||
|
example = {
|
||||||
|
serverAliases = [
|
||||||
|
"wiki.\${config.networking.domain}"
|
||||||
|
];
|
||||||
|
enableACME = false;
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
With this option, you can customize the nginx virtualHost which already has sensible defaults for DokuWiki.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
description = ''
|
|
||||||
With this option, you can customize the nginx virtualHost which already has sensible defaults for DokuWiki.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# interface
|
# interface
|
||||||
|
@ -244,52 +243,51 @@ in
|
||||||
|
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
virtualHosts = mapAttrs (hostName: cfg: mkMerge [ cfg.nginx {
|
||||||
virtualHosts = mapAttrs (hostName: cfg: mkMerge [ cfg.nginx {
|
root = mkForce "${pkg hostName cfg}/share/dokuwiki/";
|
||||||
root = mkForce "${pkg hostName cfg}/share/dokuwiki/";
|
extraConfig = "fastcgi_param HTTPS on;";
|
||||||
extraConfig = "fastcgi_param HTTPS on;";
|
|
||||||
|
|
||||||
locations."~ /(conf/|bin/|inc/|install.php)" = {
|
locations."~ /(conf/|bin/|inc/|install.php)" = {
|
||||||
extraConfig = "deny all;";
|
extraConfig = "deny all;";
|
||||||
};
|
};
|
||||||
|
|
||||||
locations."~ ^/data/" = {
|
locations."~ ^/data/" = {
|
||||||
root = "${cfg.stateDir}";
|
root = "${cfg.stateDir}";
|
||||||
extraConfig = "internal;";
|
extraConfig = "internal;";
|
||||||
};
|
};
|
||||||
|
|
||||||
locations."~ ^/lib.*\.(js|css|gif|png|ico|jpg|jpeg)$" = {
|
locations."~ ^/lib.*\.(js|css|gif|png|ico|jpg|jpeg)$" = {
|
||||||
extraConfig = "expires 365d;";
|
extraConfig = "expires 365d;";
|
||||||
};
|
};
|
||||||
|
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
priority = 1;
|
priority = 1;
|
||||||
index = "doku.php";
|
index = "doku.php";
|
||||||
extraConfig = ''try_files $uri $uri/ @dokuwiki;'';
|
extraConfig = ''try_files $uri $uri/ @dokuwiki;'';
|
||||||
};
|
};
|
||||||
|
|
||||||
locations."@dokuwiki" = {
|
locations."@dokuwiki" = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
# rewrites "doku.php/" out of the URLs if you set the userwrite setting to .htaccess in dokuwiki config page
|
# 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 ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
|
||||||
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
|
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
|
||||||
rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
|
rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
|
||||||
rewrite ^/(.*) /doku.php?id=$1&$args last;
|
rewrite ^/(.*) /doku.php?id=$1&$args last;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
locations."~ \.php$" = {
|
locations."~ \.php$" = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
try_files $uri $uri/ /doku.php;
|
try_files $uri $uri/ /doku.php;
|
||||||
include ${pkgs.nginx}/conf/fastcgi_params;
|
include ${pkgs.nginx}/conf/fastcgi_params;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
fastcgi_param REDIRECT_STATUS 200;
|
fastcgi_param REDIRECT_STATUS 200;
|
||||||
fastcgi_pass unix:${config.services.phpfpm.pools."dokuwiki-${hostName}".socket};
|
fastcgi_pass unix:${config.services.phpfpm.pools."dokuwiki-${hostName}".socket};
|
||||||
fastcgi_param HTTPS on;
|
fastcgi_param HTTPS on;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}]) eachSite;
|
}]) eachSite;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.tmpfiles.rules = flatten (mapAttrsToList (hostName: cfg: [
|
systemd.tmpfiles.rules = flatten (mapAttrsToList (hostName: cfg: [
|
||||||
"d ${stateDir cfg}/attic 0750 ${user} ${group} - -"
|
"d ${stateDir cfg}/attic 0750 ${user} ${group} - -"
|
||||||
|
@ -303,6 +301,5 @@ in
|
||||||
"d ${stateDir cfg}/pages 0750 ${user} ${group} - -"
|
"d ${stateDir cfg}/pages 0750 ${user} ${group} - -"
|
||||||
"d ${stateDir cfg}/tmp 0750 ${user} ${group} - -"
|
"d ${stateDir cfg}/tmp 0750 ${user} ${group} - -"
|
||||||
]) eachSite);
|
]) eachSite);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue