2009-01-29 19:28:09 +01:00
|
|
|
{pkgs, config, ...}:
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
let
|
2009-02-01 19:35:56 +01:00
|
|
|
inherit (pkgs.lib) mkOption mkIf;
|
2009-01-29 19:28:09 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
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>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
|
2009-02-01 19:35:56 +01:00
|
|
|
mkIf config.services.pulseaudio.enable {
|
2009-01-29 19:28:09 +01:00
|
|
|
require = [
|
|
|
|
options
|
|
|
|
];
|
|
|
|
|
|
|
|
environment = {
|
2009-05-25 19:41:03 +02:00
|
|
|
extraPackages = [pkgs.pulseaudio];
|
2009-01-29 19:28:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
users = {
|
|
|
|
extraUsers = [
|
|
|
|
{ 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";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
extraGroups = [
|
|
|
|
{ name = "pulse";
|
|
|
|
inherit gid;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
|
|
|
extraJobs = [{
|
|
|
|
name = "pulseaudio";
|
|
|
|
|
|
|
|
job = ''
|
|
|
|
description "PulseAudio system-wide server"
|
|
|
|
|
|
|
|
start on startup
|
|
|
|
stop on shutdown
|
|
|
|
|
|
|
|
start script
|
|
|
|
test -d /var/run/pulse || \
|
|
|
|
( mkdir -p --mode 755 /var/run/pulse && \
|
|
|
|
chown pulse:pulse /var/run/pulse )
|
|
|
|
end script
|
|
|
|
|
|
|
|
respawn ${pkgs.pulseaudio}/bin/pulseaudio \
|
|
|
|
--system --daemonize \
|
|
|
|
--log-level="${config.services.pulseaudio.logLevel}"
|
|
|
|
'';
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
}
|