Some checks failed
Test action / kaas (push) Failing after 1s
- Add restartUnits and ownership to Matrix and Servarr secrets - Use sops secret for qbittorrent password hash - Refactor Cardigann indexer config in Servarr - Update Caddy plugin version and hash - Add debug output to machine update justfile
40 lines
905 B
Nix
40 lines
905 B
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
namespace,
|
|
...
|
|
}: let
|
|
inherit (builtins) length;
|
|
inherit (lib) mkIf mkEnableOption mkOption types attrNames mapAttrs;
|
|
|
|
cfg = config.${namespace}.services.networking.caddy;
|
|
hasHosts = (cfg.hosts |> attrNames |> length) > 0;
|
|
in {
|
|
options.${namespace}.services.networking.caddy = {
|
|
enable = mkEnableOption "enable caddy" // {default = true;};
|
|
|
|
hosts = mkOption {
|
|
type = types.attrsOf types.str;
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
type = types.str;
|
|
};
|
|
};
|
|
|
|
config = mkIf hasHosts {
|
|
services.caddy = {
|
|
enable = cfg.enable;
|
|
|
|
package = pkgs.caddy.withPlugins {
|
|
plugins = ["github.com/corazawaf/coraza-caddy/v2@v2.1.0"];
|
|
hash = "sha256-AdL/LFKXbWmCsJ/xZWZmYBnw57c7sS6s1miR3sSx1Ow=";
|
|
};
|
|
|
|
virtualHosts =
|
|
cfg.hosts
|
|
|> mapAttrs (host: extraConfig: {inherit extraConfig;});
|
|
};
|
|
};
|
|
}
|