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:
parent
798f303659
commit
88234d3a4f
8 changed files with 71 additions and 14 deletions
|
@ -3,6 +3,7 @@
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.services.freshrss;
|
cfg = config.services.freshrss;
|
||||||
|
webserver = config.services.${cfg.webserver};
|
||||||
|
|
||||||
extension-env = pkgs.buildEnv {
|
extension-env = pkgs.buildEnv {
|
||||||
name = "freshrss-extensions";
|
name = "freshrss-extensions";
|
||||||
|
@ -129,13 +130,25 @@ in
|
||||||
example = "/mnt/freshrss";
|
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 {
|
virtualHost = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.str;
|
||||||
default = "freshrss";
|
default = "freshrss";
|
||||||
description = ''
|
description = ''
|
||||||
Name of the nginx virtualhost to use and setup. If null, do not setup any virtualhost.
|
Name of the caddy/nginx virtualhost to use and setup.
|
||||||
You may need to configure the virtualhost further through services.nginx.virtualHosts.<virtualhost>,
|
|
||||||
for example to enable SSL.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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.
|
# Set up a Nginx virtual host.
|
||||||
services.nginx = mkIf (cfg.virtualHost != null) {
|
services.nginx = mkIf (cfg.webserver == "nginx") {
|
||||||
enable = true;
|
enable = true;
|
||||||
virtualHosts.${cfg.virtualHost} = {
|
virtualHosts.${cfg.virtualHost} = {
|
||||||
root = "${cfg.package}/p";
|
root = "${cfg.package}/p";
|
||||||
|
@ -237,8 +263,8 @@ in
|
||||||
${cfg.pool} = {
|
${cfg.pool} = {
|
||||||
user = "freshrss";
|
user = "freshrss";
|
||||||
settings = {
|
settings = {
|
||||||
"listen.owner" = "nginx";
|
"listen.owner" = webserver.user;
|
||||||
"listen.group" = "nginx";
|
"listen.group" = webserver.group;
|
||||||
"listen.mode" = "0600";
|
"listen.mode" = "0600";
|
||||||
"pm" = "dynamic";
|
"pm" = "dynamic";
|
||||||
"pm.max_children" = 32;
|
"pm.max_children" = 32;
|
||||||
|
|
30
nixos/tests/freshrss/caddy-sqlite.nix
Normal file
30
nixos/tests/freshrss/caddy-sqlite.nix
Normal 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"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
)
|
|
@ -5,5 +5,6 @@
|
||||||
http-auth = import ./http-auth.nix { inherit system pkgs; };
|
http-auth = import ./http-auth.nix { inherit system pkgs; };
|
||||||
none-auth = import ./none-auth.nix { inherit system pkgs; };
|
none-auth = import ./none-auth.nix { inherit system pkgs; };
|
||||||
pgsql = import ./pgsql.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; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import ../make-test-python.nix (
|
||||||
testScript = ''
|
testScript = ''
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
machine.wait_for_open_port(80)
|
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."
|
assert '<span class="ext_name disabled">YouTube Video Feed</span>' in response, "Extension not present in extensions page."
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import ../make-test-python.nix (
|
||||||
testScript = ''
|
testScript = ''
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
machine.wait_for_open_port(80)
|
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."
|
assert 'Account: testuser' in response, "http_auth method didn't work."
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import ../make-test-python.nix (
|
import ../make-test-python.nix (
|
||||||
{ lib, pkgs, ... }:
|
{ lib, pkgs, ... }:
|
||||||
{
|
{
|
||||||
name = "freshrss-sqlite";
|
name = "freshrss-nginx-sqlite";
|
||||||
meta.maintainers = with lib.maintainers; [
|
meta.maintainers = with lib.maintainers; [
|
||||||
etu
|
etu
|
||||||
stunkymonkey
|
stunkymonkey
|
||||||
|
@ -21,7 +21,7 @@ import ../make-test-python.nix (
|
||||||
testScript = ''
|
testScript = ''
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
machine.wait_for_open_port(80)
|
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"
|
assert '<title>Login · FreshRSS</title>' in response, "Login page didn't load successfully"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@ import ../make-test-python.nix (
|
||||||
testScript = ''
|
testScript = ''
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
machine.wait_for_open_port(80)
|
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"
|
assert '<title>Main stream · FreshRSS</title>' in response, "FreshRSS stream page didn't load successfully"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ import ../make-test-python.nix (
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
machine.wait_for_open_port(5432)
|
machine.wait_for_open_port(5432)
|
||||||
machine.wait_for_open_port(80)
|
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"
|
assert '<title>Login · FreshRSS</title>' in response, "Login page didn't load successfully"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue