]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Migrate mantisbt to pkgs
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 6 May 2019 12:06:31 +0000 (14:06 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 6 May 2019 12:06:31 +0000 (14:06 +0200)
15 files changed:
nixops/modules/websites/tools/git/default.nix
nixops/modules/websites/tools/git/gitweb.nix [moved from nixops/modules/websites/tools/git/gitweb/gitweb.nix with 100% similarity]
nixops/modules/websites/tools/git/mantisbt.nix [new file with mode: 0644]
nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-slack.json [deleted file]
nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-source-integration.json [deleted file]
nixops/modules/websites/tools/git/mantisbt/mantisbt.nix [deleted file]
pkgs/webapps/default.nix
pkgs/webapps/mantisbt_2/bug_report.php.diff [moved from nixops/modules/websites/tools/git/mantisbt/patches/bug_report.php.diff with 50% similarity]
pkgs/webapps/mantisbt_2/bug_report_page.php.diff [moved from nixops/modules/websites/tools/git/mantisbt/patches/bug_report_page.php.diff with 100% similarity]
pkgs/webapps/mantisbt_2/bugnote_add.php.diff [moved from nixops/modules/websites/tools/git/mantisbt/patches/bugnote_add.php.diff with 100% similarity]
pkgs/webapps/mantisbt_2/bugnote_add_inc.php.diff [moved from nixops/modules/websites/tools/git/mantisbt/patches/bugnote_add_inc.php.diff with 100% similarity]
pkgs/webapps/mantisbt_2/default.nix [new file with mode: 0644]
pkgs/webapps/mantisbt_2/plugins/slack/default.nix [new file with mode: 0644]
pkgs/webapps/mantisbt_2/plugins/source-integration/Source.API.php.diff [moved from nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-source-integration_Source.API.php.diff with 100% similarity]
pkgs/webapps/mantisbt_2/plugins/source-integration/default.nix [new file with mode: 0644]

index dc44049220bca7aace5d94c77e7f954c46a38ee4..e7dbd6f5ce074c368a727024a8aebe11ed0e6482 100644 (file)
@@ -1,10 +1,11 @@
 { lib, pkgs, config, myconfig, mylibs, ... }:
 let
-    mantisbt = pkgs.callPackage ./mantisbt/mantisbt.nix {
+    mantisbt = pkgs.callPackage ./mantisbt.nix {
       inherit (mylibs) fetchedGithub;
+      inherit (pkgs.webapps) mantisbt_2 mantisbt_2-plugins;
       env = myconfig.env.tools.mantisbt;
     };
-    gitweb = pkgs.callPackage ./gitweb/gitweb.nix { gitoliteDir = config.services.myGitolite.gitoliteDir; };
+    gitweb = pkgs.callPackage ./gitweb.nix { gitoliteDir = config.services.myGitolite.gitoliteDir; };
 
     cfg = config.services.myWebsites.tools.git;
 in {
diff --git a/nixops/modules/websites/tools/git/mantisbt.nix b/nixops/modules/websites/tools/git/mantisbt.nix
new file mode 100644 (file)
index 0000000..36193a7
--- /dev/null
@@ -0,0 +1,90 @@
+{ lib, env, mantisbt_2, mantisbt_2-plugins, writeText, stdenv, fetchurl, fetchedGithub }:
+rec {
+  keys = [{
+    dest = "webapps/tools-mantisbt";
+    user = apache.user;
+    group = apache.group;
+    permissions = "0400";
+    text = ''
+      <?php
+      $g_hostname              = '${env.postgresql.socket}';
+      $g_db_username           = '${env.postgresql.user}';
+      $g_db_password           = '${env.postgresql.password}';
+      $g_database_name         = '${env.postgresql.database}';
+      $g_db_type               = 'pgsql';
+      $g_crypto_master_salt    = '${env.master_salt}';
+      $g_allow_signup          = OFF;
+      $g_allow_anonymous_login = ON;
+      $g_anonymous_account     = 'anonymous';
+
+      $g_phpMailer_method      = PHPMAILER_METHOD_SENDMAIL;
+      $g_smtp_host             = 'localhost';
+      $g_smtp_username         = ''';
+      $g_smtp_password         = ''';
+      $g_webmaster_email       = 'mantisbt@tools.immae.eu';
+      $g_from_email            = 'mantisbt@tools.immae.eu';
+      $g_return_path_email     = 'mantisbt@tools.immae.eu';
+      $g_from_name             = 'Mantis Bug Tracker at git.immae.eu';
+      $g_email_receive_own     = OFF;
+      # --- LDAP ---
+      $g_login_method = LDAP;
+      $g_ldap_protocol_version = 3;
+      $g_ldap_server = 'ldaps://ldap.immae.eu:636';
+      $g_ldap_root_dn = 'ou=users,dc=immae,dc=eu';
+      $g_ldap_bind_dn = 'cn=mantisbt,ou=services,dc=immae,dc=eu';
+      $g_ldap_bind_passwd = '${env.ldap.password}';
+      $g_use_ldap_email = ON;
+      $g_use_ldap_realname = ON;
+      $g_ldap_uid_field = 'uid';
+      $g_ldap_realname_field = 'cn';
+      $g_ldap_organization = '(memberOf=cn=users,cn=mantisbt,ou=services,dc=immae,dc=eu)';
+    '';
+  }];
+  webRoot = (mantisbt_2.override { mantis_config = "/var/secrets/webapps/tools-mantisbt"; }).withPlugins (builtins.attrValues mantisbt_2-plugins);
+  apache = rec {
+    user = "wwwrun";
+    group = "wwwrun";
+    modules = [ "proxy_fcgi" ];
+    webappName = "tools_mantisbt";
+    root = "/run/current-system/webapps/${webappName}";
+    vhostConf = ''
+      Alias /mantisbt "${root}"
+      <Directory "${root}">
+        DirectoryIndex index.php
+        <FilesMatch "\.php$">
+          SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
+        </FilesMatch>
+
+        AllowOverride All
+        Options FollowSymlinks
+        Require all granted
+      </Directory>
+      <Directory "${root}/admin">
+        #Reenable during upgrade
+        Require all denied
+      </Directory>
+      '';
+  };
+  phpFpm = rec {
+    serviceDeps = [ "postgresql.service" "openldap.service" ];
+    basedir = builtins.concatStringsSep ":" (
+      [ webRoot "/var/secrets/webapps/tools-mantisbt" ]
+      ++ webRoot.plugins);
+    socket = "/var/run/phpfpm/mantisbt.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
+
+      php_admin_value[upload_max_filesize] = 5000000
+
+      php_admin_value[open_basedir] = "${basedir}:/tmp:/var/lib/php/sessions/mantisbt"
+      php_admin_value[session.save_path] = "/var/lib/php/sessions/mantisbt"
+      '';
+  };
+}
diff --git a/nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-slack.json b/nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-slack.json
deleted file mode 100644 (file)
index 54ea38b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-  "tag": "9286d2e-master",
-  "meta": {
-    "name": "mantisbt-plugin-slack",
-    "url": "https://github.com/mantisbt-plugins/Slack",
-    "branch": "master"
-  },
-  "github": {
-    "owner": "mantisbt-plugins",
-    "repo": "Slack",
-    "rev": "9286d2eeeb8a986ed949e378711fef5f0bf182dc",
-    "sha256": "0nn0v4jc967giilkzrppi5svd04m2hnals75xxp0iabcdjnih0mn",
-    "fetchSubmodules": true
-  }
-}
diff --git a/nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-source-integration.json b/nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-source-integration.json
deleted file mode 100644 (file)
index e36a68c..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-  "tag": "v2.1.5",
-  "meta": {
-    "name": "mantisbt-plugin-source-integration",
-    "url": "https://github.com/mantisbt-plugins/source-integration",
-    "branch": "refs/tags/v2.1.5"
-  },
-  "github": {
-    "owner": "mantisbt-plugins",
-    "repo": "source-integration",
-    "rev": "a48039a20abc50864e0e68c0c843b27058404386",
-    "sha256": "07g6q3hivmnd94r47pp0snk5bv4pa3piwclc9qhj612i4wnsazsk",
-    "fetchSubmodules": true
-  }
-}
diff --git a/nixops/modules/websites/tools/git/mantisbt/mantisbt.nix b/nixops/modules/websites/tools/git/mantisbt/mantisbt.nix
deleted file mode 100644 (file)
index 41c5e90..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-{ lib, env, writeText, stdenv, fetchurl, fetchedGithub }:
-let
-  mantisbt = let
-    plugins = {
-      slack = stdenv.mkDerivation (fetchedGithub ./mantisbt-plugin-slack.json // rec {
-        installPhase = ''
-          sed -i -e "s/return '@' . \\\$username;/return \\\$username;/" Slack.php
-          cp -a . $out
-          '';
-      });
-      source-integration = stdenv.mkDerivation (fetchedGithub ./mantisbt-plugin-source-integration.json // rec {
-        installPhase = ''
-          mkdir $out
-          patch -p1 < ${./mantisbt-plugin-source-integration_Source.API.php.diff}
-          cp -a Source* $out/
-        '';
-      });
-    };
-  in rec {
-    keys = [{
-      dest = "webapps/tools-mantisbt";
-      user = apache.user;
-      group = apache.group;
-      permissions = "0400";
-      text = ''
-        <?php
-        $g_hostname              = '${env.postgresql.socket}';
-        $g_db_username           = '${env.postgresql.user}';
-        $g_db_password           = '${env.postgresql.password}';
-        $g_database_name         = '${env.postgresql.database}';
-        $g_db_type               = 'pgsql';
-        $g_crypto_master_salt    = '${env.master_salt}';
-        $g_allow_signup          = OFF;
-        $g_allow_anonymous_login = ON;
-        $g_anonymous_account     = 'anonymous';
-
-        $g_phpMailer_method    = PHPMAILER_METHOD_SENDMAIL;
-        $g_smtp_host           = 'localhost';
-        $g_smtp_username               = ''';
-        $g_smtp_password               = ''';
-        $g_webmaster_email     = 'mantisbt@tools.immae.eu';
-        $g_from_email          = 'mantisbt@tools.immae.eu';
-        $g_return_path_email   = 'mantisbt@tools.immae.eu';
-        $g_from_name           = 'Mantis Bug Tracker at git.immae.eu';
-        $g_email_receive_own   = OFF;
-        # --- LDAP ---
-        $g_login_method = LDAP;
-        $g_ldap_protocol_version = 3;
-        $g_ldap_server = 'ldaps://ldap.immae.eu:636';
-        $g_ldap_root_dn = 'ou=users,dc=immae,dc=eu';
-        $g_ldap_bind_dn = 'cn=mantisbt,ou=services,dc=immae,dc=eu';
-        $g_ldap_bind_passwd = '${env.ldap.password}';
-        $g_use_ldap_email = ON;
-        $g_use_ldap_realname = ON;
-        $g_ldap_uid_field = 'uid';
-        $g_ldap_realname_field = 'cn';
-        $g_ldap_organization = '(memberOf=cn=users,cn=mantisbt,ou=services,dc=immae,dc=eu)';
-      '';
-    }];
-    webRoot = stdenv.mkDerivation rec {
-      name = "mantisbt-${version}";
-      version = "2.11.1";
-      src = fetchurl {
-        url = "https://downloads.sourceforge.net/project/mantisbt/mantis-stable/${version}/${name}.tar.gz";
-        sha256 = "0jnrqz6r2hf53v0k1lh3il7hlfiphn61r9wgg6mzyywkjxwq07md";
-      };
-      patches = [
-        ./patches/bug_report.php.diff
-        ./patches/bug_report_page.php.diff
-        ./patches/bugnote_add.php.diff
-        ./patches/bugnote_add_inc.php.diff
-        ];
-      installPhase = ''
-        cp -a . $out
-        ln -s /var/secrets/webapps/tools-mantisbt $out/config/config_inc.php
-        ln -s ${plugins.slack} $out/plugins/Slack
-        ln -s ${plugins.source-integration}/Source* $out/plugins/
-      '';
-    };
-    apache = rec {
-      user = "wwwrun";
-      group = "wwwrun";
-      modules = [ "proxy_fcgi" ];
-      webappName = "tools_mantisbt";
-      root = "/run/current-system/webapps/${webappName}";
-      vhostConf = ''
-        Alias /mantisbt "${root}"
-        <Directory "${root}">
-          DirectoryIndex index.php
-          <FilesMatch "\.php$">
-            SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
-          </FilesMatch>
-
-          AllowOverride All
-          Options FollowSymlinks
-          Require all granted
-        </Directory>
-        <Directory "${root}/admin">
-          #Reenable during upgrade
-          Require all denied
-        </Directory>
-        '';
-    };
-    phpFpm = rec {
-      serviceDeps = [ "postgresql.service" "openldap.service" ];
-      basedir = builtins.concatStringsSep ":" (
-        [ webRoot "/var/secrets/webapps/tools-mantisbt" ]
-        ++ lib.attrsets.mapAttrsToList (name: value: value) plugins);
-      socket = "/var/run/phpfpm/mantisbt.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
-
-        php_admin_value[upload_max_filesize] = 5000000
-
-        php_admin_value[open_basedir] = "${basedir}:/tmp:/var/lib/php/sessions/mantisbt"
-        php_admin_value[session.save_path] = "/var/lib/php/sessions/mantisbt"
-        '';
-    };
-  };
-in
-  mantisbt
index 50c3543b84443a17662bbadfdded6d4b0d223c77..eb01a186a6ed0e37f3985609b4193fb23fc9168f 100644 (file)
@@ -25,4 +25,12 @@ rec {
   phpldapadmin = callPackage ./phpldapadmin {};
 
   rompr = callPackage ./rompr { inherit mylibs; };
+
+  mantisbt_2 = callPackage ./mantisbt_2 {};
+  mantisbt_2-with-plugins = mantisbt_2.withPlugins (builtins.attrValues mantisbt_2-plugins);
+  mantisbt_2-plugins = let
+    names = [ "slack" "source-integration" ];
+  in
+    lib.attrsets.genAttrs names
+      (name: callPackage (./mantisbt_2/plugins + "/${name}") {});
 }
similarity index 50%
rename from nixops/modules/websites/tools/git/mantisbt/patches/bug_report.php.diff
rename to pkgs/webapps/mantisbt_2/bug_report.php.diff
index a520043aba769f4aa0c3b2711722e55b4dfbb6ed..29242529592174a44fd9d55ba501ee1a6e307aee 100644 (file)
@@ -1,8 +1,8 @@
---- a/bug_report.php   2018-02-10 21:29:27.000000000 +0100
-+++ b/bug_report.php   2018-03-03 15:04:19.622499678 +0100
-@@ -149,6 +149,17 @@
-       access_ensure_project_level( config_get( 'update_bug_assign_threshold' ) );
- }
+--- a/bug_report.php   2019-05-06 12:06:44.265508011 +0200
++++ b/bug_report.php   2019-05-06 12:09:40.106952738 +0200
+@@ -67,6 +67,17 @@
+       'copy_files' => $f_copy_attachments_from_parent
+ );
  
 +# begin captcha check for anon user
 +if ( current_user_is_anonymous() && get_gd_version() > 0 ) {
@@ -15,6 +15,6 @@
 +  }
 +}
 +
- # if a profile was selected then let's use that information
- if( 0 != $t_bug_data->profile_id ) {
-       if( profile_is_global( $t_bug_data->profile_id ) ) {
+ if( $f_master_bug_id > 0 ) {
+       bug_ensure_exists( $f_master_bug_id );
diff --git a/pkgs/webapps/mantisbt_2/default.nix b/pkgs/webapps/mantisbt_2/default.nix
new file mode 100644 (file)
index 0000000..3283a01
--- /dev/null
@@ -0,0 +1,39 @@
+{ mantis_config ? "/etc/mantisbt/config_inc.php", stdenv, fetchurl }:
+let
+  withPlugins = plugins: package.overrideAttrs(old: {
+    name = "${old.name}-with-plugins";
+    installPhase = old.installPhase + (
+      builtins.concatStringsSep "\n" (
+        map (value: if builtins.hasAttr "selector" value then
+            "ln -sf ${value}/${value.selector} $out/plugins/"
+          else
+            "ln -sf ${value} $out/plugins/${value.pluginName}"
+        ) plugins
+      ));
+    passthru.plugins = plugins;
+    passthru.withPlugins = morePlugins: old.withPlugins (morePlugins ++ plugins);
+  });
+  package = stdenv.mkDerivation rec {
+    name = "mantisbt-${version}";
+    version = "2.21.0";
+    src = fetchurl {
+      url = "https://downloads.sourceforge.net/project/mantisbt/mantis-stable/${version}/${name}.tar.gz";
+      sha256 = "13lx569dp1gibq5daqp7dj6gsqic85rrix1s7xkp60gwpzk8wiw5";
+    };
+    patches = [
+      ./bug_report.php.diff
+      ./bug_report_page.php.diff
+      ./bugnote_add.php.diff
+      ./bugnote_add_inc.php.diff
+    ];
+    installPhase = ''
+    cp -a . $out
+    ln -s ${mantis_config} $out/config/config_inc.php
+    '';
+
+    passthru = {
+      plugins = [];
+      inherit withPlugins;
+    };
+  };
+in package
diff --git a/pkgs/webapps/mantisbt_2/plugins/slack/default.nix b/pkgs/webapps/mantisbt_2/plugins/slack/default.nix
new file mode 100644 (file)
index 0000000..61ed15f
--- /dev/null
@@ -0,0 +1,18 @@
+{ stdenv, fetchFromGitHub }:
+stdenv.mkDerivation rec {
+  passthru = {
+    pluginName = "Slack";
+  };
+  version = "9286d2e-master";
+  name = "mantisbt-plugin-slack-${version}";
+  src = fetchFromGitHub {
+    owner = "mantisbt-plugins";
+    repo = "Slack";
+    rev = "9286d2eeeb8a986ed949e378711fef5f0bf182dc";
+    sha256 = "0nn0v4jc967giilkzrppi5svd04m2hnals75xxp0iabcdjnih0mn";
+  };
+  installPhase = ''
+          sed -i -e "s/return '@' . \\\$username;/return \\\$username;/" Slack.php
+          cp -a . $out
+  '';
+}
diff --git a/pkgs/webapps/mantisbt_2/plugins/source-integration/default.nix b/pkgs/webapps/mantisbt_2/plugins/source-integration/default.nix
new file mode 100644 (file)
index 0000000..dc6c7de
--- /dev/null
@@ -0,0 +1,21 @@
+{ stdenv, fetchFromGitHub }:
+stdenv.mkDerivation rec {
+  version = "v2.2.0";
+  name = "mantisbt-plugin-source-integration-${version}";
+  src = fetchFromGitHub {
+    owner = "mantisbt-plugins";
+    repo = "source-integration";
+    rev = "44fc9e2e770aff4f40f56833f26a86ce0e2deb76";
+    sha256 = "0gcm6kqqijnv303sk59zn27adwx5vkr545mwzyaq2nrpxnkwdy5b";
+  };
+  patches = [
+    ./Source.API.php.diff
+  ];
+  installPhase = ''
+    mkdir $out
+    cp -a Source* $out/
+    '';
+  passthru = {
+    selector = "Source*";
+  };
+}