]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Move ttrss to pkgs
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 7 May 2019 13:02:33 +0000 (15:02 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 7 May 2019 13:02:33 +0000 (15:02 +0200)
17 files changed:
nixops/modules/websites/tools/tools/default.nix
nixops/modules/websites/tools/tools/ttrss.nix
pkgs/webapps/default.nix
pkgs/webapps/ttrss/default.nix [new file with mode: 0644]
pkgs/webapps/ttrss/plugins/af_feedmod/af_feedmod.json [moved from nixops/modules/websites/tools/tools/ttrss-af_feedmod.json with 100% similarity]
pkgs/webapps/ttrss/plugins/af_feedmod/default.nix [new file with mode: 0644]
pkgs/webapps/ttrss/plugins/af_feedmod/type_replace.patch [moved from nixops/modules/websites/tools/tools/ttrss-af-feedmod_type_replace.patch with 100% similarity]
pkgs/webapps/ttrss/plugins/auth_ldap/auth-ldap.json [moved from nixops/modules/websites/tools/tools/ttrss-auth-ldap.json with 100% similarity]
pkgs/webapps/ttrss/plugins/auth_ldap/default.nix [new file with mode: 0644]
pkgs/webapps/ttrss/plugins/feediron/default.nix [new file with mode: 0644]
pkgs/webapps/ttrss/plugins/feediron/feediron.json [moved from nixops/modules/websites/tools/tools/ttrss-feediron.json with 100% similarity]
pkgs/webapps/ttrss/plugins/feediron/json_reformat.patch [moved from nixops/modules/websites/tools/tools/ttrss-feediron_json_reformat.patch with 100% similarity]
pkgs/webapps/ttrss/plugins/ff_instagram/default.nix [new file with mode: 0644]
pkgs/webapps/ttrss/plugins/ff_instagram/ff_instagram.json [moved from nixops/modules/websites/tools/tools/ttrss-ff_instagram.json with 100% similarity]
pkgs/webapps/ttrss/plugins/tumblr_gdpr_ua/default.nix [new file with mode: 0644]
pkgs/webapps/ttrss/plugins/tumblr_gdpr_ua/tumblr_gdpr_ua.json [moved from nixops/modules/websites/tools/tools/ttrss-tumblr_gdpr_ua.json with 100% similarity]
pkgs/webapps/ttrss/tt-rss.json [moved from nixops/modules/websites/tools/tools/tt-rss.json with 100% similarity]

index 433927e1837a242523adc684b9a0403408b3ad27..22588fb92012a689ca9bb4ee76c6b53785815938 100644 (file)
@@ -5,7 +5,7 @@ let
       env = myconfig.env.tools.ympd;
     };
     ttrss = pkgs.callPackage ./ttrss.nix {
-      inherit (mylibs) fetchedGithub fetchedGit;
+      inherit (pkgs.webapps) ttrss ttrss-plugins;
       env = myconfig.env.tools.ttrss;
     };
     roundcubemail = pkgs.callPackage ./roundcubemail.nix {
index e6cad5693864a643de6df71bf7aca990a101accb..05c8cab04452831878754e25e9594892105b4c8b 100644 (file)
-{ lib, php, env, 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";
-    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
+{ php, env, ttrss, ttrss-plugins }:
+rec {
+  varDir = "/var/lib/ttrss";
+  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
+    '';
+  };
+  keys = [{
+    dest = "webapps/tools-ttrss";
+    user = apache.user;
+    group = apache.group;
+    permissions = "0400";
+    text = ''
+      <?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', '${env.postgresql.socket}');
+        define('DB_USER', '${env.postgresql.user}');
+        define('DB_NAME', '${env.postgresql.database}');
+        define('DB_PASS', '${env.postgresql.password}');
+        define('DB_PORT', '${env.postgresql.port}');
+
+        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', 'ttrss@tools.immae.eu');
+        define('REG_MAX_USERS', 10);
+
+        define('SMTP_FROM_NAME', 'Tiny Tiny RSS');
+        define('SMTP_FROM_ADDRESS', 'ttrss@tools.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', '${env.ldap.password}');
+        define('LDAP_AUTH_LOGIN_ATTRIB', 'immaeTtrssLogin');
+
+        define('LDAP_AUTH_LOG_ATTEMPTS', FALSE);
+        define('LDAP_AUTH_DEBUG', FALSE);
       '';
-    };
-    keys = [{
-      dest = "webapps/tools-ttrss";
-      user = apache.user;
-      group = apache.group;
-      permissions = "0400";
-      text = ''
-        <?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', '${env.postgresql.socket}');
-          define('DB_USER', '${env.postgresql.user}');
-          define('DB_NAME', '${env.postgresql.database}');
-          define('DB_PASS', '${env.postgresql.password}');
-          define('DB_PORT', '${env.postgresql.port}');
-
-          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', 'ttrss@tools.immae.eu');
-          define('REG_MAX_USERS', 10);
-
-          define('SMTP_FROM_NAME', 'Tiny Tiny RSS');
-          define('SMTP_FROM_ADDRESS', 'ttrss@tools.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', '${env.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} .
+  }];
+  webRoot = (ttrss.override { ttrss_config = "/var/secrets/webapps/tools-ttrss"; }).withPlugins (builtins.attrValues ttrss-plugins);
+  apache = rec {
+    user = "wwwrun";
+    group = "wwwrun";
+    modules = [ "proxy_fcgi" ];
+    webappName = "tools_ttrss";
+    root = "/run/current-system/webapps/${webappName}";
+    vhostConf = ''
+      Alias /ttrss "${root}"
+      <Directory "${root}">
+        DirectoryIndex index.php
+        <FilesMatch "\.php$">
+          SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
+        </FilesMatch>
+
+        AllowOverride All
+        Options FollowSymlinks
+        Require all granted
+      </Directory>
       '';
-      installPhase = ''
-        cp -a . $out
-        ln -s /var/secrets/webapps/tools-ttrss $out/config.php
-        ${builtins.concatStringsSep "\n" (
-          lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/plugins/${name}") plugins
-        )}
+  };
+  phpFpm = rec {
+    serviceDeps = [ "postgresql.service" "openldap.service" ];
+    basedir = builtins.concatStringsSep ":" (
+      [ webRoot "/var/secrets/webapps/tools-ttrss" varDir ]
+      ++ webRoot.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"
       '';
-    });
-    apache = rec {
-      user = "wwwrun";
-      group = "wwwrun";
-      modules = [ "proxy_fcgi" ];
-      webappName = "tools_ttrss";
-      root = "/run/current-system/webapps/${webappName}";
-      vhostConf = ''
-        Alias /ttrss "${root}"
-        <Directory "${root}">
-          DirectoryIndex index.php
-          <FilesMatch "\.php$">
-            SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
-          </FilesMatch>
-
-          AllowOverride All
-          Options FollowSymlinks
-          Require all granted
-        </Directory>
-        '';
-    };
-    phpFpm = rec {
-      serviceDeps = [ "postgresql.service" "openldap.service" ];
-      basedir = builtins.concatStringsSep ":" (
-        [ webRoot "/var/secrets/webapps/tools-ttrss" 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
+}
index 073905cc4f910f7033f2a0224f5554bc7c8cb0d9..a4e4f875f696d565c98e142e411da1e0004a5836 100644 (file)
@@ -67,6 +67,19 @@ rec {
     lib.attrsets.genAttrs names
       (name: callPackage (./roundcubemail/plugins + "/${name}") { buildPlugin = roundcubemail.buildPlugin; });
 
+  ttrss = callPackage ./ttrss { inherit mylibs; };
+  ttrss-with-plugins = ttrss.withPlugins (builtins.attrValues ttrss-plugins);
+  ttrss-plugins = let
+    names = [ "auth_ldap" "af_feedmod" "feediron" "ff_instagram" "tumblr_gdpr_ua" ];
+    patched = [ "af_feedmod" "feediron" ];
+  in
+    lib.attrsets.genAttrs names
+      (name: callPackage (./ttrss/plugins + "/${name}") (
+        { inherit mylibs; } //
+        (if builtins.elem name patched then { patched = true; } else {})
+        )
+      );
+
   yourls = callPackage ./yourls { inherit mylibs; };
   yourls-with-plugins = yourls.withPlugins (builtins.attrValues yourls-plugins);
   yourls-plugins = let
diff --git a/pkgs/webapps/ttrss/default.nix b/pkgs/webapps/ttrss/default.nix
new file mode 100644 (file)
index 0000000..0ce2f94
--- /dev/null
@@ -0,0 +1,30 @@
+{ ttrss_config ? "/etc/ttrss/config.php"
+, varDir ? "/var/lib/ttrss"
+, stdenv, mylibs }:
+let
+  withPlugins = plugins: package.overrideAttrs(old: rec {
+    name = "${old.name}-with-plugins";
+    installPhase = old.installPhase +
+      builtins.concatStringsSep "\n" (
+        map (value: "ln -s ${value} $out/plugins/${value.pluginName}") plugins
+      );
+    passthru = old.passthru // {
+      inherit plugins;
+      withPlugins = morePlugins: old.withPlugins (morePlugins ++ plugins);
+    };
+  });
+  package = stdenv.mkDerivation (mylibs.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 ${ttrss_config} $out/config.php
+      '';
+    passthru = {
+      plugins = [];
+      inherit withPlugins;
+    };
+  });
+in package
diff --git a/pkgs/webapps/ttrss/plugins/af_feedmod/default.nix b/pkgs/webapps/ttrss/plugins/af_feedmod/default.nix
new file mode 100644 (file)
index 0000000..8512be3
--- /dev/null
@@ -0,0 +1,9 @@
+{ patched ? false, stdenv, mylibs, lib }:
+stdenv.mkDerivation (mylibs.fetchedGithub ./af_feedmod.json // {
+  patches = lib.optionals patched [ ./type_replace.patch ];
+  installPhase = ''
+    mkdir $out
+    cp init.php $out
+    '';
+  passthru.pluginName = "af_feedmod";
+})
diff --git a/pkgs/webapps/ttrss/plugins/auth_ldap/default.nix b/pkgs/webapps/ttrss/plugins/auth_ldap/default.nix
new file mode 100644 (file)
index 0000000..424a9f7
--- /dev/null
@@ -0,0 +1,8 @@
+{ stdenv, mylibs }:
+stdenv.mkDerivation (mylibs.fetchedGithub ./auth-ldap.json // {
+  installPhase = ''
+    mkdir $out
+    cp plugins/auth_ldap/init.php $out
+    '';
+  passthru.pluginName = "auth_ldap";
+})
diff --git a/pkgs/webapps/ttrss/plugins/feediron/default.nix b/pkgs/webapps/ttrss/plugins/feediron/default.nix
new file mode 100644 (file)
index 0000000..80bfda4
--- /dev/null
@@ -0,0 +1,9 @@
+{ patched ? false, stdenv, mylibs, lib }:
+stdenv.mkDerivation (mylibs.fetchedGithub ./feediron.json // {
+  patches = lib.optionals patched [ ./json_reformat.patch ];
+  installPhase = ''
+    mkdir $out
+    cp -a . $out
+    '';
+  passthru.pluginName = "feediron";
+})
diff --git a/pkgs/webapps/ttrss/plugins/ff_instagram/default.nix b/pkgs/webapps/ttrss/plugins/ff_instagram/default.nix
new file mode 100644 (file)
index 0000000..3540f73
--- /dev/null
@@ -0,0 +1,8 @@
+{ stdenv, mylibs }:
+stdenv.mkDerivation (mylibs.fetchedGithub ./ff_instagram.json // {
+  installPhase = ''
+    mkdir $out
+    cp -a . $out
+    '';
+  passthru.pluginName = "ff_instagram";
+})
diff --git a/pkgs/webapps/ttrss/plugins/tumblr_gdpr_ua/default.nix b/pkgs/webapps/ttrss/plugins/tumblr_gdpr_ua/default.nix
new file mode 100644 (file)
index 0000000..2cf3e05
--- /dev/null
@@ -0,0 +1,8 @@
+{ stdenv, mylibs }:
+stdenv.mkDerivation (mylibs.fetchedGithub ./tumblr_gdpr_ua.json // {
+  installPhase = ''
+    mkdir $out
+    cp -a . $out
+    '';
+  passthru.pluginName = "tumblr_gdpr_ua";
+})