mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 15:11:25 +00:00
Add Upstart job for PulseAudio as a system-wide daemon.
svn path=/nixos/trunk/; revision=13907
This commit is contained in:
parent
42a83d3391
commit
2b8216bdda
@ -19,6 +19,7 @@
|
||||
dovecot = 15;
|
||||
tomcat = 16;
|
||||
gnunetd = 17;
|
||||
pulseaudio = 22; # must match `pulseaudio' GID
|
||||
|
||||
nixbld = 30000; # start of range of uids
|
||||
nobody = 65534;
|
||||
@ -45,6 +46,7 @@
|
||||
uucp = 19;
|
||||
lp = 20;
|
||||
tomcat = 21;
|
||||
pulseaudio = 22; # must match `pulseaudio' UID
|
||||
|
||||
users = 100;
|
||||
nixbld = 30000;
|
||||
|
@ -3066,5 +3066,6 @@ root ALL=(ALL) SETENV: ALL
|
||||
(import ../upstart-jobs/manual.nix)
|
||||
(import ../upstart-jobs/rogue.nix)
|
||||
(import ../upstart-jobs/guest-users.nix)
|
||||
(import ../upstart-jobs/pulseaudio.nix)
|
||||
];
|
||||
}
|
||||
|
94
upstart-jobs/pulseaudio.nix
Normal file
94
upstart-jobs/pulseaudio.nix
Normal file
@ -0,0 +1,94 @@
|
||||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption;
|
||||
|
||||
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;
|
||||
|
||||
{
|
||||
require = [
|
||||
options
|
||||
];
|
||||
|
||||
environment = {
|
||||
|
||||
extraPackages =
|
||||
pkgs.lib.optional
|
||||
(!config.environment.cleanStart)
|
||||
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}"
|
||||
'';
|
||||
}];
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user