-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmodule.nix
78 lines (68 loc) · 1.77 KB
/
module.nix
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
self: { config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.minidsp;
tomlFormat = pkgs.formats.toml {};
in
{
options = {
services.minidsp = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable the minidsp service
'';
};
package = mkOption {
type = types.package;
default = self.packages.${pkgs.system}.default;
description = ''
minidsp package to use
'';
};
config = mkOption {
type = tomlFormat.type;
default = {
http_server = {
bind_address = "127.0.0.1:5380";
};
tcp_server = [{
bind_address = "127.0.0.1:5333";
}];
};
description = ''
Configuration file
For available options see <https://minidsp-rs.pages.dev/daemon/>
'';
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
users = {
users.minidsp = {
description = "minidsp daemon user";
group = "minidsp";
isSystemUser = true;
};
groups.minidsp = {};
};
systemd.services.minidsp = {
after = ["network.target"];
description = "minidsp daemon";
wantedBy = ["multi-user.target"];
serviceConfig = {
User = "minidsp";
ExecStart = "${cfg.package}/bin/minidspd --config /etc/minidsp/config.toml";
};
};
environment.etc."minidsp/config.toml" = {
source = tomlFormat.generate "config.toml" cfg.config;
};
services.udev.extraRules = ''
ATTR{idVendor}=="2752", MODE="660", GROUP="minidsp"
ATTR{idVendor}=="04d8", ATTRS{idProduct}=="003f", MODE="660", GROUP="minidsp"
'';
};
}