nixos/rss-bridge: add webserver option

Co-authored-by: Zitrone <general@dev.quantenzitrone.eu>
This commit is contained in:
Felix Buehler 2025-02-10 23:30:07 +01:00
parent b8735ce254
commit 3cade1b5ac
2 changed files with 35 additions and 8 deletions

View File

@ -463,7 +463,7 @@
- `networking.wireguard` now has an optional networkd backend. It is enabled by default when `networking.useNetworkd` is enabled, and it can be enabled alongside scripted networking with `networking.wireguard.useNetworkd`. Some `networking.wireguard` options have slightly different behavior with the networkd and script-based backends, documented in each option.
- `services.rss-bridge` now has a `package` option.
- `services.rss-bridge` now has a `package` option as well as support for `caddy` as reverse proxy.
- `services.avahi.ipv6` now defaults to true.

View File

@ -18,7 +18,6 @@ let
cfg = config.services.rss-bridge;
cfgEnv = lib.pipe cfg.config [
(lib.mapAttrsRecursive (
path: value:
@ -61,17 +60,19 @@ in
user = mkOption {
type = types.str;
default = "nginx";
default = if cfg.webserver == null then "rss-bridge" else cfg.webserver;
defaultText = "{option}`config.services.rss-bridge.webserver` or \"rss-bridge\"";
description = ''
User account under which both the service and the web-application run.
The user account under which both the service and the web application run.
'';
};
group = mkOption {
type = types.str;
default = "nginx";
default = if cfg.webserver == null then "rss-bridge" else cfg.webserver;
defaultText = "{option}`config.services.rss-bridge.webserver` or \"rss-bridge\"";
description = ''
Group under which the web-application run.
The group under which the web application runs.
'';
};
@ -99,7 +100,20 @@ in
type = types.nullOr types.str;
default = "rss-bridge";
description = ''
Name of the nginx virtualhost to use and setup. If null, do not setup any virtualhost.
Name of the nginx or caddy virtualhost to use and setup. If null, do not setup any virtualhost.
'';
};
webserver = mkOption {
type = types.nullOr (
types.enum [
"nginx"
"caddy"
]
);
default = "nginx";
description = ''
Type of virtualhost to use and setup. If null, do not setup any virtualhost.
'';
};
@ -172,7 +186,7 @@ in
};
};
services.nginx = mkIf (cfg.virtualHost != null) {
services.nginx = mkIf (cfg.virtualHost != null && cfg.webserver == "nginx") {
enable = true;
virtualHosts = {
${cfg.virtualHost} = {
@ -194,6 +208,19 @@ in
};
};
};
services.caddy = mkIf (cfg.virtualHost != null && cfg.webserver == "caddy") {
enable = true;
virtualHosts.${cfg.virtualHost} = {
extraConfig = ''
root * ${cfg.package}
file_server
php_fastcgi unix/${config.services.phpfpm.pools.${cfg.pool}.socket} {
${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: " env ${n} \"${v}\"") cfgEnv)}
}
'';
};
};
};
meta.maintainers = with lib.maintainers; [ quantenzitrone ];