]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add dokuwiki
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 8 Feb 2019 22:31:48 +0000 (23:31 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 8 Feb 2019 22:31:48 +0000 (23:31 +0100)
nixops/modules/websites/tools/tools/default.nix
nixops/modules/websites/tools/tools/dokuwiki-plugin-farmer.json [new file with mode: 0644]
nixops/modules/websites/tools/tools/dokuwiki-plugin-todo.json [new file with mode: 0644]
nixops/modules/websites/tools/tools/dokuwiki.json [new file with mode: 0644]
nixops/modules/websites/tools/tools/dokuwiki.nix [new file with mode: 0644]

index 41f47a3f458305c072fac90711dd7b8d197d788d..0b50a7c2c092f74b675aa40bad2b2f931f335af5 100644 (file)
@@ -21,6 +21,9 @@ let
     shaarli = pkgs.callPackage ./shaarli.nix {
       env = myconfig.env.tools.shaarli;
     };
+    dokuwiki = pkgs.callPackage ./dokuwiki.nix {
+      inherit (mylibs) fetchedGithub;
+    };
 
     cfg = config.services.myWebsites.tools.tools;
 in {
@@ -39,7 +42,8 @@ in {
       ++ wallabag.apache.modules
       ++ yourls.apache.modules
       ++ rompr.apache.modules
-      ++ shaarli.apache.modules;
+      ++ shaarli.apache.modules
+      ++ dokuwiki.apache.modules;
 
     services.ympd = ympd.config // { enable = true; };
 
@@ -56,6 +60,7 @@ in {
         yourls.apache.vhostConf
         rompr.apache.vhostConf
         shaarli.apache.vhostConf
+        dokuwiki.apache.vhostConf
       ];
     };
 
@@ -67,6 +72,7 @@ in {
       yourls = yourls.phpFpm.pool;
       rompr = rompr.phpFpm.pool;
       shaarli = shaarli.phpFpm.pool;
+      dokuwiki = dokuwiki.phpFpm.pool;
     };
 
     system.activationScripts = {
@@ -76,6 +82,7 @@ in {
       yourls = yourls.activationScript;
       rompr = rompr.activationScript;
       shaarli = shaarli.activationScript;
+      dokuwiki = dokuwiki.activationScript;
     };
 
     systemd.services.tt-rss = {
diff --git a/nixops/modules/websites/tools/tools/dokuwiki-plugin-farmer.json b/nixops/modules/websites/tools/tools/dokuwiki-plugin-farmer.json
new file mode 100644 (file)
index 0000000..4022eb4
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "72b8577-master",
+  "meta": {
+    "name": "dokuwiki-plugin-farmer",
+    "url": "https://github.com/cosmocode/dokuwiki-plugin-farmer",
+    "branch": "master"
+  },
+  "github": {
+    "owner": "cosmocode",
+    "repo": "dokuwiki-plugin-farmer",
+    "rev": "72b857734fd164bf79cc6e17abe56491d55c1072",
+    "sha256": "1c9vc1z7yvzjz4p054kshb9yd00a4bb52s43k9zav0lvwvjij9l0",
+    "fetchSubmodules": true
+  }
+}
diff --git a/nixops/modules/websites/tools/tools/dokuwiki-plugin-todo.json b/nixops/modules/websites/tools/tools/dokuwiki-plugin-todo.json
new file mode 100644 (file)
index 0000000..9576826
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "49068ec-master",
+  "meta": {
+    "name": "dokuwiki-plugin-todo",
+    "url": "https://github.com/leibler/dokuwiki-plugin-todo",
+    "branch": "master"
+  },
+  "github": {
+    "owner": "leibler",
+    "repo": "dokuwiki-plugin-todo",
+    "rev": "49068ecea455ea997d1e4a7adab171ccaf8228e8",
+    "sha256": "1jaq623kp14fyhamsas5mk9ryqlk4q6x6znijrb5xhcdg3r83gmq",
+    "fetchSubmodules": true
+  }
+}
diff --git a/nixops/modules/websites/tools/tools/dokuwiki.json b/nixops/modules/websites/tools/tools/dokuwiki.json
new file mode 100644 (file)
index 0000000..fc03252
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "release_stable_2018-04-22b",
+  "meta": {
+    "name": "dokuwiki",
+    "url": "https://github.com/splitbrain/dokuwiki",
+    "branch": "refs/tags/release_stable_2018-04-22b"
+  },
+  "github": {
+    "owner": "splitbrain",
+    "repo": "dokuwiki",
+    "rev": "871dae1320b40211626c7ec665f5e6d5290aca95",
+    "sha256": "1syvd5dvv3v75swf8ig7dxqs0g5xikb0f6vlcy7g4c4ghldkw7nz",
+    "fetchSubmodules": true
+  }
+}
diff --git a/nixops/modules/websites/tools/tools/dokuwiki.nix b/nixops/modules/websites/tools/tools/dokuwiki.nix
new file mode 100644 (file)
index 0000000..5affddb
--- /dev/null
@@ -0,0 +1,99 @@
+{ 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 = {
+      user = "wwwrun";
+      group = "wwwrun";
+      modules = [ "proxy_fcgi" ];
+      vhostConf = ''
+        Alias /dokuwiki "${webRoot}"
+        <Directory "${webRoot}">
+          DirectoryIndex index.php
+          <FilesMatch "\.php$">
+            SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
+          </FilesMatch>
+
+          AllowOverride All
+          Options +FollowSymlinks
+          Require all granted
+        </Directory>
+        '';
+    };
+    phpFpm = rec {
+      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
+
+        ; 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