1 { config, lib, pkgs, ... }:
3 cfg = config.services.webdav;
4 format = pkgs.formats.yaml { };
9 enable = lib.mkEnableOption "WebDAV server";
14 description = "User account under which WebDAV runs.";
17 group = lib.mkOption {
20 description = "Group under which WebDAV runs.";
23 settings = lib.mkOption {
27 Attrset that is converted and passed as config file. Available options
29 [here](https://github.com/hacdias/webdav).
31 This program supports reading username and password configuration
32 from environment variables, so it's strongly recommended to store
33 username and password in a separate
34 [EnvironmentFile](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile=).
35 This prevents adding secrets to the world-readable Nix store.
37 example = lib.literalExpression ''
41 scope = "/srv/public";
46 username = "{env}ENV_USERNAME";
47 password = "{env}ENV_PASSWORD";
54 configFile = lib.mkOption {
55 type = lib.types.path;
56 default = format.generate "webdav.yaml" cfg.settings;
57 defaultText = "Config file generated from services.webdav.settings";
59 Path to config file. If this option is set, it will override any
60 configuration done in options.services.webdav.settings.
62 example = "/etc/webdav/config.yaml";
65 environmentFile = lib.mkOption {
66 type = lib.types.nullOr lib.types.path;
69 Environment file as defined in {manpage}`systemd.exec(5)`.
75 config = lib.mkIf cfg.enable {
76 users.users = lib.mkIf (cfg.user == "webdav") {
78 description = "WebDAV daemon user";
80 uid = config.ids.uids.webdav;
84 users.groups = lib.mkIf (cfg.group == "webdav") {
85 webdav.gid = config.ids.gids.webdav;
88 systemd.services.webdav = {
89 description = "WebDAV server";
90 after = [ "network.target" ];
91 wantedBy = [ "multi-user.target" ];
93 ExecStart = "${pkgs.webdav}/bin/webdav -c ${cfg.configFile}";
94 Restart = "on-failure";
97 EnvironmentFile = lib.mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
102 meta.maintainers = with lib.maintainers; [ pmy ];