forked from aylac.top/nixcfg
this repo has no description
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: let 7 name = "radicale"; 8 cfg = config.myNixOS.services.${name}; 9 10 network = config.mySnippets.tailnet; 11 service = network.networkMap.${name}; 12in { 13 options.myNixOS.services.${name} = { 14 enable = lib.mkEnableOption "${name} server"; 15 autoProxy = lib.mkOption { 16 default = true; 17 example = false; 18 description = "${name} auto proxy"; 19 type = lib.types.bool; 20 }; 21 }; 22 23 config = lib.mkIf cfg.enable { 24 services = { 25 caddy.virtualHosts."${service.vHost}".extraConfig = lib.mkIf cfg.autoProxy '' 26 bind tailscale/${name} 27 encode zstd gzip 28 reverse_proxy ${service.hostName}:${toString service.port} 29 ''; 30 31 radicale = { 32 enable = true; 33 settings = { 34 server = { 35 hosts = ["0.0.0.0:${toString service.port}" "[::]:${toString service.port}"]; 36 }; 37 auth = { 38 type = "htpasswd"; 39 htpasswd_filename = "/var/lib/radicale/users"; 40 htpasswd_encryption = "autodetect"; 41 }; 42 storage = { 43 filesystem_folder = "/var/lib/radicale/collections"; 44 hook = ''${pkgs.git}/bin/git add -A && (${pkgs.git}/bin/git diff --cached --quiet || ${pkgs.git}/bin/git commit -m "Changes by \"%(user)s\"")''; 45 }; 46 }; 47 }; 48 }; 49 }; 50}