2021-06-10 20:56:40 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
internalPort = 5232;
|
|
|
|
|
2021-06-10 21:34:27 +02:00
|
|
|
radicaleOverlay = self: super: {
|
2021-06-10 23:01:24 +02:00
|
|
|
radicaleWithInfcloud = super.radicale.overrideAttrs (old: {
|
2021-06-10 22:48:43 +02:00
|
|
|
propagatedBuildInputs = old.propagatedBuildInputs
|
2021-06-11 00:21:47 +02:00
|
|
|
++ [ pkgs.python3Packages.radicale_infcloud ];
|
2021-06-10 23:01:24 +02:00
|
|
|
});
|
2021-06-10 20:56:40 +02:00
|
|
|
};
|
|
|
|
|
2021-11-03 14:50:37 +01:00
|
|
|
htpasswd_filename = "/etc/radicale/users";
|
|
|
|
|
2021-06-10 20:56:40 +02:00
|
|
|
in {
|
|
|
|
|
|
|
|
nixpkgs.overlays = [ radicaleOverlay ];
|
|
|
|
|
|
|
|
services.radicale = {
|
|
|
|
enable = true;
|
2021-06-10 22:46:18 +02:00
|
|
|
package = pkgs.radicaleWithInfcloud;
|
2021-06-10 20:56:40 +02:00
|
|
|
settings = {
|
2021-06-10 21:34:27 +02:00
|
|
|
server = {
|
2021-06-10 20:56:40 +02:00
|
|
|
hosts = [ "[::1]:${builtins.toString internalPort}" ];
|
|
|
|
max_connections = 8;
|
|
|
|
max_content_length = 100000000;
|
|
|
|
timeout = 30;
|
|
|
|
};
|
|
|
|
auth = {
|
2021-11-03 14:50:37 +01:00
|
|
|
inherit htpasswd_filename;
|
2021-06-10 20:56:40 +02:00
|
|
|
type = "htpasswd";
|
|
|
|
htpasswd_encryption = "bcrypt";
|
|
|
|
delay = 1;
|
|
|
|
};
|
|
|
|
encoding = {
|
|
|
|
request = "utf-8";
|
|
|
|
stock = "utf-8";
|
|
|
|
};
|
2021-06-10 21:34:27 +02:00
|
|
|
storage = { filesystem_folder = "/var/lib/radicale/collections"; };
|
2021-06-10 23:25:33 +02:00
|
|
|
web = { type = "internal"; };
|
2021-06-10 21:34:27 +02:00
|
|
|
logging = { mask_passwords = true; };
|
2021-06-10 20:56:40 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-06-10 22:15:14 +02:00
|
|
|
services.nginx.virtualHosts."cal.tammena.rocks" = {
|
2021-06-10 20:56:40 +02:00
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
2021-06-10 21:45:05 +02:00
|
|
|
proxyPass = "http://[::1]:${builtins.toString internalPort}";
|
2021-06-10 20:56:40 +02:00
|
|
|
#proxyWebsockets = true; # needed if you need to use WebSocket
|
|
|
|
#extraConfig =
|
2021-06-10 21:34:27 +02:00
|
|
|
# required when the target is also TLS server with multiple hosts
|
|
|
|
#"proxy_ssl_server_name on;" +
|
|
|
|
# required when the server wants to use HTTP Authentication
|
|
|
|
#"proxy_pass_header Authorization;";
|
2021-06-10 20:56:40 +02:00
|
|
|
};
|
|
|
|
};
|
2021-11-03 14:50:37 +01:00
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
# Add a script to easily add users
|
|
|
|
(pkgs.writeScriptBin "radicale-set-user" ''
|
|
|
|
#!${pkgs.stdenv.shell}
|
|
|
|
mkdir -p $(dirname "${htpasswd_filename}")
|
|
|
|
${pkgs.apacheHttpd}/bin/htpasswd -Bc "${htpasswd_filename}" $1
|
|
|
|
'')
|
|
|
|
];
|
2021-06-10 20:56:40 +02:00
|
|
|
}
|