Merge pull request #307459 from Stunkymonkey/freshrss-extensions

freshrss-extensions: init
This commit is contained in:
Felix Bühler 2024-07-02 19:43:22 +02:00 committed by GitHub
commit 4b015946c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 256 additions and 16 deletions

View File

@ -5,6 +5,15 @@ let
cfg = config.services.freshrss;
poolName = "freshrss";
extension-env = pkgs.buildEnv {
name = "freshrss-extensions";
paths = cfg.extensions;
};
env-vars = {
DATA_PATH = cfg.dataDir;
THIRDPARTY_EXTENSIONS_PATH = "${extension-env}/share/freshrss/";
};
in
{
meta.maintainers = with maintainers; [ etu stunkymonkey mattchrist ];
@ -14,6 +23,31 @@ in
package = mkPackageOption pkgs "freshrss" { };
extensions = mkOption {
type = types.listOf types.package;
default = [ ];
defaultText = literalExpression "[]";
example = literalExpression ''
with freshrss-extensions; [
youtube
] ++ [
(freshrss-extensions.buildFreshRssExtension {
FreshRssExtUniqueId = "ReadingTime";
pname = "reading-time";
version = "1.5";
src = pkgs.fetchFromGitLab {
domain = "framagit.org";
owner = "Lapineige";
repo = "FreshRSS_Extension-ReadingTime";
rev = "fb6e9e944ef6c5299fa56ffddbe04c41e5a34ebf";
hash = "sha256-C5cRfaphx4Qz2xg2z+v5qRji8WVSIpvzMbethTdSqsk=";
};
})
]
'';
description = "Additional extensions to be used.";
};
defaultUser = mkOption {
type = types.str;
default = "admin";
@ -214,9 +248,7 @@ in
"pm.max_spare_servers" = 5;
"catch_workers_output" = true;
};
phpEnv = {
DATA_PATH = "${cfg.dataDir}";
};
phpEnv = env-vars;
};
};
@ -259,9 +291,7 @@ in
RemainAfterExit = true;
};
restartIfChanged = true;
environment = {
DATA_PATH = cfg.dataDir;
};
environment = env-vars;
script =
let
@ -293,9 +323,7 @@ in
description = "FreshRSS feed updater";
after = [ "freshrss-config.service" ];
startAt = "*:0/5";
environment = {
DATA_PATH = cfg.dataDir;
};
environment = env-vars;
serviceConfig = defaultServiceConfig // {
ExecStart = "${cfg.package}/app/actualize_script.php";
};

View File

@ -337,6 +337,7 @@ in {
freenet = handleTest ./freenet.nix {};
freeswitch = handleTest ./freeswitch.nix {};
freetube = discoverTests (import ./freetube.nix);
freshrss-extensions = handleTest ./freshrss-extensions.nix {};
freshrss-sqlite = handleTest ./freshrss-sqlite.nix {};
freshrss-pgsql = handleTest ./freshrss-pgsql.nix {};
freshrss-http-auth = handleTest ./freshrss-http-auth.nix {};

View File

@ -0,0 +1,19 @@
import ./make-test-python.nix ({ lib, pkgs, ... }: {
name = "freshrss";
nodes.machine = { pkgs, ... }: {
services.freshrss = {
enable = true;
baseUrl = "http://localhost";
authType = "none";
extensions = [ pkgs.freshrss-extensions.youtube ];
};
};
testScript = ''
machine.wait_for_unit("multi-user.target")
machine.wait_for_open_port(80)
response = machine.succeed("curl -vvv -s http://127.0.0.1:80/i/?c=extension")
assert '<span class="ext_name disabled">YouTube Video Feed</span>' in response, "Extension not present in extensions page."
'';
})

View File

@ -3,6 +3,7 @@
, fetchFromGitHub
, nixosTests
, php
, writeText
}:
stdenvNoCC.mkDerivation rec {
@ -16,26 +17,33 @@ stdenvNoCC.mkDerivation rec {
hash = "sha256-AAOON1RdbG6JSnCc123jmIlIXHOE1PE49BV4hcASO/s=";
};
passthru.tests = {
inherit (nixosTests) freshrss-sqlite freshrss-pgsql freshrss-http-auth freshrss-none-auth;
};
postPatch = ''
patchShebangs cli/*.php app/actualize_script.php
'';
# the thirdparty_extension_path can only be set by config, but should be read by an env-var.
overrideConfig = writeText "constants.local.php" ''
<?php
define('THIRDPARTY_EXTENSIONS_PATH', getenv('THIRDPARTY_EXTENSIONS_PATH') . '/extensions');
'';
buildInputs = [ php ];
# There's nothing to build.
dontBuild = true;
postPatch = ''
patchShebangs cli/*.php app/actualize_script.php
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -vr * $out/
cp $overrideConfig $out/constants.local.php
runHook postInstall
'';
passthru.tests = {
inherit (nixosTests) freshrss-sqlite freshrss-pgsql freshrss-http-auth freshrss-none-auth freshrss-extensions;
};
meta = with lib; {
description = "FreshRSS is a free, self-hostable RSS aggregator";
homepage = "https://www.freshrss.org/";

View File

@ -0,0 +1,138 @@
{ config
, lib
, fetchFromGitHub
, fetchFromGitLab
, callPackage
}:
let
buildFreshRssExtension = (callPackage ./freshrss-utils.nix { }).buildFreshRssExtension;
official_extensions_version = "unstable-2024-04-27";
official_extensions_src = fetchFromGitHub {
owner = "FreshRSS";
repo = "Extensions";
rev = "71de129744ba37fd4cf363b78445f5345bc6d0b7";
hash = "sha256-A+hOjbGNfhwTOAMeo08MUdqfWxxetzLz865oQQDsQlg=";
};
baseExtensions =
_self:
lib.mapAttrs (_n: lib.recurseIntoAttrs) {
auto-ttl = buildFreshRssExtension rec {
FreshRssExtUniqueId = "AutoTTL";
pname = "auto-ttl";
version = "0.5.0";
src = fetchFromGitHub {
owner = "mgnsk";
repo = "FreshRSS-AutoTTL";
rev = "v${version}";
hash = "sha256-OiTiLZ2BjQD1W/BD8EkUt7WB2wOjL6GMGJ+APT4YpwE=";
};
meta = {
description = "FreshRSS extension for automatic feed refresh TTL based on the average frequency of entries.";
homepage = "https://github.com/mgnsk/FreshRSS-AutoTTL";
license = lib.licenses.agpl3Only;
maintainers = [ lib.maintainers.stunkymonkey ];
};
};
demo = buildFreshRssExtension {
FreshRssExtUniqueId = "Demo";
pname = "demo";
version = "unstable-2023-12-22";
src = fetchFromGitHub {
owner = "FreshRSS";
repo = "xExtension-Demo";
rev = "8d60f71a2f0411f5fbbb1f88a57791cee0848f35";
hash = "sha256-5fe8TjefSiGMaeZkurxSJjX8qEEa1ArhJxDztp7ZNZc=";
};
meta = {
description = "FreshRSS Extension for the demo version.";
homepage = "https://github.com/FreshRSS/xExtension-Demo";
license = lib.licenses.agpl3Only;
maintainers = [ lib.maintainers.stunkymonkey ];
};
};
reading-time = buildFreshRssExtension rec {
FreshRssExtUniqueId = "ReadingTime";
pname = "reading-time";
version = "1.5";
src = fetchFromGitLab {
domain = "framagit.org";
owner = "Lapineige";
repo = "FreshRSS_Extension-ReadingTime";
rev = "fb6e9e944ef6c5299fa56ffddbe04c41e5a34ebf";
hash = "sha256-C5cRfaphx4Qz2xg2z+v5qRji8WVSIpvzMbethTdSqsk=";
};
meta = {
description = "FreshRSS extension adding a reading time estimation next to each article.";
homepage = "https://framagit.org/Lapineige/FreshRSS_Extension-ReadingTime";
license = lib.licenses.agpl3Only;
maintainers = [ lib.maintainers.stunkymonkey ];
};
};
reddit-image = buildFreshRssExtension rec {
FreshRssExtUniqueId = "RedditImage";
pname = "reddit-image";
version = "1.2.0";
src = fetchFromGitHub {
owner = "aledeg";
repo = "xExtension-RedditImage";
rev = "v${version}";
hash = "sha256-H/uxt441ygLL0RoUdtTn9Q6Q/Ois8RHlhF8eLpTza4Q=";
};
meta = {
description = "FreshRSS extension to process Reddit feeds.";
homepage = "https://github.com/aledeg/xExtension-RedditImage";
license = lib.licenses.agpl3Only;
maintainers = [ lib.maintainers.stunkymonkey ];
};
};
title-wrap = buildFreshRssExtension {
FreshRssExtUniqueId = "TitleWrap";
pname = "title-wrap";
version = official_extensions_version;
src = official_extensions_src;
sourceRoot = "source/xExtension-TitleWrap";
meta = {
description = "FreshRSS extension instead of truncating the title is wrapped.";
homepage = "https://github.com/FreshRSS/Extensions/tree/master/xExtension-TitleWrap";
license = lib.licenses.agpl3Only;
maintainers = [ lib.maintainers.stunkymonkey ];
};
};
youtube = buildFreshRssExtension {
FreshRssExtUniqueId = "YouTube";
pname = "youtube";
version = official_extensions_version;
src = official_extensions_src;
sourceRoot = "source/xExtension-YouTube";
meta = {
description = "FreshRSS extension allows you to directly watch YouTube/PeerTube videos from within subscribed channel feeds.";
homepage = "https://github.com/FreshRSS/Extensions/tree/master/xExtension-YouTube";
license = lib.licenses.agpl3Only;
maintainers = [ lib.maintainers.stunkymonkey ];
};
};
};
# add possibility to define aliases
aliases = super: {
# example: RedditImage = super.reddit-image;
};
# overlays will be applied left to right, overrides should come after aliases.
overlays = lib.optionals config.allowAliases [
(_self: super: lib.recursiveUpdate super (aliases super))
];
toFix = lib.foldl' (lib.flip lib.extends) baseExtensions overlays;
in
(lib.fix toFix) // {
inherit buildFreshRssExtension;
}

View File

@ -0,0 +1,45 @@
{ stdenv, unzip }:
let
buildFreshRssExtension =
args@{ pname
, version
, src
, FreshRssExtUniqueId
, configurePhase ? ''
runHook preConfigure
runHook postConfigure
''
, buildPhase ? ''
runHook preBuild
runHook postBuild
''
, dontPatchELF ? true
, dontStrip ? true
, passthru ? { }
, sourceRoot ? "source"
, ...
}:
stdenv.mkDerivation ((removeAttrs args [ "FreshRssExtUniqueId" ]) // {
pname = "freshrss-extension-${pname}";
inherit version src configurePhase buildPhase dontPatchELF dontStrip sourceRoot;
installPrefix = "share/freshrss/extensions/xExtension-${FreshRssExtUniqueId}";
installPhase = ''
runHook preInstall
mkdir -p "$out/$installPrefix"
find . -mindepth 1 -maxdepth 1 | xargs -d'\n' mv -t "$out/$installPrefix/"
runHook postInstall
'';
passthru = passthru // {
inherit FreshRssExtUniqueId;
};
});
in
{
inherit buildFreshRssExtension;
}

View File

@ -25488,6 +25488,7 @@ with pkgs;
freeradius = callPackage ../servers/freeradius { };
freshrss = callPackage ../servers/web-apps/freshrss { };
freshrss-extensions = recurseIntoAttrs (callPackage ../servers/web-apps/freshrss/extensions { });
freeswitch = callPackage ../servers/sip/freeswitch {
inherit (darwin.apple_sdk.frameworks) SystemConfiguration;