mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
Add mpd module
There is room for improvement here. The options in conffile could be broken out into individual options and an extraConfig option added. But I think this looks right. Patch by mornfall, slightly modified by me svn path=/nixos/trunk/; revision=30731
This commit is contained in:
parent
508fea8dac
commit
868c60c92b
@ -68,6 +68,7 @@ in
|
||||
dovenull2 = 47;
|
||||
unbound = 48;
|
||||
prayer = 49;
|
||||
mpd = 50;
|
||||
|
||||
# When adding a uid, make sure it doesn't match an existing gid.
|
||||
|
||||
@ -116,6 +117,7 @@ in
|
||||
virtuoso = 44;
|
||||
dovecot2 = 45;
|
||||
prayer = 46;
|
||||
mpd = 47;
|
||||
|
||||
# When adding a gid, make sure it doesn't match an existing uid.
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
./services/audio/alsa.nix
|
||||
./services/audio/fuppes.nix
|
||||
./services/audio/pulseaudio.nix
|
||||
./services/audio/mpd.nix
|
||||
./services/backup/mysql-backup.nix
|
||||
./services/backup/postgresql-backup.nix
|
||||
./services/backup/sitecopy-backup.nix
|
||||
|
99
modules/services/audio/mpd.nix
Normal file
99
modules/services/audio/mpd.nix
Normal file
@ -0,0 +1,99 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
with pkgs.lib;
|
||||
|
||||
let
|
||||
|
||||
uid = config.ids.uids.mpd;
|
||||
gid = config.ids.gids.mpd;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
services.mpd = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable the MPD music player daemon (server).
|
||||
'';
|
||||
};
|
||||
|
||||
conffile = mkOption {
|
||||
default = ''
|
||||
music_directory "${config.services.mpd.dataDir}/music"
|
||||
playlist_directory "${config.services.mpd.dataDir}/playlists"
|
||||
db_file "${config.services.mpd.dataDir}/tag_cache"
|
||||
state_file "${config.services.mpd.dataDir}/state"
|
||||
sticker_file "${config.services.mpd.dataDir}/sticker.sql"
|
||||
log_file "/var/log/mpd.log"
|
||||
pid_file "/var/run/mpd/mpd.pid"
|
||||
bind_to_address "localhost"
|
||||
user "mpd"
|
||||
'';
|
||||
description = ''The contents of the MPD configuration file mpd.conf'';
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
default = "/var/lib/mpd/";
|
||||
example = "debug";
|
||||
description = ''
|
||||
The root directory of the MPD data tree. Contains a tag cache,
|
||||
playlists and a music/ subdirectory that should contain (or
|
||||
symlink to) your music collection.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf config.services.mpd.enable {
|
||||
|
||||
environment.systemPackages = [ pkgs.mpd ];
|
||||
|
||||
users.extraUsers = singleton
|
||||
{ name = "mpd";
|
||||
group = "mpd";
|
||||
extraGroups = [ "audio" ];
|
||||
description = "MPD system-wide daemon";
|
||||
home = "${config.services.mpd.dataDir}";
|
||||
};
|
||||
|
||||
users.extraGroups = singleton
|
||||
{ name = "mpd";
|
||||
inherit gid;
|
||||
};
|
||||
|
||||
jobs.mpd =
|
||||
{ description = "MPD system-wide server";
|
||||
|
||||
startOn = "startup";
|
||||
|
||||
preStart =
|
||||
''
|
||||
mkdir -p /var/run/mpd && chown mpd /var/run/mpd
|
||||
test -d ${config.services.mpd.dataDir} || \
|
||||
( mkdir -p --mode 755 ${config.services.mpd.dataDir}/music \
|
||||
${config.services.mpd.dataDir}/playlists && \
|
||||
chown -R mpd:mpd ${config.services.mpd.dataDir} )
|
||||
'';
|
||||
|
||||
daemonType = "fork";
|
||||
exec =
|
||||
''
|
||||
${pkgs.mpd}/bin/mpd ${pkgs.writeText "mpd.conf" config.services.mpd.conffile}
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user