]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Move dokuwiki to pkgs
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 6 May 2019 22:01:09 +0000 (00:01 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 6 May 2019 22:01:09 +0000 (00:01 +0200)
nixops/modules/websites/tools/tools/default.nix
nixops/modules/websites/tools/tools/dokuwiki-plugin-farmer.json [deleted file]
nixops/modules/websites/tools/tools/dokuwiki-plugin-todo.json [deleted file]
nixops/modules/websites/tools/tools/dokuwiki.nix
pkgs/webapps/default.nix
pkgs/webapps/dokuwiki/default.nix [new file with mode: 0644]
pkgs/webapps/dokuwiki/dokuwiki.json [moved from nixops/modules/websites/tools/tools/dokuwiki.json with 100% similarity]
pkgs/webapps/dokuwiki/plugins/farmer.nix [new file with mode: 0644]
pkgs/webapps/dokuwiki/plugins/todo.nix [new file with mode: 0644]

index 95679f6850e10e1e95842bbb1c3c56466c1b43d1..1d459b7fb3cee7e6f9eddb9e83139a07a70d2df5 100644 (file)
@@ -30,7 +30,7 @@ let
       env = myconfig.env.tools.shaarli;
     };
     dokuwiki = pkgs.callPackage ./dokuwiki.nix {
-      inherit (mylibs) fetchedGithub;
+      inherit (pkgs.webapps) dokuwiki dokuwiki-plugins;
     };
     ldap = pkgs.callPackage ./ldap.nix {
       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 (file)
index 4022eb4..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-  "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
deleted file mode 100644 (file)
index 9576826..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-  "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
-  }
-}
index 2cd19f10a8698772a18018202ea15ce0f88131e4..c61d15f2547a0e91410240b855b99ad675c350f0 100644 (file)
-{ 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
+}
index 109eb6db237b0f232c9f89cd29e3b677755a7869..4403f5da3eb969ff711c55c8edd22f46493a42cc 100644 (file)
@@ -34,4 +34,12 @@ rec {
   in
     lib.attrsets.genAttrs names
       (name: callPackage (./mantisbt_2/plugins + "/${name}") {});
+
+  dokuwiki = callPackage ./dokuwiki { inherit mylibs; };
+  dokuwiki-with-plugins = dokuwiki.withPlugins (builtins.attrValues dokuwiki-plugins);
+  dokuwiki-plugins = let
+    names = [ "farmer" "todo" ];
+  in
+    lib.attrsets.genAttrs names
+      (name: callPackage (./dokuwiki/plugins + "/${name}.nix") {});
 }
diff --git a/pkgs/webapps/dokuwiki/default.nix b/pkgs/webapps/dokuwiki/default.nix
new file mode 100644 (file)
index 0000000..7b5d899
--- /dev/null
@@ -0,0 +1,41 @@
+{ 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
diff --git a/pkgs/webapps/dokuwiki/plugins/farmer.nix b/pkgs/webapps/dokuwiki/plugins/farmer.nix
new file mode 100644 (file)
index 0000000..b737b2d
--- /dev/null
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub }:
+stdenv.mkDerivation rec {
+  version = "72b8577-master";
+  name = "dokuwiki-plugin-farmer-${version}";
+  src = fetchFromGitHub {
+    owner = "cosmocode";
+    repo = "dokuwiki-plugin-farmer";
+    rev = "72b857734fd164bf79cc6e17abe56491d55c1072";
+    sha256 = "1c9vc1z7yvzjz4p054kshb9yd00a4bb52s43k9zav0lvwvjij9l0";
+  };
+  installPhase = ''
+    mkdir $out
+    cp -a * $out
+    '';
+  passthru = {
+    pluginName = "farmer";
+    preload = out: ''
+      # farm setup by farmer plugin
+      if (file_exists('${out}/DokuWikiFarmCore.php'))
+      {
+        include('${out}/DokuWikiFarmCore.php');
+      }
+    '';
+  };
+}
diff --git a/pkgs/webapps/dokuwiki/plugins/todo.nix b/pkgs/webapps/dokuwiki/plugins/todo.nix
new file mode 100644 (file)
index 0000000..a3e03fb
--- /dev/null
@@ -0,0 +1,18 @@
+{ stdenv, fetchFromGitHub }:
+stdenv.mkDerivation rec {
+  version = "49068ec-master";
+  name = "dokuwiki-plugin-todo-${version}";
+  src = fetchFromGitHub {
+    owner = "leibler";
+    repo = "dokuwiki-plugin-todo";
+    rev = "49068ecea455ea997d1e4a7adab171ccaf8228e8";
+    sha256 = "1jaq623kp14fyhamsas5mk9ryqlk4q6x6znijrb5xhcdg3r83gmq";
+  };
+  installPhase = ''
+    mkdir $out
+    cp -a * $out
+    '';
+  passthru = {
+    pluginName = "todo";
+  };
+}