nixpkgs/modules/services/audio/pulseaudio.nix
Eelco Dolstra 60b3f95ad8 * Move the definition of the set of system packages to
modules/config/system-path.nix.  system/system.nix is now almost
  empty.
* Removed the cleanStart option - it should be possible to get the
  same functionality by overriding config.system.path (or defining
  config.system.systemPackages with a higher priority - don't know if
  that works though).

svn path=/nixos/branches/modular-nixos/; revision=15727
2009-05-25 17:41:03 +00:00

91 lines
2.0 KiB
Nix

{pkgs, config, ...}:
###### interface
let
inherit (pkgs.lib) mkOption mkIf;
uid = (import ../../../system/ids.nix).uids.pulseaudio;
gid = (import ../../../system/ids.nix).gids.pulseaudio;
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
# For some reason, PulseAudio wants UID == GID.
assert uid == gid;
mkIf config.services.pulseaudio.enable {
require = [
options
];
environment = {
extraPackages = [pkgs.pulseaudio];
};
users = {
extraUsers = [
{ name = "pulse";
inherit uid;
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}"
'';
}];
};
}