2022-10-02 15:24:25 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
2022-10-02 17:40:10 +00:00
|
|
|
caddyRoutes = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.attrs;
|
|
|
|
description = "Caddy JSON routes for http servers";
|
2022-10-02 15:24:25 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
|
|
|
services.caddy = {
|
|
|
|
enable = true;
|
|
|
|
adapter = "''"; # Required to enable JSON
|
2022-10-02 17:40:10 +00:00
|
|
|
configFile = pkgs.writeText "Caddyfile" (builtins.toJSON {
|
|
|
|
apps.http.servers.main = {
|
|
|
|
listen = [ ":443" ];
|
|
|
|
routes = config.caddyRoutes;
|
|
|
|
};
|
|
|
|
});
|
2022-10-02 15:24:25 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|