aboutsummaryrefslogtreecommitdiff
path: root/services/caddy.nix
diff options
context:
space:
mode:
authorCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-05-31 14:40:27 -0500
committerCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-05-31 14:40:27 -0500
commit9ef174152929b038b01bc2f261b719a57cdad654 (patch)
tree97786317ef5d3de3db76cbd8f40424d5398c6319 /services/caddy.nix
parent35af4bab99da94845ebd6e9b2efae6a544d39b35 (diff)
stuff
Diffstat (limited to 'services/caddy.nix')
-rw-r--r--services/caddy.nix104
1 files changed, 0 insertions, 104 deletions
diff --git a/services/caddy.nix b/services/caddy.nix
deleted file mode 100644
index 9870af0..0000000
--- a/services/caddy.nix
+++ /dev/null
@@ -1,104 +0,0 @@
-{
- lib,
- config,
- ...
-}: let
- cfg = config.caddy;
-in {
- options = {
- caddy = {
- globalConfig = lib.mkOption {
- description = "Configuration for top level stuff (ex. dns server api keys)";
- type = lib.types.lines;
- default = "";
- };
- tld = lib.mkOption {
- description = "Your publically accessable domain name";
- type = lib.types.str;
- };
- hostname = lib.mkOption {
- description = "Your computers hostname";
- type = lib.types.str;
- };
- virtualHosts = lib.mkOption {
- description = "Magically configure caddy for services";
- type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
- options = {
- serviceName = lib.mkOption {
- type = lib.types.str;
- default = config._module.args.name;
- internal = true;
- };
- access = lib.mkOption {
- type = lib.types.enum ["public" "private"];
- description = "public: accessable at {serviceName}.my.tld. private: accessable at {serviceName}.{hostname}";
- };
- logFile = lib.mkOption {
- type = lib.types.str;
- description = "what to name the log file under /var/log/caddy";
- default = "${config.serviceName}.log";
- };
- reverseProxy = lib.mkOption {
- type = with lib.types; nullOr str;
- description = "configure caddy to reverse-proxy this port or unix domain socket (ex. 127.0.0.1:8080 or unix//var/run/my_socket)";
- default = null;
- };
- virtualHostConfig = lib.mkOption {
- type = lib.types.lines;
- description = "manual config lines to add to the caddy config";
- default = "";
- };
- };
- }));
- default = {};
- };
- };
- };
- config = {
- configData."caddyfile".text =
- ''
- {
- ${cfg.globalConfig}
- }
- ''
- ++ (cfg.virtualHosts
- |> map (vhost_cfg: let
- target =
- if vhost_cfg.access == "public"
- then
- (
- if vhost_cfg.serviceName != "root"
- then "${vhost_cfg.serviceName}.${cfg.tld}"
- else cfg.tld
- )
- else
- (
- if vhost_cfg.serviceName != "root"
- then "${vhost_cfg.serviceName}.${cfg.hostName}"
- else cfg.hostname
- );
- in ''
- log {
- output file /var/log/caddy/${vhost_cfg.logFile}
- }
-
- ${target} {
- ${
- if vhost_cfg.access == "private"
- then "tls internal"
- else ""
- }
- ${
- if vhost_cfg.reverseProxy != null
- then "reverse_proxy ${vhost_cfg.reverseProxy}"
- else ""
- }
- ${vhost_cfg.virtualHostConfig}
- }
- '')
- |> builtins.concatStringsSep "\n\n");
-
- services."caddy".systemd.service = {
- };
- };
-}