summary refs log tree commit diff
path: root/nixos/modules/services/audio/fuppes.nix
blob: 3eb0732bae2e2316e6bb574432bfdd66bef79dbc (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{config, pkgs, ...}:

let
  cfg = config.services.fuppesd;
in

with pkgs.lib;

{
  options = {
    services.fuppesd = {
      enable = mkOption {
        default = false;
        type = with types; bool;
        description = ''
          Enables Fuppes (UPnP A/V Media Server).  Can be used to watch
          photos, video and listen to music from a phone/tv connected to the
          local network.
        '';
      };

      name = mkOption {
        example = "Media Center";
        type = types.str;
        description = ''
          Enables Fuppes (UPnP A/V Media Server).  Can be used to watch
          photos, video and listen to music from a phone/tv connected to the
          local network.
        '';
      };

      log = {
        level = mkOption {
          default = 0;
          example = 3;
          type = with types; uniq int;
          description = ''
            Logging level of fuppes, An integer between 0 and 3.
          '';
        };

        file = mkOption {
          default = "/var/log/fuppes.log";
          type = types.str;
          description = ''
            File which will contains the log produced by the daemon.
          '';
        };
      };

      config = mkOption {
        example = "/etc/fuppes/fuppes.cfg";
        type = types.str;
        description = ''
          Mutable configuration file which can be edited with the web
          interface.  Due to possible modification, double quote the full
          path of the filename stored in your filesystem to avoid attempts
          to modify the content of the nix store.
        '';
      };

      vfolder = mkOption {
        example = literalExample "/etc/fuppes/vfolder.cfg";
        description = ''
          XML file describing the layout of virtual folder visible by the
          client.
        '';
      };

      database = mkOption {
        default = "/var/lib/fuppes/fuppes.db";
        type = types.str;
        description = ''
          Database file which index all shared files.
        '';
      };

      ## At the moment, no plugins are packaged.
      /*
      plugins = mkOption {
        type = with types; listOf package;
        description = ''
          List of Fuppes plugins.
        '';
      };
      */

      user = mkOption {
        default = "root"; # The default is not secure.
        example = "fuppes";
        type = types.str;
        description = ''
          Name of the user which own the configuration files and under which
          the fuppes daemon will be executed.
        '';
      };

    };
  };

  config = mkIf cfg.enable {
    jobs.fuppesd = {
      description = "UPnP A/V Media Server. (${cfg.name})";
      startOn = "ip-up";
      daemonType = "fork";
      exec = ''/var/setuid-wrappers/sudo -u ${cfg.user} -- ${pkgs.fuppes}/bin/fuppesd --friendly-name ${cfg.name} --log-level ${toString cfg.log.level} --log-file ${cfg.log.file} --config-file ${cfg.config} --vfolder-config-file ${cfg.vfolder} --database-file ${cfg.database}'';
    };

    services.fuppesd.name = mkDefault config.networking.hostName;

    services.fuppesd.vfolder = mkDefault ./fuppes/vfolder.cfg;

    security.sudo.enable = true;
  };
}