···
1
+
{ config, lib, pkgs, ... }:
5
+
cfg = config.services.webdav;
6
+
format = pkgs.formats.yaml { };
11
+
enable = mkEnableOption "WebDAV server";
16
+
description = "User account under which WebDAV runs.";
22
+
description = "Group under which WebDAV runs.";
25
+
settings = mkOption {
29
+
Attrset that is converted and passed as config file. Available options
31
+
<link xlink:href="https://github.com/hacdias/webdav">here</link>.
33
+
This program supports reading username and password configuration
34
+
from environment variables, so it's strongly recommended to store
35
+
username and password in a separate
36
+
<link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile=">EnvironmentFile</link>.
37
+
This prevents adding secrets to the world-readable Nix store.
39
+
example = literalExpression ''
41
+
address = "0.0.0.0";
43
+
scope = "/srv/public";
48
+
username = "{env}ENV_USERNAME";
49
+
password = "{env}ENV_PASSWORD";
56
+
configFile = mkOption {
58
+
default = format.generate "webdav.yaml" cfg.settings;
59
+
defaultText = "Config file generated from services.webdav.settings";
61
+
Path to config file. If this option is set, it will override any
62
+
configuration done in options.services.webdav.settings.
64
+
example = "/etc/webdav/config.yaml";
67
+
environmentFile = mkOption {
68
+
type = types.nullOr types.path;
71
+
Environment file as defined in <citerefentry>
72
+
<refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum>
79
+
config = mkIf cfg.enable {
80
+
users.users = mkIf (cfg.user == "webdav") {
82
+
description = "WebDAV daemon user";
83
+
isSystemUser = true;
88
+
users.groups = mkIf (cfg.group == "webdav") {
92
+
systemd.services.webdav = {
93
+
description = "WebDAV server";
94
+
after = [ "network.target" ];
95
+
wantedBy = [ "multi-user.target" ];
97
+
ExecStart = "${pkgs.webdav}/bin/webdav -c ${cfg.configFile}";
98
+
Restart = "on-failure";
101
+
EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
106
+
meta.maintainers = with maintainers; [ pengmeiyu ];