about summary refs log tree commit diff
path: root/machines/srv3/services/webdav/default.nix
blob: e18449072dab9831510df92baef649298714f417 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{ config, lib, ... }:
let
cfg = config.services.srv3-webdav;
in
{

	options = {
		services.srv3-webdav = {
			enable = lib.mkEnableOption "WebDav server";

			domain = lib.mkOption {
				type = lib.types.str;
				description = "Where webdav server should live";
			};

			port = lib.mkOption {
				type = lib.types.number;
				default = 6060;
# FIX: Hardening reverse proxy
				description = "Internal port on which webdav server will run";
			};
			
			configFile = lib.mkOption {
				type = lib.types.path;
				default = "/etc/webdav.yaml";
				description = "WebDav server config file";
			};
		};

	};
	config = lib.mkIf cfg.enable {
		services.nginx.virtualHosts.${cfg.domain} = {
			forceSSL = true;
			enableACME = true;

			locations."/" = {
				proxyPass = "http://localhost:${toString cfg.port}";
			};
		};

		services.webdav = {
			enable = true;
			configFile = cfg.configFile;
		};
	};

}