0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

nixos/freshrss: add caddy support

This commit is contained in:
Felix Buehler 2025-01-26 20:00:50 +01:00
parent 798f303659
commit 88234d3a4f
8 changed files with 71 additions and 14 deletions

View file

@ -3,6 +3,7 @@
with lib;
let
cfg = config.services.freshrss;
webserver = config.services.${cfg.webserver};
extension-env = pkgs.buildEnv {
name = "freshrss-extensions";
@ -129,13 +130,25 @@ in
example = "/mnt/freshrss";
};
webserver = mkOption {
type = types.enum [ "nginx" "caddy" "none"];
default = "nginx";
description = ''
Whether to use nginx or caddy for virtual host management.
Further nginx configuration can be done by adapting `services.nginx.virtualHosts.<name>`.
See [](#opt-services.nginx.virtualHosts) for further information.
Further caddy configuration can be done by adapting `services.caddy.virtualHosts.<name>`.
See [](#opt-services.caddy.virtualHosts) for further information.
'';
};
virtualHost = mkOption {
type = types.nullOr types.str;
type = types.str;
default = "freshrss";
description = ''
Name of the nginx virtualhost to use and setup. If null, do not setup any virtualhost.
You may need to configure the virtualhost further through services.nginx.virtualHosts.<virtualhost>,
for example to enable SSL.
Name of the caddy/nginx virtualhost to use and setup.
'';
};
@ -204,8 +217,21 @@ in
'';
}
];
# Set up a Caddy virtual host.
services.caddy = mkIf (cfg.webserver == "caddy") {
enable = true;
virtualHosts.${cfg.virtualHost}.extraConfig = ''
root * ${config.services.freshrss.package}/p
php_fastcgi unix/${config.services.phpfpm.pools.freshrss.socket} {
env FRESHRSS_DATA_PATH ${config.services.freshrss.dataDir}
}
file_server
'';
};
# Set up a Nginx virtual host.
services.nginx = mkIf (cfg.virtualHost != null) {
services.nginx = mkIf (cfg.webserver == "nginx") {
enable = true;
virtualHosts.${cfg.virtualHost} = {
root = "${cfg.package}/p";
@ -237,8 +263,8 @@ in
${cfg.pool} = {
user = "freshrss";
settings = {
"listen.owner" = "nginx";
"listen.group" = "nginx";
"listen.owner" = webserver.user;
"listen.group" = webserver.group;
"listen.mode" = "0600";
"pm" = "dynamic";
"pm.max_children" = 32;

View file

@ -0,0 +1,30 @@
import ../make-test-python.nix (
{ lib, pkgs, ... }:
{
name = "freshrss-caddy-sqlite";
meta.maintainers = with lib.maintainers; [
etu
stunkymonkey
];
nodes.machine =
{ pkgs, ... }:
{
services.freshrss = {
enable = true;
baseUrl = "http://localhost";
passwordFile = pkgs.writeText "password" "secret";
dataDir = "/srv/freshrss";
webserver = "caddy";
virtualHost = "freshrss:80";
};
};
testScript = ''
machine.wait_for_unit("multi-user.target")
machine.wait_for_open_port(80)
response = machine.succeed("curl -vvv -s -H 'Host: freshrss' http://localhost:80/i/")
assert '<title>Login · FreshRSS</title>' in response, "Login page didn't load successfully"
'';
}
)

View file

@ -5,5 +5,6 @@
http-auth = import ./http-auth.nix { inherit system pkgs; };
none-auth = import ./none-auth.nix { inherit system pkgs; };
pgsql = import ./pgsql.nix { inherit system pkgs; };
sqlite = import ./sqlite.nix { inherit system pkgs; };
nginx-sqlite = import ./nginx-sqlite.nix { inherit system pkgs; };
caddy-sqlite = import ./caddy-sqlite.nix { inherit system pkgs; };
}

View file

@ -17,7 +17,7 @@ import ../make-test-python.nix (
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")
response = machine.succeed("curl -vvv -s http://localhost:80/i/?c=extension")
assert '<span class="ext_name disabled">YouTube Video Feed</span>' in response, "Extension not present in extensions page."
'';
}

View file

@ -18,7 +18,7 @@ import ../make-test-python.nix (
testScript = ''
machine.wait_for_unit("multi-user.target")
machine.wait_for_open_port(80)
response = machine.succeed("curl -vvv -s -H 'Host: freshrss' -H 'Remote-User: testuser' http://127.0.0.1:80/i/")
response = machine.succeed("curl -vvv -s -H 'Host: freshrss' -H 'Remote-User: testuser' http://localhost:80/i/")
assert 'Account: testuser' in response, "http_auth method didn't work."
'';
}

View file

@ -1,7 +1,7 @@
import ../make-test-python.nix (
{ lib, pkgs, ... }:
{
name = "freshrss-sqlite";
name = "freshrss-nginx-sqlite";
meta.maintainers = with lib.maintainers; [
etu
stunkymonkey
@ -21,7 +21,7 @@ import ../make-test-python.nix (
testScript = ''
machine.wait_for_unit("multi-user.target")
machine.wait_for_open_port(80)
response = machine.succeed("curl -vvv -s -H 'Host: freshrss' http://127.0.0.1:80/i/")
response = machine.succeed("curl -vvv -s -H 'Host: freshrss' http://localhost:80/i/")
assert '<title>Login · FreshRSS</title>' in response, "Login page didn't load successfully"
'';
}

View file

@ -17,7 +17,7 @@ import ../make-test-python.nix (
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/")
response = machine.succeed("curl -vvv -s http://localhost:80/i/")
assert '<title>Main stream · FreshRSS</title>' in response, "FreshRSS stream page didn't load successfully"
'';
}

View file

@ -47,7 +47,7 @@ import ../make-test-python.nix (
machine.wait_for_unit("multi-user.target")
machine.wait_for_open_port(5432)
machine.wait_for_open_port(80)
response = machine.succeed("curl -vvv -s -H 'Host: freshrss' http://127.0.0.1:80/i/")
response = machine.succeed("curl -vvv -s -H 'Host: freshrss' http://localhost:80/i/")
assert '<title>Login · FreshRSS</title>' in response, "Login page didn't load successfully"
'';
}