| { base, config, pkgs, lib, ... }: lib.recursiveUpdate { |
| services.caddy.enable = true; |
| services.caddy.configFile = lib.pipe ./caddy/caddyfile.nix [ |
| (f: f { inherit pkgs lib; }) |
| (pkgs.writeText "caddy.json") |
| services.caddy.package = pkgs.callPackage ../packages/caddy.nix { }; |
| services.caddy.user = "root"; |
| systemd.services.caddy.serviceConfig.ProtectHome = lib.mkForce false; |
| sops.secrets.cloudflare_token = { |
| owner = config.users.users.root.name; |
| group = config.users.users.nobody.group; |
| sopsFile = ../secrets/caddy.json; |
| isDerived = base != null; |
| caddy_json = base.config.services.caddy.configFile; |
| scalpel.trafos."caddy.json" = { |
| source = toString caddy_json; |
| matchers."cloudflare_token".secret = |
| config.sops.secrets.cloudflare_token.path; |
| owner = config.users.users.root.name; |
| group = config.users.users.nobody.group; |
| services.caddy.configFile = lib.mkForce config.scalpel.trafos."caddy.json".destination; |
| systemd.services.caddy.reloadTriggers = [ caddy_json ]; |