1 { config, lib, pkgs, ... }:
5 cfg = config.services.webdav;
6 format = pkgs.formats.yaml { };
11 enable = mkEnableOption (lib.mdDoc "WebDAV server");
16 description = lib.mdDoc "User account under which WebDAV runs.";
22 description = lib.mdDoc "Group under which WebDAV runs.";
28 description = lib.mdDoc ''
29 Attrset that is converted and passed as config file. Available options
31 [here](https://github.com/hacdias/webdav).
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 [EnvironmentFile](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile=).
37 This prevents adding secrets to the world-readable Nix store.
39 example = literalExpression ''
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";
60 description = lib.mdDoc ''
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;
70 description = lib.mdDoc ''
71 Environment file as defined in {manpage}`systemd.exec(5)`.
77 config = mkIf cfg.enable {
78 users.users = mkIf (cfg.user == "webdav") {
80 description = "WebDAV daemon user";
82 uid = config.ids.uids.webdav;
86 users.groups = mkIf (cfg.group == "webdav") {
87 webdav.gid = config.ids.gids.webdav;
90 systemd.services.webdav = {
91 description = "WebDAV server";
92 after = [ "network.target" ];
93 wantedBy = [ "multi-user.target" ];
95 ExecStart = "${pkgs.webdav}/bin/webdav -c ${cfg.configFile}";
96 Restart = "on-failure";
99 EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
104 meta.maintainers = with maintainers; [ pmy ];