This commit is contained in:
sinavir 2023-01-12 18:11:50 +01:00
parent dd8ec6c18e
commit 0ac470c493
20 changed files with 129 additions and 730 deletions

91
default.nix Normal file
View file

@ -0,0 +1,91 @@
{ lib
, stdenv
, fetchFromGitHub
, writeText
, nixosTests
, dokuwiki
}:
stdenv.mkDerivation rec {
pname = "dokuwiki";
version = "2022-07-31a";
src = fetchFromGitHub {
owner = "splitbrain";
repo = pname;
rev = "release_stable_${version}";
sha256 = "sha256-gtWEtc3kbMokKycTx71XXblkDF39i926uN2kU3oOeVw=";
};
preload = writeText "preload.php" ''
<?php
$config_cascade = array(
'acl' => array(
'default' => getenv('DOKUWIKI_ACL_AUTH_CONFIG'),
),
'plainauth.users' => array(
'default' => getenv('DOKUWIKI_USERS_AUTH_CONFIG'),
'protected' => "" // not used by default
),
);
'';
phpLocalConfig = writeText "local.php" ''
<?php
return require(getenv('DOKUWIKI_LOCAL_CONFIG'));
?>
'';
phpPluginsLocalConfig = writeText "plugins.local.php" ''
<?php
return require(getenv('DOKUWIKI_PLUGINS_LOCAL_CONFIG'));
?>
'';
installPhase = ''
runHook preInstall
mkdir -p $out/share/dokuwiki
cp -r * $out/share/dokuwiki
cp ${preload} $out/share/dokuwiki/inc/preload.php
cp ${phpLocalConfig} $out/share/dokuwiki/conf/local.php
cp ${phpPluginsLocalConfig} $out/share/dokuwiki/conf/plugins.local.php
runHook postInstall
'';
passthru = {
combine = { basePackage ? dokuwiki
, plugins ? []
, templates ? []
, localConfig ? null
, pluginsConfig ? null
, aclConfig ? null
, pname ? (p: "${p.pname}-combined")
}: let
isNotEmpty = x: lib.optionalString (! builtins.elem x [ null "" ]);
in basePackage.overrideAttrs (prev: {
pname = if builtins.isFunction pname then pname prev else pname;
postInstall = prev.postInstall or "" + ''
${lib.concatMapStringsSep "\n" (tpl: "cp -r ${toString tpl} $out/share/dokuwiki/lib/tpl/${tpl.name}") templates}
${lib.concatMapStringsSep "\n" (plugin: "cp -r ${toString plugin} $out/share/dokuwiki/lib/plugins/${plugin.name}") plugins}
${isNotEmpty localConfig "ln -sf ${localConfig} $out/share/dokuwiki/conf/local.php" }
${isNotEmpty pluginsConfig "ln -sf ${pluginsConfig} $out/share/dokuwiki/conf/plugins.local.php" }
${isNotEmpty aclConfig "ln -sf ${aclConfig} $out/share/dokuwiki/acl.auth.php" }
'';
});
tests = {
inherit (nixosTests) dokuwiki;
};
};
meta = with lib; {
description = "Simple to use and highly versatile Open Source wiki software that doesn't require a database";
license = licenses.gpl2;
homepage = "https://www.dokuwiki.org";
platforms = platforms.all;
maintainers = with maintainers; [ _1000101 ];
};
}

View file

@ -8,6 +8,7 @@
imports = imports =
[ # Include the results of the hardware scan. [ # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
../../shared/nur.nix
../../profiles/shared-hackens ../../profiles/shared-hackens
]; ];

View file

@ -11,8 +11,8 @@
./physical.nix ./physical.nix
./core-hackens ./core-hackens
../../secrets ../../secrets
./wiki
./webpass.nix ./webpass.nix
./nginx.nix
]; ];
networking.hostName = "hackens-org"; # Define your hostname. networking.hostName = "hackens-org"; # Define your hostname.
@ -23,7 +23,7 @@
# this value at the release version of the first install of this system. # this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option # Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.11"; # Did you read the comment? system.stateVersion = "22.11"; # Did you read the comment?
} }

View file

@ -1,8 +1,4 @@
{ {
imports = [ imports =
./personal-users.nix [ ./personal-users.nix ./ssh-server.nix ./static-dns.nix ./programs.nix ];
./ssh-server.nix
./static-dns.nix
./programs.nix
];
} }

View file

@ -1,10 +1,12 @@
{ ... }: { ... }: {
{ users = {
users.users = { mutableUsers = false;
users = {
rlahfa = { rlahfa = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
hashedPassword = "$6$y/I6nKCMYUku7$91vTR5kYz4nHyhbuA/j6kPsD8Vfo/Rg7ri6Ympftra9V6emOt/mPg0AScECtYjSIxretvfQ3sPUF1Ho0IWx381"; hashedPassword =
"$6$y/I6nKCMYUku7$91vTR5kYz4nHyhbuA/j6kPsD8Vfo/Rg7ri6Ympftra9V6emOt/mPg0AScECtYjSIxretvfQ3sPUF1Ho0IWx381";
openssh.authorizedKeys.keyFiles = [ ../../../pubkeys/raito.keys ]; openssh.authorizedKeys.keyFiles = [ ../../../pubkeys/raito.keys ];
}; };
gdoriathdohler = { gdoriathdohler = {
@ -15,6 +17,8 @@
mdebray = { mdebray = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
hashedPassword =
"$6$ujz06kXa4TgvPAbF$NaXkDuOUpf3.fBRh7JuygtS0V2U/Bz4N3DpbOznO.md44xEdlKwPH/pSbL9CQJBhI5kodaKZeSaoCyhzybBPA/";
openssh.authorizedKeys.keyFiles = [ ../../../pubkeys/sinavir.keys ]; openssh.authorizedKeys.keyFiles = [ ../../../pubkeys/sinavir.keys ];
}; };
hbarral = { hbarral = {
@ -22,6 +26,8 @@
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
openssh.authorizedKeys.keyFiles = [ ../../../pubkeys/backslash.keys ]; openssh.authorizedKeys.keyFiles = [ ../../../pubkeys/backslash.keys ];
}; };
root.openssh.authorizedKeys.keyFiles = [ ../../../pubkeys/beigbeder.keys ]; # Jacques Beigbeder est tjrs root. root.openssh.authorizedKeys.keyFiles =
[ ../../../pubkeys/beigbeder.keys ]; # Jacques Beigbeder est tjrs root.
};
}; };
} }

View file

@ -1,6 +1 @@
{ pkgs, ... }: { { pkgs, ... }: { environment.systemPackages = with pkgs; [ vim git ]; }
environment.systemPackages = with pkgs; [
vim
git
];
}

View file

@ -1,5 +1,4 @@
{ ... }: { ... }: {
{
# Enable the OpenSSH daemon. # Enable the OpenSSH daemon.
services.openssh.enable = true; services.openssh.enable = true;
services.openssh.passwordAuthentication = false; services.openssh.passwordAuthentication = false;

View file

@ -1,7 +1 @@
{ ... }: { ... }: { networking.nameservers = [ "1.1.1.1" "8.8.8.8" ]; }
{
networking.nameservers = [
"1.1.1.1"
"8.8.8.8"
];
}

View file

@ -1,25 +0,0 @@
{ pkgs, ... }:
let
python = pkgs.python39.withPackages (ps: [
ps.asyncio-mqtt
ps.websockets
]);
script = pkgs.fetchgit {
url = "https://git.eleves.ens.fr/hackens/kfet2mqtt.git";
rev = "4a9ca954fd4405ccbabdb0793f1a2f76c7561a8e";
sha256 = "1g4gv2mc0kd108yw8y6gbskg8zhnrlwdnza8mhii2n8jidh63485";
};
in
{
systemd.services."kfet2mqtt" = {
enable = true;
description = "Programme qui indique l'ouverture de la k-fet sur le broker mqtt d'hackENS";
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${python}/bin/python ${script}/script.py";
Restart = "always";
RestartSec = 10;
};
wantedBy = [ "mulit-user.target" ];
};
}

View file

@ -1,20 +0,0 @@
{ ... }:
let
port = 1883;
in
{
services.mosquitto = {
enable = true;
listeners = [
{
address = "10.158.1.1";
acl = [ "topic readwrite #" ];
port = port;
settings = {
allow_anonymous = true;
};
}
];
};
networking.firewall.allowedTCPPorts = [ port ];
}

View file

@ -1,128 +0,0 @@
{ pkgs, config, ... }:
let
hostname = "new.hackens.org";
in
{
networking.firewall.allowedTCPPorts = [ 80 443 ];
services.nginx.virtualHosts."${hostname}" = {
enableACME = true;
forceSSL = true;
};
services.dokuwiki.sites."${hostname}" = {
enable = true;
extraConfig = ''
$conf['template'] = 'bootstrap3';
$conf['license'] = 'cc-by-sa';
$conf['title'] = 'hackEns';
$conf['start'] = 'accueil';
$conf['lang'] = 'fr';
$conf['breadcrumbs'] = 0; // On s'en fiche de l'historique des pages visitées
$conf['youarehere'] = true; // Par contre on veut notre position dans la hiérarchie du site
// On veut que les liens externes s'ouvrent dans de nouveaux onglets
$conf['target'] = array(
'extern' => '_tab'
);
$conf['htmlok'] = 1; // On peut mettre du html dans les pages
$conf['sitemap'] = 7;
$conf['rss_type'] = 'rss2';
$conf['userewrite'] = 1; // Important, sinon on casse tout avec les règles nginx définies par le module nixos
$conf['useslash'] = 1;
$conf['plugin']['tokenbucketauth']['tba_send_mail'] = 'hackens@clipper.ens.fr'; // Ban auto des IPs qui brute-forcent
$conf['tpl']['bootstrap3']['showAddNewPage'] = 'logged';
$conf['tpl']['bootstrap3']['fluidContainer'] = 0;
$conf['htmlmail'] = 0; // On envoie les mails en plain text
$conf['authtype'] = 'oauth';
$conf['plugin']['oauthkeycloak']['key'] = 'wiki';
$conf['plugin']['oauthkeycloak']['secret'] = file('${config.age.secrets.wikiOpenID.path}', FILE_IGNORE_NEW_LINES)[0];
$conf['plugin']['oauthkeycloak']['openidurl'] = 'https://auth.rz.ens.wtf/auth/realms/hackENS/.well-known/openid-configuration/';
'';
pluginsConfig = ''
$plugins['authmysql'] = 0;
$plugins['popularity'] = 0;
$plugins['authpgsql'] = 0;
$plugins['authpdo'] = 0;
$plugins['authldap'] = 0;
$plugins['oauthkeycloak'] = 1;
'';
disableActions = "register";
superUser = "@admin";
aclUse = true;
# Il faut packager les templates
templates = pkgs.hackens.dokuwikiAddons.bootstrap3;
plugins = [
(pkgs.stdenv.mkDerivation {
name = "commonmark";
# Download the theme from the dokuwiki site
src = pkgs.fetchzip {
url = "https://github.com/clockoon/dokuwiki-plugin-commonmark/releases/download/v1.2.0/release.tar.gz";
sha256 = "10SVyqkbkwzF/m4aTHB/ssXJK5rjQbLxYOAFDKYOxTY=";
};
# Installing simply means copying all files to the output directory
installPhase = ''
mkdir -p $out
cp -R * $out/
'';
})
(pkgs.stdenv.mkDerivation {
name = "catlist";
# Download the theme from the dokuwiki site
src = pkgs.fetchFromGitHub {
owner = "xif-fr";
repo = "dokuwiki-plugin-catlist";
rev = "065f8d2f4817409989b9342b901163452fb9f547";
sha256 = "1l7bvnqkai8qkqqb67w8yy7fbs30dviqc36pyqggzfjhi558i9ih";
};
# Installing simply means copying all files to the output directory
installPhase = ''
mkdir -p $out
cp -R * $out/
'';
})
(pkgs.stdenv.mkDerivation {
name = "oauth";
# Download the theme from the dokuwiki site
src = pkgs.fetchFromGitHub {
owner = "cosmocode";
repo = "dokuwiki-plugin-oauth";
rev = "2022-01-13";
sha256 = "ruaw8MqSMgopULD7vxed44nbowjVc1e4H0Q7JEL9pD0=";
};
# Installing simply means copying all files to the output directory
installPhase = ''
mkdir -p $out
cp -R * $out/
'';
})
(pkgs.stdenv.mkDerivation {
name = "oauthkeycloak";
# Download the theme from the dokuwiki site
src = pkgs.fetchFromGitHub {
owner = "YoitoFes";
repo = "dokuwiki-plugin-oauthkeycloak";
rev = "2022-12-23";
sha256 = "jV4CCVJ+4vbWE52ocsJnHR5oIM5ZM/5aYub6wxkVado=";
};
# Installing simply means copying all files to the output directory
installPhase = ''
mkdir -p $out
cp -R * $out/
'';
})
];
};
# On veut php-xml
services.phpfpm.pools."dokuwiki-${hostname}".phpPackage = pkgs.lib.mkForce ( pkgs.php8.withExtensions (
{ all, enabled, ... }:
enabled ++ [
all.xml
]
));
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

View file

@ -1,5 +1,4 @@
{ ... }: { ... }:
{ {
imports = [ <agenix/modules/age.nix> ];
age.secrets."wikiOpenID".file = ./wiki-openID.age; age.secrets."wikiOpenID".file = ./wiki-openID.age;
} }

View file

@ -1,386 +0,0 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.dokuwiki;
eachSite = cfg.sites;
user = "dokuwiki";
webserver = config.services.${cfg.webserver};
stateDir = hostName: "/var/lib/dokuwiki/${hostName}/data";
dokuwikiAclAuthConfig = hostName: cfg: pkgs.writeText "acl.auth-${hostName}.php" "${toString cfg.acl}";
dokuwikiLocalConfig = hostName: cfg: pkgs.writeText "local-${hostName}.php" ''
<?php
$conf['savedir'] = '${cfg.stateDir}';
$conf['superuser'] = '${toString cfg.superUser}';
$conf['useacl'] = '${toString cfg.aclUse}';
$conf['disableactions'] = '${cfg.disableActions}';
${toString cfg.settings}
'';
dokuwikiPluginsLocalConfig = hostName: cfg: pkgs.writeText "plugins.local-${hostName}.php" ''
<?php
${cfg.pluginsConfig}
'';
pkg = hostName: cfg: pkgs.stdenv.mkDerivation rec {
pname = "dokuwiki-${hostName}";
version = src.version;
src = cfg.package;
installPhase = ''
mkdir -p $out
cp -r * $out/
# 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}
'';
};
siteOpts = { config, lib, name, ... }:
{
options = {
enable = mkEnableOption "DokuWiki web application.";
package = mkOption {
type = types.package;
default = pkgs.dokuwiki;
defaultText = literalExpression "pkgs.dokuwiki";
description = "Which DokuWiki package to use.";
};
stateDir = mkOption {
type = types.path;
default = "/var/lib/dokuwiki/${name}/data";
description = "Location of the DokuWiki state directory.";
};
acl = mkOption {
type = types.nullOr types.lines;
default = null;
example = "* @ALL 8";
description = ''
Access Control Lists: see <link xlink:href="https://www.dokuwiki.org/acl"/>
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.
'';
};
aclFile = mkOption {
type = with types; nullOr str;
default = if (config.aclUse && config.acl == null) then "/var/lib/dokuwiki/${name}/acl.auth.php" else 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"/>
'';
example = "/var/lib/dokuwiki/${name}/acl.auth.php";
};
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 = 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";
};
disableActions = mkOption {
type = types.nullOr types.str;
default = "";
example = "search,register";
description = ''
Disable individual action modes. Refer to
<link xlink:href="https://www.dokuwiki.org/config:action_modes"/>
for details on supported values.
'';
};
plugins = mkOption {
type = types.listOf types.path;
default = [];
description = ''
List of path(s) to respective plugin(s) which are copied from the 'plugin' directory.
It is a good practice to package them.
'';
};
templates = mkOption {
type = types.listOf types.path;
default = [];
description = ''
List of path(s) to respective template(s) which are copied from the 'tpl' directory.
It is a good practice to package them.
'';
};
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.
'';
};
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.
'';
};
};
};
in
{
# interface
options = {
services.dokuwiki = {
sites = mkOption {
type = types.attrsOf (types.submodule siteOpts);
default = {};
description = "Specification of one or more DokuWiki sites to serve";
};
webserver = mkOption {
type = types.enum [ "nginx" "caddy" ];
default = "nginx";
description = ''
Whether to use nginx or caddy for virtual host management.
Further nginx configuration can be done by adapting <literal>services.nginx.virtualHosts.&lt;name&gt;</literal>.
See <xref linkend="opt-services.nginx.virtualHosts"/> for further information.
TO COMPLETE
'';
};
};
};
disabledModules = [ "services/web-apps/dokuwiki.nix" ];
# implementation
config = mkIf (eachSite != {}) (mkMerge [{
assertions = flatten (mapAttrsToList (hostName: cfg:
[{
assertion = cfg.aclUse -> (cfg.acl != null || cfg.aclFile != null);
message = "Either services.dokuwiki.sites.${hostName}.acl or services.dokuwiki.sites.${hostName}.aclFile is mandatory if aclUse true";
}
{
assertion = cfg.usersFile != null -> cfg.aclUse != false;
message = "services.dokuwiki.sites.${hostName}.aclUse must must be true if usersFile is not null";
}
]) eachSite);
services.phpfpm.pools = mapAttrs' (hostName: cfg: (
nameValuePair "dokuwiki-${hostName}" {
inherit user;
group = webserver.group;
phpEnv = {
DOKUWIKI_LOCAL_CONFIG = "${dokuwikiLocalConfig hostName cfg}";
DOKUWIKI_PLUGINS_LOCAL_CONFIG = "${dokuwikiPluginsLocalConfig hostName cfg}";
DOKUWIKI_ROOT = "${cfg.finalPackage}/share/dokuwiki/";
DOKUWIKI_USERS_AUTH_CONFIG = "${if cfg.usersFile!= {} then cfg.usersFile else ""}";
} //optionalAttrs (cfg.aclUse) {
DOKUWIKI_ACL_AUTH_CONFIG = if (cfg.acl != null) then "${dokuwikiAclAuthConfig hostName cfg}" else "${toString cfg.aclFile}";
};
settings = {
"listen.owner" = webserver.user;
"listen.group" = webserver.group;
} // cfg.poolConfig;
}
)) eachSite;
}
{
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}/log 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);
users.users.${user} = {
group = webserver.group;
isSystemUser = true;
};
}
(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/|vendor/|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 = ''
# 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;
'';
};
"~ \\.php$" = {
extraConfig = ''
try_files $uri $uri/ /doku.php;
include ${config.services.nginx.package}/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REDIRECT_STATUS 200;
fastcgi_pass unix:${config.services.phpfpm.pools."dokuwiki-${hostName}".socket};
'';
};
};
}) eachSite;
};
})
(mkIf (cfg.webserver == "caddy") {
services.caddy = {
enable = true;
virtualHosts = mapAttrs' (hostName: cfg: (
nameValuePair "http://${hostName}" {
extraConfig = ''
root * ${pkg hostName cfg}/share/dokuwiki
file_server
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;
};
})
]);
meta.maintainers = with maintainers; [
_1000101
onny
dandellion
];
}

View file

@ -1,6 +0,0 @@
{ pkgs, config, lib, ...}:
{
imports = [
./custom-dokuwiki.nix
];
}

View file

@ -1,39 +0,0 @@
{ pkgs, lib, config, ... }:
let
cfg = config.services.mqtt2prometheus;
in
{
options.services.mqtt2prometheus = {
enable = lib.mkEnableOption "Enable mqtt2Prometheus";
package = lib.mkOption {
type = lib.types.package;
description = "Which mqtt2prometheus package to use";
};
listenAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "listen address for HTTP server used to expose metrics";
};
listenPort = lib.mkOption {
type = lib.types.port;
default = 9641;
description = "HTTP port used to expose metrics";
};
config = lib.mkOption { # à nixifier (un jour)
type = lib.types.path;
description = "Path to config file";
};
};
config = lib.mkIf cfg.enable {
systemd.services."mqtt2prometheus" = {
enable = true;
description = "MQTT client which exposes metrics for prometheus monitoring software";
after = [ "network-online.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/mqtt2prometheus -config ${cfg.config} -listen-address ${cfg.listenAddress} -listen-port ${toString cfg.listenPort}";
Restart = "always";
};
wantedBy = [ "multi-user.target" ];
};
};
}

View file

@ -1,52 +0,0 @@
{ lib, stdenv, fetchFromGitHub, writeText, nixosTests }:
stdenv.mkDerivation rec {
pname = "dokuwiki";
version = "2022-07-31";
src = fetchFromGitHub {
owner = "splitbrain";
repo = pname;
rev = "release_stable_${version}";
sha256 = "sha256-FreJsajdfoefQHo6rBzkImDUvR3Zb7rBQTYhYvyRJC4=";
};
preload = writeText "preload.php" ''
<?php
$config_cascade = array(
'main' => array(
'local' => array(getenv('DOKUWIKI_LOCAL_CONFIG')),
),
'acl' => array(
'default' => getenv('DOKUWIKI_ACL_AUTH_CONFIG'),
),
'plainauth.users' => array(
'default' => getenv('DOKUWIKI_USERS_AUTH_CONFIG'),
),
'plugins' => array(
'local' => array(getenv('DOKUWIKI_PLUGINS_LOCAL_CONFIG')),
),
);
'';
installPhase = ''
mkdir -p $out/share/dokuwiki
cp -r * $out/share/dokuwiki
cp ${preload} $out/share/dokuwiki/inc/preload.php
'';
patches = [ ./dokuwiki_deep_merge.patch ];
passthru.tests = {
inherit (nixosTests) dokuwiki;
};
meta = with lib; {
description = "Simple to use and highly versatile Open Source wiki software that doesn't require a database";
license = licenses.gpl2;
homepage = "https://www.dokuwiki.org";
platforms = platforms.all;
maintainers = with maintainers; [ _1000101 ];
};
}

View file

@ -1,11 +0,0 @@
--- a/inc/config_cascade.php
+++ b/inc/config_cascade.php
@@ -5,7 +5,7 @@
* This array configures the default locations of various files in the
* DokuWiki directory hierarchy. It can be overriden in inc/preload.php
*/
-$config_cascade = array_merge(
+$config_cascade = array_merge_recursive(
array(
'main' => array(
'default' => array(DOKU_CONF . 'dokuwiki.php'),

View file

@ -1,15 +0,0 @@
{ pkgs, ... }:
pkgs.buildGoModule rec {
pname = "mqtt2prometheus";
version = "0.1.6";
src = pkgs.fetchFromGitHub {
owner = "hikhvar";
repo = "mqtt2prometheus";
rev = "v${version}";
sha256 = "0dz5mrwm231g45i8rbmvaza8bm6cr4jg5vc87h41vnm7xsx815g7";
};
vendorSha256 = "1fyzij7cakhd6x2hf3rvvslvvxmfmlp881x5rz2qwm04spa18cp4";
postInstall = ''
mv $out/bin/cmd $out/bin/mqtt2prometheus
'';
}