-{ lib, php, stdenv, writeText, fetchedGithub }:
-let
- dokuwiki = let
- plugins = {
- farmer = stdenv.mkDerivation (fetchedGithub ./dokuwiki-plugin-farmer.json // rec {
- installPhase = ''
- mkdir $out
- cp -a * $out/
- '';
- });
- todo = stdenv.mkDerivation (fetchedGithub ./dokuwiki-plugin-todo.json // rec {
- installPhase = ''
- mkdir $out
- cp -a * $out/
- '';
- });
- };
- preload = writeText "preload.php" ''
- <?php
- # farm setup by farmer plugin
- if(file_exists('${plugins.farmer}/DokuWikiFarmCore.php'))
- {
- include('${plugins.farmer}/DokuWikiFarmCore.php');
- }
- '';
- in rec {
- varDir = "/var/lib/dokuwiki";
- activationScript = {
- deps = [ "wrappers" ];
- text = ''
- if [ ! -d ${varDir} ]; then
- install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
- ${varDir}/animals
- cp -a ${webRoot}/conf.dist ${varDir}/conf
- cp -a ${webRoot}/data.dist ${varDir}/data
- cp -a ${webRoot}/
- chown -R ${apache.user}:${apache.user} ${varDir}/config ${varDir}/data
- chmod -R 755 ${varDir}/config ${varDir}/data
- fi
- install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
- '';
- };
- webRoot = stdenv.mkDerivation (fetchedGithub ./dokuwiki.json // rec {
- buildPhase = ''
- mv conf conf.dist
- mv data data.dist
- '';
- installPhase = ''
- cp -a . $out
- cp ${preload} $out/inc/preload.php
- ln -sf ${varDir}/{conf,data} $out/
- ln -sf ${varDir}/conf/.htaccess $out/
- ${builtins.concatStringsSep "\n" (
- lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/lib/plugins/${name}") plugins
- )}
- '';
- });
- apache = rec {
- user = "wwwrun";
- group = "wwwrun";
- modules = [ "proxy_fcgi" ];
- webappName = "tools_dokuwiki";
- root = "/run/current-system/webapps/${webappName}";
- vhostConf = ''
- Alias /dokuwiki "${root}"
- <Directory "${root}">
- DirectoryIndex index.php
- <FilesMatch "\.php$">
- SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
- </FilesMatch>
+{ lib, stdenv, dokuwiki, dokuwiki-plugins }:
+rec {
+ varDir = "/var/lib/dokuwiki";
+ activationScript = {
+ deps = [ "wrappers" ];
+ text = ''
+ if [ ! -d ${varDir} ]; then
+ install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
+ ${varDir}/animals
+ cp -a ${webRoot}/conf.dist ${varDir}/conf
+ cp -a ${webRoot}/data.dist ${varDir}/data
+ cp -a ${webRoot}/
+ chown -R ${apache.user}:${apache.user} ${varDir}/config ${varDir}/data
+ chmod -R 755 ${varDir}/config ${varDir}/data
+ fi
+ install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
+ '';
+ };
+ webRoot = dokuwiki.withPlugins (builtins.attrValues dokuwiki-plugins);
+ apache = rec {
+ user = "wwwrun";
+ group = "wwwrun";
+ modules = [ "proxy_fcgi" ];
+ webappName = "tools_dokuwiki";
+ root = "/run/current-system/webapps/${webappName}";
+ vhostConf = ''
+ Alias /dokuwiki "${root}"
+ <Directory "${root}">
+ DirectoryIndex index.php
+ <FilesMatch "\.php$">
+ SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
+ </FilesMatch>
- AllowOverride All
- Options +FollowSymlinks
- Require all granted
- </Directory>
- '';
- };
- phpFpm = rec {
- serviceDeps = [ "openldap.service" ];
- basedir = builtins.concatStringsSep ":" (
- [ webRoot varDir ]
- ++ lib.attrsets.mapAttrsToList (name: value: value) plugins);
- socket = "/var/run/phpfpm/dokuwiki.sock";
- pool = ''
- listen = ${socket}
- user = ${apache.user}
- group = ${apache.group}
- listen.owner = ${apache.user}
- listen.group = ${apache.group}
- pm = ondemand
- pm.max_children = 60
- pm.process_idle_timeout = 60
+ AllowOverride All
+ Options +FollowSymlinks
+ Require all granted
+ </Directory>
+ '';
+ };
+ phpFpm = rec {
+ serviceDeps = [ "openldap.service" ];
+ basedir = builtins.concatStringsSep ":" (
+ [ webRoot varDir ] ++ webRoot.plugins);
+ socket = "/var/run/phpfpm/dokuwiki.sock";
+ pool = ''
+ listen = ${socket}
+ user = ${apache.user}
+ group = ${apache.group}
+ listen.owner = ${apache.user}
+ listen.group = ${apache.group}
+ pm = ondemand
+ pm.max_children = 60
+ pm.process_idle_timeout = 60
- ; Needed to avoid clashes in browser cookies (same domain)
- php_value[session.name] = DokuwikiPHPSESSID
- php_admin_value[open_basedir] = "${basedir}:/tmp"
- php_admin_value[session.save_path] = "${varDir}/phpSessions"
- '';
- };
+ ; Needed to avoid clashes in browser cookies (same domain)
+ php_value[session.name] = DokuwikiPHPSESSID
+ php_admin_value[open_basedir] = "${basedir}:/tmp"
+ php_admin_value[session.save_path] = "${varDir}/phpSessions"
+ '';
};
-in
- dokuwiki
+}
--- /dev/null
+{ varDir ? "/var/lib/dokuwiki", preload ? "", lib, stdenv, mylibs, writeText }:
+let
+ preloadFile = plugins: let preloads = [preload]
+ ++ builtins.concatMap (p: lib.optional (lib.hasAttr "preload" p) (p.preload p)) plugins;
+ in writeText "preload.php" (''
+ <?php
+ '' + builtins.concatStringsSep "\n" preloads
+ );
+ withPlugins = plugins: package.overrideAttrs(old: {
+ name = "${old.name}-with-plugins";
+ installPhase = old.installPhase + (
+ builtins.concatStringsSep "\n" (
+ map (value: "ln -sf ${value} $out/lib/plugins/${value.pluginName}") plugins
+ )
+ );
+ installPreloadPhase = ''
+ cp ${preloadFile plugins} $out/inc/preload.php
+ '';
+ passthru.plugins = plugins;
+ passthru.withPlugins = morePlugins: old.withPlugins (morePlugins ++ plugins);
+ });
+ package = stdenv.mkDerivation (mylibs.fetchedGithub ./dokuwiki.json // rec {
+ phases = "unpackPhase buildPhase installPhase installPreloadPhase fixupPhase";
+ buildPhase = ''
+ mv conf conf.dist
+ mv data data.dist
+ '';
+ installPhase = ''
+ cp -a . $out
+ ln -sf ${varDir}/{conf,data} $out/
+ ln -sf ${varDir}/conf/.htaccess $out/
+ '';
+ installPreloadPhase = ''
+ cp ${preloadFile []} $out/inc/preload.php
+ '';
+ passthru = {
+ plugins = [];
+ inherit withPlugins varDir;
+ };
+ });
+in package