blob: d301a4967de4d371a575f52de14c2db4f3aea1e6 (
plain)
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
|
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.eth.services.upmpdcli;
cacheDir = "upmpdcli";
upmpdConf = pkgs.writeText "upmpd.conf" ''
cachedir = /var/cache/${cacheDir}
friendlyname = ${cfg.friendlyName}
mpdhost = ${cfg.mpd.host}
mpdport = ${toString cfg.mpd.port}
${optionalString (cfg.mpd.password != "") "${cfg.mpd.password}"}
${cfg.extraConfig}
'';
in {
options.eth.services.upmpdcli = {
enable = mkEnableOption "Run upmpdcli server";
friendlyName = mkOption {
type = types.str;
default = "UpMpd (${config.networking.hostName})";
description = "Friendly Name used for UPnP discovery.";
};
mpd = {
host = mkOption {
type = types.str;
default = config.services.mpd.network.listenAddress;
description = "Host of the MPD server.";
};
port = mkOption {
type = types.int;
default = config.services.mpd.network.port;
description = "Port of the MPD server.";
};
password = mkOption {
type = types.str;
default = "";
description = "Password of the MPD server.";
};
};
extraConfig = mkOption {
type = types.lines;
default = "";
};
};
config = mkIf cfg.enable {
systemd.services.upmpdcli = {
enable = true;
description = "";
wants = [ "network.target" ];
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.openssl pkgs.python3 ];
serviceConfig = {
DynamicUser = true;
CacheDirectory = cacheDir;
Type = "simple";
ExecStart="${pkgs.eth.upmpdcli}/bin/upmpdcli -c ${upmpdConf}";
Restart = "always";
RestartSec = "1min";
NoNewPrivileges = true;
ProtectHome = true;
ProtectKernelTunables = true;
ProtectControlGroups = true;
ProtectKernelModules = true;
};
};
};
}
|