aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nixops/modules/websites/tools/tools/default.nix2
-rw-r--r--nixops/modules/websites/tools/tools/dokuwiki-plugin-farmer.json15
-rw-r--r--nixops/modules/websites/tools/tools/dokuwiki-plugin-todo.json15
-rw-r--r--nixops/modules/websites/tools/tools/dokuwiki.nix157
-rw-r--r--pkgs/webapps/default.nix8
-rw-r--r--pkgs/webapps/dokuwiki/default.nix41
-rw-r--r--pkgs/webapps/dokuwiki/dokuwiki.json (renamed from nixops/modules/websites/tools/tools/dokuwiki.json)0
-rw-r--r--pkgs/webapps/dokuwiki/plugins/farmer.nix25
-rw-r--r--pkgs/webapps/dokuwiki/plugins/todo.nix18
9 files changed, 151 insertions, 130 deletions
diff --git a/nixops/modules/websites/tools/tools/default.nix b/nixops/modules/websites/tools/tools/default.nix
index 95679f6..1d459b7 100644
--- a/nixops/modules/websites/tools/tools/default.nix
+++ b/nixops/modules/websites/tools/tools/default.nix
@@ -30,7 +30,7 @@ let
30 env = myconfig.env.tools.shaarli; 30 env = myconfig.env.tools.shaarli;
31 }; 31 };
32 dokuwiki = pkgs.callPackage ./dokuwiki.nix { 32 dokuwiki = pkgs.callPackage ./dokuwiki.nix {
33 inherit (mylibs) fetchedGithub; 33 inherit (pkgs.webapps) dokuwiki dokuwiki-plugins;
34 }; 34 };
35 ldap = pkgs.callPackage ./ldap.nix { 35 ldap = pkgs.callPackage ./ldap.nix {
36 inherit (pkgs.webapps) phpldapadmin; 36 inherit (pkgs.webapps) phpldapadmin;
diff --git a/nixops/modules/websites/tools/tools/dokuwiki-plugin-farmer.json b/nixops/modules/websites/tools/tools/dokuwiki-plugin-farmer.json
deleted file mode 100644
index 4022eb4..0000000
--- a/nixops/modules/websites/tools/tools/dokuwiki-plugin-farmer.json
+++ /dev/null
@@ -1,15 +0,0 @@
1{
2 "tag": "72b8577-master",
3 "meta": {
4 "name": "dokuwiki-plugin-farmer",
5 "url": "https://github.com/cosmocode/dokuwiki-plugin-farmer",
6 "branch": "master"
7 },
8 "github": {
9 "owner": "cosmocode",
10 "repo": "dokuwiki-plugin-farmer",
11 "rev": "72b857734fd164bf79cc6e17abe56491d55c1072",
12 "sha256": "1c9vc1z7yvzjz4p054kshb9yd00a4bb52s43k9zav0lvwvjij9l0",
13 "fetchSubmodules": true
14 }
15}
diff --git a/nixops/modules/websites/tools/tools/dokuwiki-plugin-todo.json b/nixops/modules/websites/tools/tools/dokuwiki-plugin-todo.json
deleted file mode 100644
index 9576826..0000000
--- a/nixops/modules/websites/tools/tools/dokuwiki-plugin-todo.json
+++ /dev/null
@@ -1,15 +0,0 @@
1{
2 "tag": "49068ec-master",
3 "meta": {
4 "name": "dokuwiki-plugin-todo",
5 "url": "https://github.com/leibler/dokuwiki-plugin-todo",
6 "branch": "master"
7 },
8 "github": {
9 "owner": "leibler",
10 "repo": "dokuwiki-plugin-todo",
11 "rev": "49068ecea455ea997d1e4a7adab171ccaf8228e8",
12 "sha256": "1jaq623kp14fyhamsas5mk9ryqlk4q6x6znijrb5xhcdg3r83gmq",
13 "fetchSubmodules": true
14 }
15}
diff --git a/nixops/modules/websites/tools/tools/dokuwiki.nix b/nixops/modules/websites/tools/tools/dokuwiki.nix
index 2cd19f1..c61d15f 100644
--- a/nixops/modules/websites/tools/tools/dokuwiki.nix
+++ b/nixops/modules/websites/tools/tools/dokuwiki.nix
@@ -1,102 +1,61 @@
1{ lib, php, stdenv, writeText, fetchedGithub }: 1{ lib, stdenv, dokuwiki, dokuwiki-plugins }:
2let 2rec {
3 dokuwiki = let 3 varDir = "/var/lib/dokuwiki";
4 plugins = { 4 activationScript = {
5 farmer = stdenv.mkDerivation (fetchedGithub ./dokuwiki-plugin-farmer.json // rec { 5 deps = [ "wrappers" ];
6 installPhase = '' 6 text = ''
7 mkdir $out 7 if [ ! -d ${varDir} ]; then
8 cp -a * $out/ 8 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
9 ''; 9 ${varDir}/animals
10 }); 10 cp -a ${webRoot}/conf.dist ${varDir}/conf
11 todo = stdenv.mkDerivation (fetchedGithub ./dokuwiki-plugin-todo.json // rec { 11 cp -a ${webRoot}/data.dist ${varDir}/data
12 installPhase = '' 12 cp -a ${webRoot}/
13 mkdir $out 13 chown -R ${apache.user}:${apache.user} ${varDir}/config ${varDir}/data
14 cp -a * $out/ 14 chmod -R 755 ${varDir}/config ${varDir}/data
15 ''; 15 fi
16 }); 16 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
17 }; 17 '';
18 preload = writeText "preload.php" '' 18 };
19 <?php 19 webRoot = dokuwiki.withPlugins (builtins.attrValues dokuwiki-plugins);
20 # farm setup by farmer plugin 20 apache = rec {
21 if(file_exists('${plugins.farmer}/DokuWikiFarmCore.php')) 21 user = "wwwrun";
22 { 22 group = "wwwrun";
23 include('${plugins.farmer}/DokuWikiFarmCore.php'); 23 modules = [ "proxy_fcgi" ];
24 } 24 webappName = "tools_dokuwiki";
25 ''; 25 root = "/run/current-system/webapps/${webappName}";
26 in rec { 26 vhostConf = ''
27 varDir = "/var/lib/dokuwiki"; 27 Alias /dokuwiki "${root}"
28 activationScript = { 28 <Directory "${root}">
29 deps = [ "wrappers" ]; 29 DirectoryIndex index.php
30 text = '' 30 <FilesMatch "\.php$">
31 if [ ! -d ${varDir} ]; then 31 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
32 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \ 32 </FilesMatch>
33 ${varDir}/animals
34 cp -a ${webRoot}/conf.dist ${varDir}/conf
35 cp -a ${webRoot}/data.dist ${varDir}/data
36 cp -a ${webRoot}/
37 chown -R ${apache.user}:${apache.user} ${varDir}/config ${varDir}/data
38 chmod -R 755 ${varDir}/config ${varDir}/data
39 fi
40 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
41 '';
42 };
43 webRoot = stdenv.mkDerivation (fetchedGithub ./dokuwiki.json // rec {
44 buildPhase = ''
45 mv conf conf.dist
46 mv data data.dist
47 '';
48 installPhase = ''
49 cp -a . $out
50 cp ${preload} $out/inc/preload.php
51 ln -sf ${varDir}/{conf,data} $out/
52 ln -sf ${varDir}/conf/.htaccess $out/
53 ${builtins.concatStringsSep "\n" (
54 lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/lib/plugins/${name}") plugins
55 )}
56 '';
57 });
58 apache = rec {
59 user = "wwwrun";
60 group = "wwwrun";
61 modules = [ "proxy_fcgi" ];
62 webappName = "tools_dokuwiki";
63 root = "/run/current-system/webapps/${webappName}";
64 vhostConf = ''
65 Alias /dokuwiki "${root}"
66 <Directory "${root}">
67 DirectoryIndex index.php
68 <FilesMatch "\.php$">
69 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
70 </FilesMatch>
71 33
72 AllowOverride All 34 AllowOverride All
73 Options +FollowSymlinks 35 Options +FollowSymlinks
74 Require all granted 36 Require all granted
75 </Directory> 37 </Directory>
76 ''; 38 '';
77 }; 39 };
78 phpFpm = rec { 40 phpFpm = rec {
79 serviceDeps = [ "openldap.service" ]; 41 serviceDeps = [ "openldap.service" ];
80 basedir = builtins.concatStringsSep ":" ( 42 basedir = builtins.concatStringsSep ":" (
81 [ webRoot varDir ] 43 [ webRoot varDir ] ++ webRoot.plugins);
82 ++ lib.attrsets.mapAttrsToList (name: value: value) plugins); 44 socket = "/var/run/phpfpm/dokuwiki.sock";
83 socket = "/var/run/phpfpm/dokuwiki.sock"; 45 pool = ''
84 pool = '' 46 listen = ${socket}
85 listen = ${socket} 47 user = ${apache.user}
86 user = ${apache.user} 48 group = ${apache.group}
87 group = ${apache.group} 49 listen.owner = ${apache.user}
88 listen.owner = ${apache.user} 50 listen.group = ${apache.group}
89 listen.group = ${apache.group} 51 pm = ondemand
90 pm = ondemand 52 pm.max_children = 60
91 pm.max_children = 60 53 pm.process_idle_timeout = 60
92 pm.process_idle_timeout = 60
93 54
94 ; Needed to avoid clashes in browser cookies (same domain) 55 ; Needed to avoid clashes in browser cookies (same domain)
95 php_value[session.name] = DokuwikiPHPSESSID 56 php_value[session.name] = DokuwikiPHPSESSID
96 php_admin_value[open_basedir] = "${basedir}:/tmp" 57 php_admin_value[open_basedir] = "${basedir}:/tmp"
97 php_admin_value[session.save_path] = "${varDir}/phpSessions" 58 php_admin_value[session.save_path] = "${varDir}/phpSessions"
98 ''; 59 '';
99 };
100 }; 60 };
101in 61}
102 dokuwiki
diff --git a/pkgs/webapps/default.nix b/pkgs/webapps/default.nix
index 109eb6d..4403f5d 100644
--- a/pkgs/webapps/default.nix
+++ b/pkgs/webapps/default.nix
@@ -34,4 +34,12 @@ rec {
34 in 34 in
35 lib.attrsets.genAttrs names 35 lib.attrsets.genAttrs names
36 (name: callPackage (./mantisbt_2/plugins + "/${name}") {}); 36 (name: callPackage (./mantisbt_2/plugins + "/${name}") {});
37
38 dokuwiki = callPackage ./dokuwiki { inherit mylibs; };
39 dokuwiki-with-plugins = dokuwiki.withPlugins (builtins.attrValues dokuwiki-plugins);
40 dokuwiki-plugins = let
41 names = [ "farmer" "todo" ];
42 in
43 lib.attrsets.genAttrs names
44 (name: callPackage (./dokuwiki/plugins + "/${name}.nix") {});
37} 45}
diff --git a/pkgs/webapps/dokuwiki/default.nix b/pkgs/webapps/dokuwiki/default.nix
new file mode 100644
index 0000000..7b5d899
--- /dev/null
+++ b/pkgs/webapps/dokuwiki/default.nix
@@ -0,0 +1,41 @@
1{ varDir ? "/var/lib/dokuwiki", preload ? "", lib, stdenv, mylibs, writeText }:
2let
3 preloadFile = plugins: let preloads = [preload]
4 ++ builtins.concatMap (p: lib.optional (lib.hasAttr "preload" p) (p.preload p)) plugins;
5 in writeText "preload.php" (''
6 <?php
7 '' + builtins.concatStringsSep "\n" preloads
8 );
9 withPlugins = plugins: package.overrideAttrs(old: {
10 name = "${old.name}-with-plugins";
11 installPhase = old.installPhase + (
12 builtins.concatStringsSep "\n" (
13 map (value: "ln -sf ${value} $out/lib/plugins/${value.pluginName}") plugins
14 )
15 );
16 installPreloadPhase = ''
17 cp ${preloadFile plugins} $out/inc/preload.php
18 '';
19 passthru.plugins = plugins;
20 passthru.withPlugins = morePlugins: old.withPlugins (morePlugins ++ plugins);
21 });
22 package = stdenv.mkDerivation (mylibs.fetchedGithub ./dokuwiki.json // rec {
23 phases = "unpackPhase buildPhase installPhase installPreloadPhase fixupPhase";
24 buildPhase = ''
25 mv conf conf.dist
26 mv data data.dist
27 '';
28 installPhase = ''
29 cp -a . $out
30 ln -sf ${varDir}/{conf,data} $out/
31 ln -sf ${varDir}/conf/.htaccess $out/
32 '';
33 installPreloadPhase = ''
34 cp ${preloadFile []} $out/inc/preload.php
35 '';
36 passthru = {
37 plugins = [];
38 inherit withPlugins varDir;
39 };
40 });
41in package
diff --git a/nixops/modules/websites/tools/tools/dokuwiki.json b/pkgs/webapps/dokuwiki/dokuwiki.json
index fc03252..fc03252 100644
--- a/nixops/modules/websites/tools/tools/dokuwiki.json
+++ b/pkgs/webapps/dokuwiki/dokuwiki.json
diff --git a/pkgs/webapps/dokuwiki/plugins/farmer.nix b/pkgs/webapps/dokuwiki/plugins/farmer.nix
new file mode 100644
index 0000000..b737b2d
--- /dev/null
+++ b/pkgs/webapps/dokuwiki/plugins/farmer.nix
@@ -0,0 +1,25 @@
1{ stdenv, fetchFromGitHub }:
2stdenv.mkDerivation rec {
3 version = "72b8577-master";
4 name = "dokuwiki-plugin-farmer-${version}";
5 src = fetchFromGitHub {
6 owner = "cosmocode";
7 repo = "dokuwiki-plugin-farmer";
8 rev = "72b857734fd164bf79cc6e17abe56491d55c1072";
9 sha256 = "1c9vc1z7yvzjz4p054kshb9yd00a4bb52s43k9zav0lvwvjij9l0";
10 };
11 installPhase = ''
12 mkdir $out
13 cp -a * $out
14 '';
15 passthru = {
16 pluginName = "farmer";
17 preload = out: ''
18 # farm setup by farmer plugin
19 if (file_exists('${out}/DokuWikiFarmCore.php'))
20 {
21 include('${out}/DokuWikiFarmCore.php');
22 }
23 '';
24 };
25}
diff --git a/pkgs/webapps/dokuwiki/plugins/todo.nix b/pkgs/webapps/dokuwiki/plugins/todo.nix
new file mode 100644
index 0000000..a3e03fb
--- /dev/null
+++ b/pkgs/webapps/dokuwiki/plugins/todo.nix
@@ -0,0 +1,18 @@
1{ stdenv, fetchFromGitHub }:
2stdenv.mkDerivation rec {
3 version = "49068ec-master";
4 name = "dokuwiki-plugin-todo-${version}";
5 src = fetchFromGitHub {
6 owner = "leibler";
7 repo = "dokuwiki-plugin-todo";
8 rev = "49068ecea455ea997d1e4a7adab171ccaf8228e8";
9 sha256 = "1jaq623kp14fyhamsas5mk9ryqlk4q6x6znijrb5xhcdg3r83gmq";
10 };
11 installPhase = ''
12 mkdir $out
13 cp -a * $out
14 '';
15 passthru = {
16 pluginName = "todo";
17 };
18}