blob: 04df2a8e867d73005724e9c98160e39a026d83be (
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
|
{ config, pkgs, ... }:
with pkgs.lib;
let
uid = config.ids.uids.pulseaudio;
gid = config.ids.gids.pulseaudio;
in
{
###### interface
options = {
services.pulseaudio = {
enable = mkOption {
default = false;
description = ''
Whether to enable the PulseAudio system-wide audio server.
Note that the documentation recommends running PulseAudio
daemons per-user rather than system-wide on desktop machines.
'';
};
logLevel = mkOption {
default = "notice";
example = "debug";
description = ''
A string denoting the log level: one of
<literal>error</literal>, <literal>warn</literal>,
<literal>notice</literal>, <literal>info</literal>,
or <literal>debug</literal>.
'';
};
};
};
###### implementation
config = mkIf config.services.pulseaudio.enable {
environment.systemPackages = [ pkgs.pulseaudio ];
users.extraUsers = singleton
{ name = "pulse";
# For some reason, PulseAudio wants UID == GID.
uid = assert uid == gid; uid;
group = "pulse";
description = "PulseAudio system-wide daemon";
home = "/var/run/pulse";
};
users.extraGroups = singleton
{ name = "pulse";
inherit gid;
};
jobs.pulseaudio =
{ description = "PulseAudio system-wide server";
startOn = "startup";
preStart =
''
test -d /var/run/pulse || \
( mkdir -p --mode 755 /var/run/pulse && \
chown pulse:pulse /var/run/pulse )
'';
exec =
''
${pkgs.pulseaudio}/bin/pulseaudio \
--system --daemonize \
--log-level="${config.services.pulseaudio.logLevel}"
'';
};
};
}
|