]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add ttrss
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 8 Jan 2019 09:47:14 +0000 (10:47 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 8 Jan 2019 12:27:14 +0000 (13:27 +0100)
virtual/eldiron.nix
virtual/packages.nix
virtual/packages/tt-rss.json [new file with mode: 0644]
virtual/packages/ttrss-af-feedmod_type_replace.patch [new file with mode: 0644]
virtual/packages/ttrss-af_feedmod.json [new file with mode: 0644]
virtual/packages/ttrss-auth-ldap.json [new file with mode: 0644]
virtual/packages/ttrss-feediron.json [new file with mode: 0644]
virtual/packages/ttrss-feediron_json_reformat.patch [new file with mode: 0644]
virtual/packages/ttrss-ff_instagram.json [new file with mode: 0644]
virtual/packages/ttrss-tumblr_gdpr_ua.json [new file with mode: 0644]
virtual/packages/ttrss.nix [new file with mode: 0644]

index 6237e06b9df49cb86018619a03d9171b6fc52242..2152aff465670c1829471a22dbad9bd22d0a4780 100644 (file)
@@ -8,7 +8,7 @@
     with import ../libs.nix;
     let
         mypkgs = pkgs.callPackage ./packages.nix {
-          inherit checkEnv fetchedGitPrivate fetchedGithub;
+          inherit checkEnv fetchedGit fetchedGitPrivate fetchedGithub;
         };
     in
   {
         aten_prod = mypkgs.aten_prod.phpFpm.pool;
         nextcloud = mypkgs.nextcloud.phpFpm.pool;
         mantisbt = mypkgs.mantisbt.phpFpm.pool;
+        ttrss = mypkgs.ttrss.phpFpm.pool;
       };
     };
 
       aten_dev  = mypkgs.aten_dev.activationScript;
       aten_prod = mypkgs.aten_prod.activationScript;
       nextcloud = mypkgs.nextcloud.activationScript;
+      ttrss = mypkgs.ttrss.activationScript;
       httpd = ''
         install -d -m 0755 /var/lib/acme/acme-challenge
         install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions
         install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions/adminer
         install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions/mantisbt
+        install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions/ttrss
         '';
       redis = ''
         mkdir -p /run/redis
         mypkgs.ympd.apache.modules ++
         mypkgs.git.web.apache.modules ++
         mypkgs.mantisbt.apache.modules ++
+        mypkgs.ttrss.apache.modules ++
         pkgs.lib.lists.flatten (pkgs.lib.attrsets.mapAttrsToList (n: v: v.modules) apacheConfig) ++
         [ "macro" ]);
       extraConfig = builtins.concatStringsSep "\n"
           extraConfig = builtins.concatStringsSep "\n" [
             mypkgs.adminer.apache.vhostConf
             mypkgs.ympd.apache.vhostConf
+            mypkgs.ttrss.apache.vhostConf
           ];
         })
         (withConf "eldiron" // {
         "5 0 * * * root ${stats "osteopathe-cc.fr" ./packages/chloe_goaccess.conf}"
         ];
     };
+
+    systemd.services.tt-rss = {
+      description = "Tiny Tiny RSS feeds update daemon";
+      serviceConfig = {
+        User = "wwwrun";
+        ExecStart = "${pkgs.php}/bin/php ${mypkgs.ttrss.webRoot}/update.php --daemon";
+        StandardOutput = "syslog";
+        StandardError = "syslog";
+        PermissionsStartOnly = true;
+      };
+
+      wantedBy = [ "multi-user.target" ];
+      requires = ["postgresql.service"];
+      after = ["network.target" "postgresql.service"];
+    };
   };
 }
index 88b4717b91de9c89ccf6e2a598accd7fd866be22..ee5dc155634b73a2d20ecace8a0d53b0c30b4164 100644 (file)
@@ -1,4 +1,4 @@
-{ callPackage, checkEnv, fetchedGitPrivate, fetchedGithub }:
+{ callPackage, checkEnv, fetchedGit, fetchedGitPrivate, fetchedGithub }:
 let
   connexionswing = callPackage ./packages/connexionswing.nix { inherit checkEnv fetchedGitPrivate; };
   ludivinecassal = callPackage ./packages/ludivinecassal.nix { inherit checkEnv fetchedGitPrivate; };
@@ -10,6 +10,7 @@ let
   ympd = callPackage ./packages/ympd.nix {};
   gitweb = callPackage ./packages/gitweb.nix {};
   mantisbt = callPackage ./packages/mantisbt.nix { inherit checkEnv fetchedGithub; };
+  ttrss = callPackage ./packages/ttrss.nix { inherit checkEnv fetchedGithub fetchedGit; };
 in
   {
     inherit adminer;
@@ -26,6 +27,7 @@ in
     chloe_prod = chloe { environment = "prod"; };
     inherit nextcloud;
     inherit mantisbt;
+    inherit ttrss;
     # FIXME: add buildbot
     git = { web = gitweb; };
   }
diff --git a/virtual/packages/tt-rss.json b/virtual/packages/tt-rss.json
new file mode 100644 (file)
index 0000000..e2731b0
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "tag": "986ca25-master",
+  "meta": {
+    "name": "tt-rss",
+    "url": "https://git.tt-rss.org/fox/tt-rss.git",
+    "branch": "master"
+  },
+  "git": {
+    "url": "https://git.tt-rss.org/fox/tt-rss.git",
+    "rev": "986ca251f995f7754a0470d3e0c44538a545081f",
+    "sha256": "0xkafkh7l9zazm5d6snlq03kdfxfhkb4c8fdsb32wn8b9bhdzf5s",
+    "fetchSubmodules": true
+  }
+}
diff --git a/virtual/packages/ttrss-af-feedmod_type_replace.patch b/virtual/packages/ttrss-af-feedmod_type_replace.patch
new file mode 100644 (file)
index 0000000..d622577
--- /dev/null
@@ -0,0 +1,12 @@
+--- a/init.php 2014-06-16 14:21:06.995480038 +0200
++++ b/init.php 2014-06-16 14:22:00.151027654 +0200
+@@ -147,6 +147,9 @@
+                         }
+                     }
+                     break;
++                case 'replace':
++                    $article['content'] = preg_replace("/".$config['pattern']."/",$config['replacement'],$article['content']);
++                    break;
+                 default:
+                     // unknown type or invalid config
diff --git a/virtual/packages/ttrss-af_feedmod.json b/virtual/packages/ttrss-af_feedmod.json
new file mode 100644 (file)
index 0000000..e57fcce
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "0ea2092-master",
+  "meta": {
+    "name": "ttrss-af_feedmod",
+    "url": "https://github.com/mbirth/ttrss_plugin-af_feedmod",
+    "branch": "master"
+  },
+  "github": {
+    "owner": "mbirth",
+    "repo": "ttrss_plugin-af_feedmod",
+    "rev": "0ea2092dd34067ecd898802cfca3570023d1ecfe",
+    "sha256": "02ibf47zcrsc2rr45wsix8gxyyf371davj8n8i0gj1zdq95klvnv",
+    "fetchSubmodules": true
+  }
+}
diff --git a/virtual/packages/ttrss-auth-ldap.json b/virtual/packages/ttrss-auth-ldap.json
new file mode 100644 (file)
index 0000000..c8aaab5
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "4d751b0-master",
+  "meta": {
+    "name": "ttrss-auth-ldap",
+    "url": "https://github.com/hydrian/TTRSS-Auth-LDAP",
+    "branch": "master"
+  },
+  "github": {
+    "owner": "hydrian",
+    "repo": "TTRSS-Auth-LDAP",
+    "rev": "4d751b095c29a8dbe2dc7bb07777742956136e94",
+    "sha256": "0b9fl86acrzpcv41r7pj3bl8b3n72hpkdywzx9zjyfqv5pskxyim",
+    "fetchSubmodules": true
+  }
+}
diff --git a/virtual/packages/ttrss-feediron.json b/virtual/packages/ttrss-feediron.json
new file mode 100644 (file)
index 0000000..5dbec92
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "407168c-master",
+  "meta": {
+    "name": "ttrss-feediron",
+    "url": "https://github.com/m42e/ttrss_plugin-feediron",
+    "branch": "master"
+  },
+  "github": {
+    "owner": "m42e",
+    "repo": "ttrss_plugin-feediron",
+    "rev": "407168c628880b5ced572cc549db6d50e866d3c8",
+    "sha256": "17b95ifpcph6m03hjd1mhi8gi1hw9yd3fnffmw66fqr5c9l3zd9r",
+    "fetchSubmodules": true
+  }
+}
diff --git a/virtual/packages/ttrss-feediron_json_reformat.patch b/virtual/packages/ttrss-feediron_json_reformat.patch
new file mode 100644 (file)
index 0000000..e1c44d9
--- /dev/null
@@ -0,0 +1,18 @@
+diff --git a/init.php b/init.php
+index 3c0f2f9..1aad146 100644
+--- a/init.php
++++ b/init.php
+@@ -600,10 +600,11 @@ class Feediron extends Plugin implements IHandler
+                       return false;
+               }
+-              $this->host->set($this, 'json_conf', Feediron_Json::format($json_conf));
++                $new_conf = json_encode(json_decode($json_conf), JSON_PRETTY_PRINT);
++                $this->host->set($this, 'json_conf', $new_conf);
+               $json_reply['success'] = true;
+               $json_reply['message'] = __('Configuration saved.');
+-              $json_reply['json_conf'] = Feediron_Json::format($json_conf);
++                $json_reply['json_conf'] = $new_conf;
+               echo json_encode($json_reply);
+       }
diff --git a/virtual/packages/ttrss-ff_instagram.json b/virtual/packages/ttrss-ff_instagram.json
new file mode 100644 (file)
index 0000000..1f241b9
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "0366ffb-master",
+  "meta": {
+    "name": "ttrss-ff_instagram",
+    "url": "https://github.com/wltb/ff_instagram",
+    "branch": "master"
+  },
+  "github": {
+    "owner": "wltb",
+    "repo": "ff_instagram",
+    "rev": "0366ffb18c4d490c8fbfba2f5f3367a5af23cfe8",
+    "sha256": "0vvzl6wi6jmrqknsfddvckjgsgfizz1d923d1nyrpzjfn6bda1vk",
+    "fetchSubmodules": true
+  }
+}
diff --git a/virtual/packages/ttrss-tumblr_gdpr_ua.json b/virtual/packages/ttrss-tumblr_gdpr_ua.json
new file mode 100644 (file)
index 0000000..eafbcfe
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "287c584-master",
+  "meta": {
+    "name": "ttrss-tumblr_gdpr_ua",
+    "url": "https://github.com/hkockerbeck/ttrss-tumblr-gdpr-ua",
+    "branch": "master"
+  },
+  "github": {
+    "owner": "hkockerbeck",
+    "repo": "ttrss-tumblr-gdpr-ua",
+    "rev": "287c584e68845d524f920156bff0b2eaa6f65117",
+    "sha256": "1fviawgcclqky4k4xv1sqzvpb8i74w9f0pclm09m78s8l85wh9py",
+    "fetchSubmodules": true
+  }
+}
diff --git a/virtual/packages/ttrss.nix b/virtual/packages/ttrss.nix
new file mode 100644 (file)
index 0000000..f7b0f61
--- /dev/null
@@ -0,0 +1,182 @@
+{ lib, php, checkEnv, writeText, stdenv, fetchedGit, fetchedGithub }:
+let
+  ttrss = let
+    plugins = {
+      auth_ldap = stdenv.mkDerivation (fetchedGithub ./ttrss-auth-ldap.json // rec {
+        installPhase = ''
+          mkdir $out
+          cp plugins/auth_ldap/init.php $out
+        '';
+      });
+      af_feedmod = stdenv.mkDerivation (fetchedGithub ./ttrss-af_feedmod.json // rec {
+        patches = [ ./ttrss-af-feedmod_type_replace.patch ];
+        installPhase = ''
+          mkdir $out
+          cp init.php $out
+        '';
+      });
+      feediron = stdenv.mkDerivation (fetchedGithub ./ttrss-feediron.json // rec {
+        patches = [ ./ttrss-feediron_json_reformat.patch ];
+        installPhase = ''
+          mkdir $out
+          cp -a . $out
+        '';
+      });
+      ff_instagram = stdenv.mkDerivation (fetchedGithub ./ttrss-ff_instagram.json // rec {
+        installPhase = ''
+          mkdir $out
+          cp -a . $out
+        '';
+      });
+      tumblr_gdpr_ua = stdenv.mkDerivation (fetchedGithub ./ttrss-tumblr_gdpr_ua.json // rec {
+        installPhase = ''
+          mkdir $out
+          cp -a . $out
+        '';
+      });
+    };
+  in rec {
+    varDir = "/var/lib/ttrss";
+    # FIXME: initial sync
+    activationScript = {
+      deps = [ "wrappers" ];
+      text = ''
+        install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
+          ${varDir}/lock ${varDir}/cache ${varDir}/feed-icons
+        install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}/cache/export/ \
+          ${varDir}/cache/feeds/ \
+          ${varDir}/cache/images/ \
+          ${varDir}/cache/js/ \
+          ${varDir}/cache/simplepie/ \
+          ${varDir}/cache/upload/
+        touch ${varDir}/feed-icons/index.html
+        install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
+      '';
+    };
+    config =
+      # FIXME: LOG_DESTINATION syslog?
+      assert checkEnv "NIXOPS_TTRSS_DB_PASSWORD";
+      assert checkEnv "NIXOPS_TTRSS_LDAP_PASSWORD";
+      writeText "config.php" ''
+      <?php
+
+        define('PHP_EXECUTABLE', '${php}/bin/php');
+
+        define('LOCK_DIRECTORY', 'lock');
+        define('CACHE_DIR', 'cache');
+        define('ICONS_DIR', 'feed-icons');
+        define('ICONS_URL', 'feed-icons');
+        define('SELF_URL_PATH', 'https://tools.immae.eu/ttrss/');
+
+        define('MYSQL_CHARSET', 'UTF8');
+
+        define('DB_TYPE', 'pgsql');
+        define('DB_HOST', 'db-1.immae.eu');
+        define('DB_USER', 'ttrss');
+        define('DB_NAME', 'ttrss');
+        define('DB_PASS', '${builtins.getEnv "NIXOPS_TTRSS_DB_PASSWORD"}');
+        define('DB_PORT', '5432');
+
+        define('AUTH_AUTO_CREATE', true);
+        define('AUTH_AUTO_LOGIN', true);
+
+        define('SINGLE_USER_MODE', false);
+
+        define('SIMPLE_UPDATE_MODE', false);
+        define('CHECK_FOR_UPDATES', true);
+
+        define('FORCE_ARTICLE_PURGE', 0);
+        define('SESSION_COOKIE_LIFETIME', 60*60*24*120);
+        define('ENABLE_GZIP_OUTPUT', false);
+
+        define('PLUGINS', 'auth_ldap, note, instances');
+
+        define('LOG_DESTINATION', ''');
+        define('CONFIG_VERSION', 26);
+
+
+        define('SPHINX_SERVER', 'localhost:9312');
+        define('SPHINX_INDEX', 'ttrss, delta');
+
+        define('ENABLE_REGISTRATION', false);
+        define('REG_NOTIFY_ADDRESS', 'outils@immae.eu');
+        define('REG_MAX_USERS', 10);
+
+        define('SMTP_SERVER', 'mail.immae.eu:25');
+        define('SMTP_LOGIN', ''');
+        define('SMTP_PASSWORD', ''');
+        define('SMTP_SECURE', 'tls');
+
+        define('SMTP_FROM_NAME', 'Tiny Tiny RSS');
+        define('SMTP_FROM_ADDRESS', 'outils@immae.eu');
+        define('DIGEST_SUBJECT', '[tt-rss] New headlines for last 24 hours');
+
+        define('LDAP_AUTH_SERVER_URI', 'ldap://ldap.immae.eu:389/');
+        define('LDAP_AUTH_USETLS', TRUE);
+        define('LDAP_AUTH_ALLOW_UNTRUSTED_CERT', TRUE);
+        define('LDAP_AUTH_BASEDN', 'dc=immae,dc=eu');
+        define('LDAP_AUTH_ANONYMOUSBEFOREBIND', FALSE);
+        define('LDAP_AUTH_SEARCHFILTER', '(&(memberOf=cn=users,cn=ttrss,ou=services,dc=immae,dc=eu)(|(cn=???)(uid=???)(&(uid:dn:=???)(ou=ttrss))))');
+
+        define('LDAP_AUTH_BINDDN', 'cn=ttrss,ou=services,dc=immae,dc=eu');
+        define('LDAP_AUTH_BINDPW', '${builtins.getEnv "NIXOPS_TTRSS_LDAP_PASSWORD"}');
+        define('LDAP_AUTH_LOGIN_ATTRIB', 'immaeTtrssLogin');
+
+        define('LDAP_AUTH_LOG_ATTEMPTS', FALSE);
+        define('LDAP_AUTH_DEBUG', FALSE);
+      '';
+    webRoot = stdenv.mkDerivation (fetchedGit ./tt-rss.json // rec {
+      buildPhase = ''
+        rm -rf lock feed-icons cache
+        ln -sf ../../../../../${varDir}/{lock,feed-icons,cache} .
+      '';
+      installPhase = ''
+        cp -a . $out
+        ln -s ${config} $out/config.php
+        ${builtins.concatStringsSep "\n" (
+          lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/plugins/${name}") plugins
+        )}
+      '';
+    });
+    apache = {
+      user = "wwwrun";
+      group = "wwwrun";
+      modules = [ "proxy_fcgi" ];
+      vhostConf = ''
+        Alias /ttrss "${webRoot}"
+        <Directory "${webRoot}">
+          DirectoryIndex index.php
+          <FilesMatch "\.php$">
+            SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
+          </FilesMatch>
+
+          AllowOverride All
+          Options FollowSymlinks
+          Require all granted
+        </Directory>
+        '';
+    };
+    phpFpm = rec {
+      basedir = builtins.concatStringsSep ":" (
+        [ webRoot config varDir ]
+        ++ lib.attrsets.mapAttrsToList (name: value: value) plugins);
+      socket = "/var/run/phpfpm/ttrss.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] = TtrssPHPSESSID
+        php_admin_value[open_basedir] = "${basedir}:/tmp"
+        php_admin_value[session.save_path] = "${varDir}/phpSessions"
+        '';
+    };
+  };
+in 
+  ttrss