From 86663f1789aecdb62e44a4be46e0ed111b795a09 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Tue, 7 May 2019 15:02:33 +0200 Subject: [PATCH] Move ttrss to pkgs --- .../modules/websites/tools/tools/default.nix | 2 +- nixops/modules/websites/tools/tools/ttrss.nix | 304 ++++++++---------- pkgs/webapps/default.nix | 13 + pkgs/webapps/ttrss/default.nix | 30 ++ .../ttrss/plugins/af_feedmod/af_feedmod.json | 0 .../ttrss/plugins/af_feedmod/default.nix | 9 + .../plugins/af_feedmod/type_replace.patch | 0 .../ttrss/plugins/auth_ldap/auth-ldap.json | 0 .../ttrss/plugins/auth_ldap/default.nix | 8 + .../ttrss/plugins/feediron/default.nix | 9 + .../ttrss/plugins/feediron/feediron.json | 0 .../plugins/feediron/json_reformat.patch | 0 .../ttrss/plugins/ff_instagram/default.nix | 8 + .../plugins/ff_instagram/ff_instagram.json | 0 .../ttrss/plugins/tumblr_gdpr_ua/default.nix | 8 + .../tumblr_gdpr_ua/tumblr_gdpr_ua.json | 0 .../tools => pkgs/webapps/ttrss}/tt-rss.json | 0 17 files changed, 213 insertions(+), 178 deletions(-) create mode 100644 pkgs/webapps/ttrss/default.nix rename nixops/modules/websites/tools/tools/ttrss-af_feedmod.json => pkgs/webapps/ttrss/plugins/af_feedmod/af_feedmod.json (100%) create mode 100644 pkgs/webapps/ttrss/plugins/af_feedmod/default.nix rename nixops/modules/websites/tools/tools/ttrss-af-feedmod_type_replace.patch => pkgs/webapps/ttrss/plugins/af_feedmod/type_replace.patch (100%) rename nixops/modules/websites/tools/tools/ttrss-auth-ldap.json => pkgs/webapps/ttrss/plugins/auth_ldap/auth-ldap.json (100%) create mode 100644 pkgs/webapps/ttrss/plugins/auth_ldap/default.nix create mode 100644 pkgs/webapps/ttrss/plugins/feediron/default.nix rename nixops/modules/websites/tools/tools/ttrss-feediron.json => pkgs/webapps/ttrss/plugins/feediron/feediron.json (100%) rename nixops/modules/websites/tools/tools/ttrss-feediron_json_reformat.patch => pkgs/webapps/ttrss/plugins/feediron/json_reformat.patch (100%) create mode 100644 pkgs/webapps/ttrss/plugins/ff_instagram/default.nix rename nixops/modules/websites/tools/tools/ttrss-ff_instagram.json => pkgs/webapps/ttrss/plugins/ff_instagram/ff_instagram.json (100%) create mode 100644 pkgs/webapps/ttrss/plugins/tumblr_gdpr_ua/default.nix rename nixops/modules/websites/tools/tools/ttrss-tumblr_gdpr_ua.json => pkgs/webapps/ttrss/plugins/tumblr_gdpr_ua/tumblr_gdpr_ua.json (100%) rename {nixops/modules/websites/tools/tools => pkgs/webapps/ttrss}/tt-rss.json (100%) diff --git a/nixops/modules/websites/tools/tools/default.nix b/nixops/modules/websites/tools/tools/default.nix index 433927e..22588fb 100644 --- a/nixops/modules/websites/tools/tools/default.nix +++ b/nixops/modules/websites/tools/tools/default.nix @@ -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 { diff --git a/nixops/modules/websites/tools/tools/ttrss.nix b/nixops/modules/websites/tools/tools/ttrss.nix index e6cad56..05c8cab 100644 --- a/nixops/modules/websites/tools/tools/ttrss.nix +++ b/nixops/modules/websites/tools/tools/ttrss.nix @@ -1,181 +1,131 @@ -{ 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 = '' + + DirectoryIndex index.php + + SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" + + + AllowOverride All + Options FollowSymlinks + Require all granted + ''; - 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}" - - DirectoryIndex index.php - - SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" - - - AllowOverride All - Options FollowSymlinks - Require all granted - - ''; - }; - 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 +} diff --git a/pkgs/webapps/default.nix b/pkgs/webapps/default.nix index 073905c..a4e4f87 100644 --- a/pkgs/webapps/default.nix +++ b/pkgs/webapps/default.nix @@ -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 index 0000000..0ce2f94 --- /dev/null +++ b/pkgs/webapps/ttrss/default.nix @@ -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/nixops/modules/websites/tools/tools/ttrss-af_feedmod.json b/pkgs/webapps/ttrss/plugins/af_feedmod/af_feedmod.json similarity index 100% rename from nixops/modules/websites/tools/tools/ttrss-af_feedmod.json rename to pkgs/webapps/ttrss/plugins/af_feedmod/af_feedmod.json diff --git a/pkgs/webapps/ttrss/plugins/af_feedmod/default.nix b/pkgs/webapps/ttrss/plugins/af_feedmod/default.nix new file mode 100644 index 0000000..8512be3 --- /dev/null +++ b/pkgs/webapps/ttrss/plugins/af_feedmod/default.nix @@ -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/nixops/modules/websites/tools/tools/ttrss-af-feedmod_type_replace.patch b/pkgs/webapps/ttrss/plugins/af_feedmod/type_replace.patch similarity index 100% rename from nixops/modules/websites/tools/tools/ttrss-af-feedmod_type_replace.patch rename to pkgs/webapps/ttrss/plugins/af_feedmod/type_replace.patch diff --git a/nixops/modules/websites/tools/tools/ttrss-auth-ldap.json b/pkgs/webapps/ttrss/plugins/auth_ldap/auth-ldap.json similarity index 100% rename from nixops/modules/websites/tools/tools/ttrss-auth-ldap.json rename to pkgs/webapps/ttrss/plugins/auth_ldap/auth-ldap.json diff --git a/pkgs/webapps/ttrss/plugins/auth_ldap/default.nix b/pkgs/webapps/ttrss/plugins/auth_ldap/default.nix new file mode 100644 index 0000000..424a9f7 --- /dev/null +++ b/pkgs/webapps/ttrss/plugins/auth_ldap/default.nix @@ -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 index 0000000..80bfda4 --- /dev/null +++ b/pkgs/webapps/ttrss/plugins/feediron/default.nix @@ -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/nixops/modules/websites/tools/tools/ttrss-feediron.json b/pkgs/webapps/ttrss/plugins/feediron/feediron.json similarity index 100% rename from nixops/modules/websites/tools/tools/ttrss-feediron.json rename to pkgs/webapps/ttrss/plugins/feediron/feediron.json diff --git a/nixops/modules/websites/tools/tools/ttrss-feediron_json_reformat.patch b/pkgs/webapps/ttrss/plugins/feediron/json_reformat.patch similarity index 100% rename from nixops/modules/websites/tools/tools/ttrss-feediron_json_reformat.patch rename to pkgs/webapps/ttrss/plugins/feediron/json_reformat.patch diff --git a/pkgs/webapps/ttrss/plugins/ff_instagram/default.nix b/pkgs/webapps/ttrss/plugins/ff_instagram/default.nix new file mode 100644 index 0000000..3540f73 --- /dev/null +++ b/pkgs/webapps/ttrss/plugins/ff_instagram/default.nix @@ -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/nixops/modules/websites/tools/tools/ttrss-ff_instagram.json b/pkgs/webapps/ttrss/plugins/ff_instagram/ff_instagram.json similarity index 100% rename from nixops/modules/websites/tools/tools/ttrss-ff_instagram.json rename to pkgs/webapps/ttrss/plugins/ff_instagram/ff_instagram.json 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 index 0000000..2cf3e05 --- /dev/null +++ b/pkgs/webapps/ttrss/plugins/tumblr_gdpr_ua/default.nix @@ -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"; +}) diff --git a/nixops/modules/websites/tools/tools/ttrss-tumblr_gdpr_ua.json b/pkgs/webapps/ttrss/plugins/tumblr_gdpr_ua/tumblr_gdpr_ua.json similarity index 100% rename from nixops/modules/websites/tools/tools/ttrss-tumblr_gdpr_ua.json rename to pkgs/webapps/ttrss/plugins/tumblr_gdpr_ua/tumblr_gdpr_ua.json diff --git a/nixops/modules/websites/tools/tools/tt-rss.json b/pkgs/webapps/ttrss/tt-rss.json similarity index 100% rename from nixops/modules/websites/tools/tools/tt-rss.json rename to pkgs/webapps/ttrss/tt-rss.json -- 2.41.0