From 43dac87fef530d52961cb7df5fdb01aa651d802c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 6 May 2019 14:06:31 +0200 Subject: [PATCH] Migrate mantisbt to pkgs --- nixops/modules/websites/tools/git/default.nix | 5 +- .../tools/git/{gitweb => }/gitweb.nix | 0 .../modules/websites/tools/git/mantisbt.nix | 90 ++++++++++++ .../git/mantisbt/mantisbt-plugin-slack.json | 15 -- .../mantisbt-plugin-source-integration.json | 15 -- .../websites/tools/git/mantisbt/mantisbt.nix | 128 ------------------ pkgs/webapps/default.nix | 8 ++ .../webapps/mantisbt_2}/bug_report.php.diff | 16 +-- .../mantisbt_2}/bug_report_page.php.diff | 0 .../webapps/mantisbt_2}/bugnote_add.php.diff | 0 .../mantisbt_2}/bugnote_add_inc.php.diff | 0 pkgs/webapps/mantisbt_2/default.nix | 39 ++++++ .../mantisbt_2/plugins/slack/default.nix | 18 +++ .../source-integration/Source.API.php.diff | 0 .../plugins/source-integration/default.nix | 21 +++ 15 files changed, 187 insertions(+), 168 deletions(-) rename nixops/modules/websites/tools/git/{gitweb => }/gitweb.nix (100%) create mode 100644 nixops/modules/websites/tools/git/mantisbt.nix delete mode 100644 nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-slack.json delete mode 100644 nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-source-integration.json delete mode 100644 nixops/modules/websites/tools/git/mantisbt/mantisbt.nix rename {nixops/modules/websites/tools/git/mantisbt/patches => pkgs/webapps/mantisbt_2}/bug_report.php.diff (50%) rename {nixops/modules/websites/tools/git/mantisbt/patches => pkgs/webapps/mantisbt_2}/bug_report_page.php.diff (100%) rename {nixops/modules/websites/tools/git/mantisbt/patches => pkgs/webapps/mantisbt_2}/bugnote_add.php.diff (100%) rename {nixops/modules/websites/tools/git/mantisbt/patches => pkgs/webapps/mantisbt_2}/bugnote_add_inc.php.diff (100%) create mode 100644 pkgs/webapps/mantisbt_2/default.nix create mode 100644 pkgs/webapps/mantisbt_2/plugins/slack/default.nix rename nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-source-integration_Source.API.php.diff => pkgs/webapps/mantisbt_2/plugins/source-integration/Source.API.php.diff (100%) create mode 100644 pkgs/webapps/mantisbt_2/plugins/source-integration/default.nix diff --git a/nixops/modules/websites/tools/git/default.nix b/nixops/modules/websites/tools/git/default.nix index dc44049..e7dbd6f 100644 --- a/nixops/modules/websites/tools/git/default.nix +++ b/nixops/modules/websites/tools/git/default.nix @@ -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/gitweb/gitweb.nix b/nixops/modules/websites/tools/git/gitweb.nix similarity index 100% rename from nixops/modules/websites/tools/git/gitweb/gitweb.nix rename to nixops/modules/websites/tools/git/gitweb.nix diff --git a/nixops/modules/websites/tools/git/mantisbt.nix b/nixops/modules/websites/tools/git/mantisbt.nix new file mode 100644 index 0000000..36193a7 --- /dev/null +++ b/nixops/modules/websites/tools/git/mantisbt.nix @@ -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 = '' + + DirectoryIndex index.php + + SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" + + + AllowOverride All + Options FollowSymlinks + Require all granted + + + #Reenable during upgrade + Require all denied + + ''; + }; + 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 index 54ea38b..0000000 --- a/nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-slack.json +++ /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 index e36a68c..0000000 --- a/nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-source-integration.json +++ /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 index 41c5e90..0000000 --- a/nixops/modules/websites/tools/git/mantisbt/mantisbt.nix +++ /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 = '' - - DirectoryIndex index.php - - SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" - - - AllowOverride All - Options FollowSymlinks - Require all granted - - - #Reenable during upgrade - Require all denied - - ''; - }; - 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 diff --git a/pkgs/webapps/default.nix b/pkgs/webapps/default.nix index 50c3543..eb01a18 100644 --- a/pkgs/webapps/default.nix +++ b/pkgs/webapps/default.nix @@ -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}") {}); } diff --git a/nixops/modules/websites/tools/git/mantisbt/patches/bug_report.php.diff b/pkgs/webapps/mantisbt_2/bug_report.php.diff 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 a520043..2924252 100644 --- a/nixops/modules/websites/tools/git/mantisbt/patches/bug_report.php.diff +++ b/pkgs/webapps/mantisbt_2/bug_report.php.diff @@ -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/nixops/modules/websites/tools/git/mantisbt/patches/bug_report_page.php.diff b/pkgs/webapps/mantisbt_2/bug_report_page.php.diff similarity index 100% rename from nixops/modules/websites/tools/git/mantisbt/patches/bug_report_page.php.diff rename to pkgs/webapps/mantisbt_2/bug_report_page.php.diff diff --git a/nixops/modules/websites/tools/git/mantisbt/patches/bugnote_add.php.diff b/pkgs/webapps/mantisbt_2/bugnote_add.php.diff similarity index 100% rename from nixops/modules/websites/tools/git/mantisbt/patches/bugnote_add.php.diff rename to pkgs/webapps/mantisbt_2/bugnote_add.php.diff diff --git a/nixops/modules/websites/tools/git/mantisbt/patches/bugnote_add_inc.php.diff b/pkgs/webapps/mantisbt_2/bugnote_add_inc.php.diff similarity index 100% rename from nixops/modules/websites/tools/git/mantisbt/patches/bugnote_add_inc.php.diff rename to pkgs/webapps/mantisbt_2/bugnote_add_inc.php.diff diff --git a/pkgs/webapps/mantisbt_2/default.nix b/pkgs/webapps/mantisbt_2/default.nix new file mode 100644 index 0000000..3283a01 --- /dev/null +++ b/pkgs/webapps/mantisbt_2/default.nix @@ -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 index 0000000..61ed15f --- /dev/null +++ b/pkgs/webapps/mantisbt_2/plugins/slack/default.nix @@ -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/nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-source-integration_Source.API.php.diff b/pkgs/webapps/mantisbt_2/plugins/source-integration/Source.API.php.diff similarity index 100% rename from nixops/modules/websites/tools/git/mantisbt/mantisbt-plugin-source-integration_Source.API.php.diff rename to pkgs/webapps/mantisbt_2/plugins/source-integration/Source.API.php.diff 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 index 0000000..dc6c7de --- /dev/null +++ b/pkgs/webapps/mantisbt_2/plugins/source-integration/default.nix @@ -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*"; + }; +} -- 2.41.0