]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add rompr
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 25 Jan 2019 13:21:34 +0000 (14:21 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 25 Jan 2019 13:21:34 +0000 (14:21 +0100)
Fixes https://git.immae.eu/mantisbt/view.php?id=70

virtual/modules/websites/tools/ether/etherpad_lite.nix
virtual/modules/websites/tools/tools/default.nix
virtual/modules/websites/tools/tools/rompr.json [new file with mode: 0644]
virtual/modules/websites/tools/tools/rompr.nix [new file with mode: 0644]
virtual/modules/websites/tools/tools/ympd.nix

index f5f05b735d25dd16862d6fd4f414b4ac8be1a036..02071f1020472f92f0780ba05a99f3b0fb62e18f 100644 (file)
@@ -1,6 +1,6 @@
 { env, fetchedGithub, fetchurl, stdenv, writeText, pkgs, cacert }:
 let
-  listenPort = "18001";
+  listenPort = env.listenPort;
   sessionkey = writeText "SESSIONKEY.txt" env.session_key;
   apikey = writeText "APIKEY.txt" env.api_key;
   jquery = fetchurl {
@@ -41,7 +41,7 @@ let
         "favicon": "favicon.ico",
 
         "ip": "127.0.0.1",
-        "port" : ${listenPort},
+        "port" : ${env.listenPort},
         "showSettingsInAdminPage" : false,
         "dbType" : "postgres",
         "dbSettings" : {
index 7fb4974bd7687a006ca5fe85876e1c4dc07c3575..333ffb0c79e9cf6129b34f7340dd1ccf20bb4650 100644 (file)
@@ -1,7 +1,9 @@
 { lib, pkgs, config, myconfig, mylibs, ... }:
 let
     adminer = pkgs.callPackage ../../commons/adminer.nix {};
-    ympd = pkgs.callPackage ./ympd.nix {};
+    ympd = pkgs.callPackage ./ympd.nix {
+      env = myconfig.env.tools.ympd;
+    };
     ttrss = pkgs.callPackage ./ttrss.nix {
       inherit (mylibs) fetchedGithub fetchedGit;
       env = myconfig.env.tools.ttrss;
@@ -12,6 +14,10 @@ let
       inherit (mylibs) fetchedGithub;
       env = myconfig.env.tools.yourls;
     };
+    rompr = pkgs.callPackage ./rompr.nix {
+      inherit (mylibs) fetchedGithub;
+      env = myconfig.env.tools.rompr;
+    };
 
     cfg = config.services.myWebsites.tools.tools;
 in {
@@ -28,9 +34,10 @@ in {
       ++ ttrss.apache.modules
       ++ roundcubemail.apache.modules
       ++ wallabag.apache.modules
-      ++ yourls.apache.modules;
+      ++ yourls.apache.modules
+      ++ rompr.apache.modules;
 
-    services.ympd = ympd.config // { enable = false; };
+    services.ympd = ympd.config // { enable = true; };
 
     services.myWebsites.tools.vhostConfs.tools = {
       certName    = "eldiron";
@@ -43,6 +50,7 @@ in {
         roundcubemail.apache.vhostConf
         wallabag.apache.vhostConf
         yourls.apache.vhostConf
+        rompr.apache.vhostConf
       ];
     };
 
@@ -52,6 +60,7 @@ in {
       roundcubemail = roundcubemail.phpFpm.pool;
       wallabag = wallabag.phpFpm.pool;
       yourls = yourls.phpFpm.pool;
+      rompr = rompr.phpFpm.pool;
     };
 
     system.activationScripts = {
@@ -59,6 +68,7 @@ in {
       roundcubemail = roundcubemail.activationScript;
       wallabag = wallabag.activationScript;
       yourls = yourls.activationScript;
+      rompr = rompr.activationScript;
     };
 
     systemd.services.tt-rss = {
diff --git a/virtual/modules/websites/tools/tools/rompr.json b/virtual/modules/websites/tools/tools/rompr.json
new file mode 100644 (file)
index 0000000..778d915
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "1.24",
+  "meta": {
+    "name": "rompr",
+    "url": "https://github.com/fatg3erman/RompR",
+    "branch": "refs/tags/1.24"
+  },
+  "github": {
+    "owner": "fatg3erman",
+    "repo": "RompR",
+    "rev": "0d8f597027ac71b320963fe3f33f461a136312ad",
+    "sha256": "13p3c4whhmvz1vvh9fva5gdx4xji288k108hjdi8b1yn506lzix2",
+    "fetchSubmodules": true
+  }
+}
diff --git a/virtual/modules/websites/tools/tools/rompr.nix b/virtual/modules/websites/tools/tools/rompr.nix
new file mode 100644 (file)
index 0000000..055334e
--- /dev/null
@@ -0,0 +1,86 @@
+{ lib, env, stdenv, fetchedGithub }:
+let
+  rompr = let
+  in rec {
+    varDir = "/var/lib/rompr";
+    activationScript = ''
+      install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
+        ${varDir}/prefs ${varDir}/albumart ${varDir}/phpSessions
+    '';
+    webRoot = stdenv.mkDerivation (fetchedGithub ./rompr.json // rec {
+      installPhase = ''
+        cp -a . $out
+        ln -sf ../../../../../../${varDir}/prefs $out/prefs
+        ln -sf ../../../../../../${varDir}/albumart $out/albumart
+      '';
+    });
+    apache = {
+      user = "wwwrun";
+      group = "wwwrun";
+      modules = [ "headers" "mime" "proxy_fcgi" ];
+      vhostConf = ''
+        Alias /rompr ${webRoot}
+
+        <Directory ${webRoot}>
+          Options Indexes FollowSymLinks
+          DirectoryIndex index.php
+          AllowOverride all
+          Require all granted
+          Order allow,deny
+          Allow from all
+          ErrorDocument 404 /rompr/404.php
+          AddType image/x-icon .ico
+
+          <FilesMatch "\.php$">
+            SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
+          </FilesMatch>
+        </Directory>
+
+        <Directory ${webRoot}/albumart/small>
+            Header Set Cache-Control "max-age=0, no-store"
+            Header Set Cache-Control "no-cache, must-revalidate"
+        </Directory>
+
+        <Directory ${webRoot}/albumart/asdownloaded>
+            Header Set Cache-Control "max-age=0, no-store"
+            Header Set Cache-Control "no-cache, must-revalidate"
+        </Directory>
+
+        <LocationMatch "^/rompr">
+          Use LDAPConnect
+          Require ldap-group   cn=users,cn=mpd,ou=services,dc=immae,dc=eu
+          Require local
+        </LocationMatch>
+        '';
+    };
+    phpFpm = rec {
+      basedir = builtins.concatStringsSep ":" [ webRoot varDir ];
+      socket = "/var/run/phpfpm/rompr.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] = RomprPHPSESSID
+        php_admin_value[open_basedir] = "${basedir}:/tmp"
+        php_admin_value[session.save_path] = "${varDir}/phpSessions"
+        php_flag[magic_quotes_gpc] = Off
+        php_flag[track_vars] = On
+        php_flag[register_globals] = Off
+        php_admin_flag[allow_url_fopen] = On
+        php_value[include_path] = ${webRoot}
+        php_admin_value[upload_tmp_dir] = "${varDir}/prefs"
+        php_admin_value[post_max_size] = 32M
+        php_admin_value[upload_max_filesize] = 32M
+        php_admin_value[memory_limit] = 256M
+        '';
+    };
+  };
+in
+  rompr
index 74bf2e5d202c65449a6af4e152207405eafdcd9b..57443603aa891589f747275ba61b01b8934a6d7d 100644 (file)
@@ -1,12 +1,9 @@
-{}:
+{ env }:
 let
   ympd = rec {
     config = {
-      webPort = "localhost:18001";
-      mpd = {
-        host = "malige.home.immae.eu";
-        port = 6600;
-      };
+      webPort = "localhost:${env.listenPort}";
+      mpd = env.mpd;
     };
     apache = {
       modules = [