mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-22 21:35:37 +00:00
move caddy config into separate file
This commit is contained in:
parent
90bc2ecd49
commit
b4ba0706c0
26
modules/services/caddy.nix
Normal file
26
modules/services/caddy.nix
Normal file
@ -0,0 +1,26 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
|
||||
in {
|
||||
|
||||
options = {
|
||||
caddyServers = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "Caddy JSON configs for http servers";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
adapter = "''"; # Required to enable JSON
|
||||
configFile = pkgs.writeText "Caddyfile"
|
||||
(builtins.toJSON { apps.http.servers = config.caddyServers; });
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -7,6 +7,8 @@ let
|
||||
|
||||
in {
|
||||
|
||||
imports = [ ./caddy.nix ];
|
||||
|
||||
options = {
|
||||
bookServer = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
@ -26,12 +28,7 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
adapter = "''"; # Required to enable JSON
|
||||
configFile = pkgs.writeText "Caddyfile" (builtins.toJSON {
|
||||
apps.http.servers = {
|
||||
calibre = {
|
||||
caddyServers.calibre = {
|
||||
listen = [ ":443" ];
|
||||
routes = [{
|
||||
match = [{ host = [ config.bookServer ]; }];
|
||||
@ -42,10 +39,6 @@ in {
|
||||
}];
|
||||
}];
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
networking.firewall.interfaces.calibre = { allowedTCPPorts = [ 80 443 ]; };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user