New to Nix, Help me fix config

I am trying to run both fresh-rss and rss-bridge in path localhost/rss and localhost/bridge.
individually both work but i was trying to host them with same server on my laptop(not a seperate setup). the config for that i was trying to work on is below(will not work directly).
Any recommendation are welcome.

{lib, config, pkgs, ...}:

let
  freshrss_package = pkgs.freshrss;
  freshrss = ./freshrss.nix;
  bridge_package = pkgs.rss-bridge;
  freshrss_pool = "freshrss";
  freshrss_url_path = "rss";
  bridge_config={
          system.enabled_bridges = [ "*" ];
          FileCache = {
            enable_purge = true;
          };
    };
  cfgHalf = lib.mapAttrsRecursive (path: value: let
  envName = lib.toUpper ("RSSBRIDGE_" + lib.concatStringsSep "_" path);
  envValue = if lib.isList value then
      lib.concatStringsSep "," value
    else if lib.isBool value then
      lib.boolToString value
    else
      toString value;
  in if (value != null) then "fastcgi_param \"${envName}\" \"${envValue}\";" else null) bridge_config;
  cfgEnv = lib.concatStringsSep "\n" (lib.collect lib.isString cfgHalf);
in
{
  #imports = [ ./freshrss.nix ];
  #disabledModules = [ "services/web-apps/freshrss.nix" ];
#set my own virtualHost
#copy from nixpkgs and merge
      services.nginx = {
        enable = true;
        virtualHosts.localhost = {
          # php files handling
          # this regex is mandatory because of the API
          /*
          locations."~ ^/${freshrss_url_path}/.+?\.php(/.*)?$"={
            root = "${freshrss_package}/p";
            extraConfig = ''
              fastcgi_pass unix:${config.services.phpfpm.pools.${freshrss_pool}.socket};
              fastcgi_split_path_info ^/${freshrss_url_path}(/.+\.php)(/.*)?$;
              set $path_info $fastcgi_path_info;
              fastcgi_param PATH_INFO $path_info;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              include ${pkgs.nginx}/conf/fastcgi_params;
              include ${pkgs.nginx}/conf/fastcgi.conf;
            '';
          };

          locations."~ ^/${freshrss_url_path}(?!.*\.php)(/.*)?$" = {
            root = "${freshrss_package}/p";
            tryFiles = "$1 /${freshrss_url_path}$1/index.php$is_args$args";
            index = "index.php index.html index.htm";
          };*/

          locations."/" = {
            root = "${bridge_package}";
            tryFiles = "$uri /index.php$is_args$args";
          };

          locations."~ ^/index.php(/|$)" = {
            root = "${bridge_package}";
            extraConfig = ''
              include ${pkgs.nginx}/conf/fastcgi_params;
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              fastcgi_pass unix:${config.services.phpfpm.pools.${freshrss_pool}.socket};
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              ${cfgEnv}
            '';
          };

          #locations."= /" = {
          #  return = "301 /rss/";
          #};
        };
      };

#add services
    services.freshrss = {
      enable = true;
      baseUrl = "http://localhost/${freshrss_url_path}";#change this to tell the base url is new
      passwordFile = pkgs.writeText "password" "secret";
      virtualHost = null;#dont setup, use previous
      pool = freshrss_pool;
      dataDir = "/srv/freshrss";
      extensions = [ pkgs.freshrss-extensions.youtube ] ++ [
        (pkgs.freshrss-extensions.buildFreshRssExtension rec {
          FreshRssExtUniqueId = "ClickableLinks";
          pname = "clickable-links";
          version = "1.01";
          src = pkgs.fetchFromGitHub {
            owner = "kapdap";
            repo = "freshrss-extensions";
            rev = "a44a25a6b8c7f298ac05b8db323bdea931e6e530";
            hash = "sha256-uWZi0sHdfDENJqjqTz5yoDZp3ViZahYI2OUgajdx4MQ=";
          };
          sourceRoot = "${src.name}/xExtension-ClickableLinks";
          meta = {
            description = "Replaces non-clickable plain text URLs found in articles with clickable HTML links.";
            homepage = "https://github.com/kapdap/freshrss-extensions/tree/master/xExtension-ClickableLinks";

          };
        })
      ];
    };

    services.rss-bridge = {
        enable = true;
        virtualHost = null;
        pool = freshrss_pool;
        user = "freshrss";
        config = bridge_config;
    };
}

Hello and welcome to the Nix community!

I’d love to assist you, but it seems you haven’t provided enough details about the issue you’re experiencing.

To get the best possible help, please include more information, such as error logs, the exact commands you ran, and any relevant configuration details.

If you’re unsure how to ask technical questions effectively, this guide might be helpful: How To Ask Questions The Smart Way (don’t mind the title of the page, there are very good information there!)

2 Likes

Ok, that was the config i was trying to write, which is very bad bcz i gave up after trying many things that i could learn but nix has very less resources that i can learn with so had to give up searching on github (only things that i found when searching/learning).

the main problem i had(currently) is

  • the rss-bridge will have write problem

Type: Exception
Code: 0
Message: The FileCache path is not writable: lib/../cache/
File: lib/CacheFactory.php
Line: 59
Trace
#0 index.php(71): RssBridge->__construct()
#1 lib/RssBridge.php(22): CacheFactory->create()
#2 lib/CacheFactory.php(59)

Context
Query:
Version: 2024-02-02
OS: Linux
PHP: 8.2.24 

but if i just run services.rss-bridge.enable = true; it will work fine.(i mean alone)
same is for freshrss.

the thing i want to do is to run both of these servies in subpath ie. localhost/rss and localhost/bridge not diffrent virtualhosts. so i am trying to merge these configs but it is not working as i expected.

i thought the problem was due to permission, as they both use diffrent user ids . so tried to change those to one. (security is not the problem for me as i am trying to run it localhost) .

i can provide any more information if requested.

  #imports = [ ./freshrss.nix ];
  #disabledModules = [ "services/web-apps/freshrss.nix" ];

this was my attempt to replace to replace those modules so i can use my own patched one there just like i expected. but the same code from github gives this error

error:
       … while calling the 'seq' builtin
         at /nix/store/dyzl40h25l04565n90psbhzgnc5vp2xr-source/lib/modules.nix:334:18:
          333|         options = checked options;
          334|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          335|         _module = checked (config._module);

       … while evaluating a branch condition
         at /nix/store/dyzl40h25l04565n90psbhzgnc5vp2xr-source/lib/modules.nix:273:9:
          272|       checkUnmatched =
          273|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |         ^
          274|           let

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: path '/nix/store/mp7xc6iq7c2hh6jrx55w6kmlbg3zr4gr-source/system/freshrss.nix' does not exist
          src = pkgs.fetchFromGitHub {
            owner = "kapdap";
            repo = "freshrss-extensions";
            rev = "a44a25a6b8c7f298ac05b8db323bdea931e6e530";
            hash = "sha256-uWZi0sHdfDENJqjqTz5yoDZp3ViZahYI2OUgajdx4MQ=";
          };

and is there a ez way i can keep updating these packages from github. the other extensions provided there(nixpkgs) look old too.(based on version)

i solved it by reading other packages from nixpkgs.