2009-10-12 18:36:19 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2009-01-29 19:28:09 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2009-05-29 16:25:56 +02:00
|
|
|
uid = config.ids.uids.pulseaudio;
|
|
|
|
gid = config.ids.gids.pulseaudio;
|
2009-01-29 19:28:09 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
2009-01-29 19:28:09 +01:00
|
|
|
options = {
|
2009-10-12 18:36:19 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
'';
|
2009-01-29 19:28:09 +01:00
|
|
|
};
|
2009-10-12 18:36:19 +02:00
|
|
|
|
|
|
|
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>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-01-29 19:28:09 +01:00
|
|
|
};
|
2009-10-12 18:36:19 +02:00
|
|
|
|
2009-01-29 19:28:09 +01:00
|
|
|
};
|
2009-10-12 18:36:19 +02:00
|
|
|
|
2009-01-29 19:28:09 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
###### implementation
|
2009-01-29 19:28:09 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
config = mkIf config.services.pulseaudio.enable {
|
2009-01-29 19:28:09 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
environment.systemPackages = [ pkgs.pulseaudio ];
|
2009-01-29 19:28:09 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
users.extraUsers = singleton
|
2009-01-29 19:28:09 +01:00
|
|
|
{ name = "pulse";
|
2009-05-29 16:25:56 +02:00
|
|
|
# For some reason, PulseAudio wants UID == GID.
|
|
|
|
uid = assert uid == gid; uid;
|
2009-01-29 19:28:09 +01:00
|
|
|
group = "pulse";
|
|
|
|
description = "PulseAudio system-wide daemon";
|
|
|
|
home = "/var/run/pulse";
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
2009-01-29 19:28:09 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
users.extraGroups = singleton
|
2009-01-29 19:28:09 +01:00
|
|
|
{ name = "pulse";
|
|
|
|
inherit gid;
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
2009-01-29 19:28:09 +01:00
|
|
|
|
2009-10-12 20:09:34 +02:00
|
|
|
jobs.pulseaudio =
|
2009-10-12 18:36:19 +02:00
|
|
|
{ description = "PulseAudio system-wide server";
|
2009-01-29 19:28:09 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
startOn = "startup";
|
2009-01-29 19:28:09 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
test -d /var/run/pulse || \
|
|
|
|
( mkdir -p --mode 755 /var/run/pulse && \
|
|
|
|
chown pulse:pulse /var/run/pulse )
|
|
|
|
'';
|
2009-01-29 19:28:09 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
exec =
|
|
|
|
''
|
|
|
|
${pkgs.pulseaudio}/bin/pulseaudio \
|
|
|
|
--system --daemonize \
|
|
|
|
--log-level="${config.services.pulseaudio.logLevel}"
|
|
|
|
'';
|
|
|
|
};
|
2009-01-29 19:28:09 +01:00
|
|
|
|
|
|
|
};
|
2009-10-12 18:36:19 +02:00
|
|
|
|
2009-01-29 19:28:09 +01:00
|
|
|
}
|