radicale.nix (1252B)
1 { 2 config, 3 lib, 4 ... 5 }: let 6 cfg = config.services.haravara.radicale; 7 in { 8 options.services.haravara.radicale = { 9 enable = lib.mkEnableOption "Radicale CalDAV/CardDAV server"; 10 domain = lib.mkOption { 11 type = lib.types.str; 12 description = "Domain for the Radicale instance"; 13 }; 14 port = lib.mkOption { 15 type = lib.types.port; 16 default = 5232; 17 description = "Port for Radicale to listen on"; 18 }; 19 dataDir = lib.mkOption { 20 type = lib.types.str; 21 default = "/var/lib/radicale/collections"; 22 description = "Directory for Radicale storage"; 23 }; 24 htpasswdFile = lib.mkOption { 25 type = lib.types.path; 26 description = "Path to htpasswd file for Radicale auth"; 27 }; 28 }; 29 30 config = lib.mkIf cfg.enable { 31 services.radicale = { 32 enable = true; 33 settings = { 34 server.hosts = ["127.0.0.1:${toString cfg.port}"]; 35 auth = { 36 type = "htpasswd"; 37 htpasswd_filename = cfg.htpasswdFile; 38 htpasswd_encryption = "bcrypt"; 39 }; 40 storage.filesystem_folder = cfg.dataDir; 41 }; 42 }; 43 44 services.caddy.virtualHosts."${cfg.domain}".extraConfig = '' 45 reverse_proxy 127.0.0.1:${toString cfg.port} 46 ''; 47 }; 48 }