From a8ef1adb4a90c2524ac09a85463598e5d41d2a4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Sat, 25 Apr 2020 15:49:40 +0200 Subject: [PATCH] Migrate phpbb and remove manual tools pages --- .../private/websites/tools/tools/default.nix | 41 +++++++------ .../private/websites/tools/tools/phpbb.nix | 59 ++++++++++++++++++ pkgs/webapps/default.nix | 2 + pkgs/webapps/phpbb/default.nix | 60 +++++++++++++++++++ pkgs/webapps/phpbb/extensions/adduser.nix | 22 +++++++ .../phpbb/extensions/autosubscribe.nix | 19 ++++++ pkgs/webapps/phpbb/extensions/mailinglist.nix | 18 ++++++ pkgs/webapps/phpbb/extensions/markdown.nix | 20 +++++++ pkgs/webapps/phpbb/extensions/mchat.nix | 21 +++++++ .../phpbb/extensions/monitoranswers.nix | 19 ++++++ pkgs/webapps/phpbb/langs/fr.nix | 12 ++++ 11 files changed, 275 insertions(+), 18 deletions(-) create mode 100644 modules/private/websites/tools/tools/phpbb.nix create mode 100644 pkgs/webapps/phpbb/default.nix create mode 100644 pkgs/webapps/phpbb/extensions/adduser.nix create mode 100644 pkgs/webapps/phpbb/extensions/autosubscribe.nix create mode 100644 pkgs/webapps/phpbb/extensions/mailinglist.nix create mode 100644 pkgs/webapps/phpbb/extensions/markdown.nix create mode 100644 pkgs/webapps/phpbb/extensions/mchat.nix create mode 100644 pkgs/webapps/phpbb/extensions/monitoranswers.nix create mode 100644 pkgs/webapps/phpbb/langs/fr.nix diff --git a/modules/private/websites/tools/tools/default.nix b/modules/private/websites/tools/tools/default.nix index dbd65e6..0cb7a10 100644 --- a/modules/private/websites/tools/tools/default.nix +++ b/modules/private/websites/tools/tools/default.nix @@ -38,6 +38,12 @@ let grocy = pkgs.callPackage ./grocy.nix { inherit (pkgs.webapps) grocy; }; + phpbb = pkgs.callPackage ./phpbb.nix { + phpbb = (pkgs.webapps.phpbb.withLangs (l: [ l.fr ])).withExts (e: [ + e.alfredoramos.markdown e.davidiq.mailinglist e.dmzx.mchat + e.empteintesduweb.monitoranswers e.lr94.autosubscribe + e.phpbbmodders.adduser ]); + }; webhooks = pkgs.callPackage ./webhooks.nix { env = config.myEnv.tools.webhooks; }; @@ -69,6 +75,7 @@ in { shaarli = shaarli.backups; ttrss = ttrss.backups; wallabag = wallabag.backups; + phpbb = phpbb.backups; }; services.websites.env.tools.modules = @@ -81,6 +88,7 @@ in { ++ rompr.apache.modules ++ shaarli.apache.modules ++ dokuwiki.apache.modules + ++ phpbb.apache.modules ++ ldap.apache.modules ++ kanboard.apache.modules; @@ -110,14 +118,13 @@ in { certName = "eldiron"; addToCerts = true; hosts = ["tools.immae.eu" ]; - root = "/var/lib/ftp/tools.immae.eu"; + root = landing; extraConfig = [ '' RedirectMatch 301 ^/vpn(.*)$ https://vpn.immae.eu$1 RedirectMatch 301 ^/roundcube(.*)$ https://mail.immae.eu/roundcube$1 RedirectMatch 301 ^/jappix(.*)$ https://im.immae.fr/converse - Alias /landing ${landing} DirectoryIndex index.html AllowOverride None @@ -127,20 +134,6 @@ in { SetHandler "proxy:unix:${pcfg.tools.socket}|fcgi://localhost" - - - DirectoryIndex index.php index.htm index.html - AllowOverride all - Require all granted - - SetHandler "proxy:unix:${pcfg.tools.socket}|fcgi://localhost" - - - RewriteEngine On - RewriteCond ${landing}%{REQUEST_URI} -f - RewriteRule ^(.*)$ /landing/$1 [L] - RewriteRule ^$ /landing/ [L] - '' (adminer.apache.vhostConf pcfg.adminer.socket) ympd.apache.vhostConf @@ -153,6 +146,7 @@ in { (ldap.apache.vhostConf pcfg.ldap.socket) (kanboard.apache.vhostConf pcfg.kanboard.socket) (grocy.apache.vhostConf pcfg.grocy.socket) + (phpbb.apache.vhostConf pcfg.phpbb.socket) '' Alias /paste /var/lib/fiche @@ -219,6 +213,10 @@ in { after = lib.mkAfter dokuwiki.phpFpm.serviceDeps; wants = dokuwiki.phpFpm.serviceDeps; }; + phpfpm-phpbb = { + after = lib.mkAfter phpbb.phpFpm.serviceDeps; + wants = phpbb.phpFpm.serviceDeps; + }; phpfpm-kanboard = { after = lib.mkAfter kanboard.phpFpm.serviceDeps; wants = kanboard.phpFpm.serviceDeps; @@ -289,8 +287,8 @@ in { # Needed to avoid clashes in browser cookies (same domain) "php_value[session.name]" = "ToolsPHPSESSID"; "php_admin_value[open_basedir]" = builtins.concatStringsSep ":" [ - "/run/wrappers/bin/sendmail" "/var/lib/ftp/tools.immae.eu" - landing "/tmp" "${config.secrets.location}/webapps/webhooks" + "/run/wrappers/bin/sendmail" landing "/tmp" + "${config.secrets.location}/webapps/webhooks" ]; }; phpEnv = { @@ -349,6 +347,11 @@ in { group = "wwwrun"; settings = dokuwiki.phpFpm.pool; }; + phpbb = { + user = "wwwrun"; + group = "wwwrun"; + settings = phpbb.phpFpm.pool; + }; ldap = { user = "wwwrun"; group = "wwwrun"; @@ -376,6 +379,7 @@ in { rompr = rompr.activationScript; shaarli = shaarli.activationScript; dokuwiki = dokuwiki.activationScript; + phpbb = phpbb.activationScript; kanboard = kanboard.activationScript; ldap = ldap.activationScript; }; @@ -383,6 +387,7 @@ in { services.websites.webappDirs = { _adminer = adminer.webRoot; "${dokuwiki.apache.webappName}" = dokuwiki.webRoot; + "${phpbb.apache.webappName}" = phpbb.webRoot; "${ldap.apache.webappName}" = "${ldap.webRoot}/htdocs"; "${rompr.apache.webappName}" = rompr.webRoot; "${shaarli.apache.webappName}" = shaarli.webRoot; diff --git a/modules/private/websites/tools/tools/phpbb.nix b/modules/private/websites/tools/tools/phpbb.nix new file mode 100644 index 0000000..fa26069 --- /dev/null +++ b/modules/private/websites/tools/tools/phpbb.nix @@ -0,0 +1,59 @@ +{ lib, phpbb, gnused }: +rec { + backups = { + rootDir = varDir; + }; + varDir = "/var/lib/phpbb"; + activationScript = { + deps = [ "wrappers" ]; + text = '' + if [ ! -d ${varDir} ]; then + install -m 0755 -o ${apache.user} -g ${apache.user} -d ${varDir} + cp -a ${phpbb}/vars/* ${varDir} + chown -R ${apache.user}:${apache.user} ${varDir} + fi + install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions + ''; + }; + webRoot = phpbb; + apache = rec { + user = "wwwrun"; + group = "wwwrun"; + modules = [ "proxy_fcgi" ]; + webappName = "tools_phpbb"; + root = "/run/current-system/webapps/${webappName}"; + vhostConf = socket: '' + Alias /forum "${root}" + + DirectoryIndex index.php + + SetHandler "proxy:unix:${socket}|fcgi://localhost" + + + AllowOverride All + Options FollowSymlinks + Require all granted + + # add instal to the list after install + + Require all denied + + ''; + }; + phpFpm = rec { + serviceDeps = [ "postgresql.service" ]; + basedir = builtins.concatStringsSep ":" [ "/run/wrappers/bin/sendmail" phpbb varDir ]; + pool = { + "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]" = "PhpBBPHPSESSID"; + "php_admin_value[open_basedir]" = "${basedir}:/tmp"; + "php_admin_value[session.save_path]" = "${varDir}/phpSessions"; + }; + }; +} diff --git a/pkgs/webapps/default.nix b/pkgs/webapps/default.nix index 8cc252d..3117f7e 100644 --- a/pkgs/webapps/default.nix +++ b/pkgs/webapps/default.nix @@ -69,6 +69,8 @@ rec { (name: callPackage (./nextcloud/apps + "/${name}.nix") { buildApp = nextcloud.buildApp; }); peertube = callPackage ./peertube { inherit mylibs; }; + phpbb = callPackage ./phpbb {}; + phpldapadmin = callPackage ./phpldapadmin {}; rompr = callPackage ./rompr { inherit mylibs; }; diff --git a/pkgs/webapps/phpbb/default.nix b/pkgs/webapps/phpbb/default.nix new file mode 100644 index 0000000..d7d008e --- /dev/null +++ b/pkgs/webapps/phpbb/default.nix @@ -0,0 +1,60 @@ +{ stdenv, fetchurl, callPackage +, varDir ? "/var/lib/phpbb" +}: +let + allExts = { + alfredoramos.markdown = callPackage ./extensions/markdown.nix {}; + davidiq.mailinglist = callPackage ./extensions/mailinglist.nix {}; + dmzx.mchat = callPackage ./extensions/mchat.nix {}; + empteintesduweb.monitoranswers = callPackage ./extensions/monitoranswers.nix {}; + lr94.autosubscribe = callPackage ./extensions/autosubscribe.nix {}; + phpbbmodders.adduser = callPackage ./extensions/adduser.nix {}; + }; + allLangs = { + fr = callPackage ./langs/fr.nix {}; + }; + toPassthru = pkg: { + withLangs = withLangs pkg; + withExts = withExts pkg; + }; + withExts = pkg: toExts: + let + exts = toExts allExts; + toInstallExt = ext: "cp -r ${ext}/* $out/ext/"; + newPhpBB = pkg.overrideAttrs(old: { + installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallExt exts); + passthru = toPassthru newPhpBB; + }); + in newPhpBB; + withLangs = pkg: toLangs: + let + langs = toLangs allLangs; + toInstallLang = lang: "cp -r ${lang}/*/ $out"; + newPhpBB = pkg.overrideAttrs(old: { + installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallLang langs); + passthru = toPassthru newPhpBB; + }); + in newPhpBB; + phpBB = stdenv.mkDerivation rec { + pname = "phpBB"; + version = "3.3.0"; + + src = fetchurl { + url = "https://download.phpbb.com/pub/release/3.3/${version}/${pname}-${version}.tar.bz2"; + sha256 = "a6234ac9dcf9086c025ece29a0a235f997a92bb9a994eff0ddcf8917e841262f"; + }; + + phases = [ "unpackPhase" "installPhase" ]; + + installPhase = '' + cp -a . $out + mkdir -p $out/vars + mv $out/{cache,files,store,config.php} $out/vars + ln -s ${varDir}/{cache,files,store,config.php} $out/ + echo -e "core:\n allow_install_dir: true" >> $out/config/production/config.yml + ''; + + passthru = toPassthru phpBB; + }; +in + phpBB diff --git a/pkgs/webapps/phpbb/extensions/adduser.nix b/pkgs/webapps/phpbb/extensions/adduser.nix new file mode 100644 index 0000000..f9073e6 --- /dev/null +++ b/pkgs/webapps/phpbb/extensions/adduser.nix @@ -0,0 +1,22 @@ +{ stdenv, fetchurl, unzip }: +stdenv.mkDerivation rec { + pname = "phpBB-extension-adduser"; + version = "1.0.4"; + src = fetchurl { + # https://www.phpbb.com/customise/db/extension/acp_add_user_2 + url = "https://www.phpbb.com/customise/db/download/141601"; + sha256 = "13m4anib74cinnv1ap3b1ncb8cxm3mzhhmlqhbrr9mlrqmwf4zg2"; + }; + + buildInputs = [ unzip ]; + phases = [ "unpackPhase" "installPhase" ]; + unpackPhase = '' + mkdir src + cd src + unzip $src + ''; + installPhase = '' + cp -a . $out + cp -a $out/phpbbmodders/adduser/language/en $out/phpbbmodders/adduser/language/fr + ''; +} diff --git a/pkgs/webapps/phpbb/extensions/autosubscribe.nix b/pkgs/webapps/phpbb/extensions/autosubscribe.nix new file mode 100644 index 0000000..78e23fc --- /dev/null +++ b/pkgs/webapps/phpbb/extensions/autosubscribe.nix @@ -0,0 +1,19 @@ +{ stdenv, fetchurl, unzip }: +stdenv.mkDerivation rec { + pname = "phpBB-extension-autosubscribe"; + version = "1.1.0"; + src = fetchurl { + # https://www.phpbb.com/customise/db/extension/autosubscribe + url = "https://www.phpbb.com/customise/db/download/146556"; + sha256 = "0dsay463g4impw86w1nv307nslc195fkgkqmihfn5kc0hya0giv0"; + }; + + buildInputs = [ unzip ]; + phases = [ "unpackPhase" "installPhase" ]; + unpackPhase = '' + mkdir src + cd src + unzip $src + ''; + installPhase = "cp -a . $out"; +} diff --git a/pkgs/webapps/phpbb/extensions/mailinglist.nix b/pkgs/webapps/phpbb/extensions/mailinglist.nix new file mode 100644 index 0000000..d432aaf --- /dev/null +++ b/pkgs/webapps/phpbb/extensions/mailinglist.nix @@ -0,0 +1,18 @@ +{ stdenv, fetchurl, unzip }: +stdenv.mkDerivation rec { + pname = "phpBB-extension-MailingList"; + version = "2.0.0"; + src = fetchurl { + url = "https://github.com/DavidIQ/MailingList/archive/${version}.tar.gz"; + sha256 = "1ddg8bci85jwmvyakcwdn4yzqwz1rgy7ljf4nmfk9p2kvx2nhj62"; + }; + + phases = [ "unpackPhase" "installPhase" ]; + installPhase = '' + mkdir -p $out/davidiq/mailinglist + cp -a . $out/davidiq/mailinglist + # delete last two lines which contain EMAIL_SIG + sed -i -n -e :a -e '1,2!{P;N;D;};N;ba' $out/davidiq/mailinglist/language/en/email/* + ''; +} + diff --git a/pkgs/webapps/phpbb/extensions/markdown.nix b/pkgs/webapps/phpbb/extensions/markdown.nix new file mode 100644 index 0000000..3bd73c7 --- /dev/null +++ b/pkgs/webapps/phpbb/extensions/markdown.nix @@ -0,0 +1,20 @@ +{ stdenv, fetchurl, unzip }: +stdenv.mkDerivation rec { + pname = "phpBB-extension-markdown"; + version = "1.2.0"; + src = fetchurl { + # https://www.phpbb.com/customise/db/extension/markdown + name = "alfredoramos_markdown_${version}.zip"; + url = "https://www.phpbb.com/customise/db/download/173626"; + sha256 = "0bmgi8qr6azaaz8xnz8dkyf147dyawqvqr93r01qbm9s8bfkpzqx"; + }; + + buildInputs = [ unzip ]; + phases = [ "unpackPhase" "installPhase" ]; + unpackPhase = '' + mkdir src + cd src + unzip $src + ''; + installPhase = "cp -a . $out"; +} diff --git a/pkgs/webapps/phpbb/extensions/mchat.nix b/pkgs/webapps/phpbb/extensions/mchat.nix new file mode 100644 index 0000000..93ea861 --- /dev/null +++ b/pkgs/webapps/phpbb/extensions/mchat.nix @@ -0,0 +1,21 @@ +{ stdenv, fetchurl, unzip }: +stdenv.mkDerivation rec { + pname = "phpBB-extension-mchat"; + version = "2.1.3"; + src = fetchurl { + # https://www.phpbb.com/customise/db/extension/mchat_extension + name = "dmzx_mchat_${version}.zip"; + url = "https://www.phpbb.com/customise/db/download/168331"; + sha256 = "0mcka02wamn899vg64m1c5d5k6f4qml18cshhzfvccrdc7a0m5p1"; + }; + + buildInputs = [ unzip ]; + phases = [ "unpackPhase" "installPhase" ]; + unpackPhase = '' + mkdir src + cd src + unzip $src + ''; + installPhase = "cp -a . $out"; +} + diff --git a/pkgs/webapps/phpbb/extensions/monitoranswers.nix b/pkgs/webapps/phpbb/extensions/monitoranswers.nix new file mode 100644 index 0000000..52c852e --- /dev/null +++ b/pkgs/webapps/phpbb/extensions/monitoranswers.nix @@ -0,0 +1,19 @@ +{ stdenv, fetchurl, unzip }: +stdenv.mkDerivation rec { + pname = "phpBB-extension-monitoranswers"; + version = "1.0.0"; + src = fetchurl { + # http://forums.phpbb-fr.com/extensions-developpement-en-cours/sujet208410.html + url = "https://www.empreintesduweb.com/dl/extension_empreintesduweb_monitoranswers_v100.zip"; + sha256 = "0g5khzz7brkra9rnnjh8vsv11h8vf36pcw53b4wrkcjb66bfm20s"; + }; + + buildInputs = [ unzip ]; + phases = [ "unpackPhase" "installPhase" ]; + unpackPhase = '' + mkdir src + cd src + unzip $src + ''; + installPhase = "cp -a . $out"; +} diff --git a/pkgs/webapps/phpbb/langs/fr.nix b/pkgs/webapps/phpbb/langs/fr.nix new file mode 100644 index 0000000..12f2df0 --- /dev/null +++ b/pkgs/webapps/phpbb/langs/fr.nix @@ -0,0 +1,12 @@ +{ stdenv, fetchurl }: +stdenv.mkDerivation rec { + pname = "phpBB-language-fr"; + version = "v4.0.0"; + src = fetchurl { + url = "https://github.com/milescellar/phpbb-language-fr/archive/${version}.tar.gz"; + sha256 = "0pkw55pb8ka4ayn1861hwvjwzs8vkq04yaxrs7zm9c8lh2g7y8z0"; + }; + + phases = [ "unpackPhase" "installPhase" ]; + installPhase = "cp -a . $out"; +} -- 2.41.0