about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/misc/spice-webdavd.nix
blob: bfb5b262ee1ad3d1311395354f85423b3ab09629 (plain) (blame)
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
{ config, pkgs, lib, ... }:

with lib;
let
  cfg = config.services.spice-webdavd;
in
{
  options = {
    services.spice-webdavd = {
      enable = mkEnableOption "the spice guest webdav proxy daemon";

      package = mkOption {
        default = pkgs.phodav;
        defaultText = literalExpression "pkgs.phodav";
        type = types.package;
        description = "spice-webdavd provider package to use.";
      };
    };
  };

  config = mkIf cfg.enable {
    # ensure the webdav fs this exposes can actually be mounted
    services.davfs2.enable = true;

    # add the udev rule which starts the proxy when the spice socket is present
    services.udev.packages = [ cfg.package ];

    systemd.services.spice-webdavd = {
      description = "spice-webdav proxy daemon";

      serviceConfig = {
        Type = "simple";
        ExecStart = "${cfg.package}/bin/spice-webdavd -p 9843";
        Restart = "on-success";
      };
    };
  };
}