aboutsummaryrefslogtreecommitdiff
path: root/nixops
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-04-20 17:02:18 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-04-22 18:34:18 +0200
commit65e649254aa406277f5e8b99adf1114e6ac373ca (patch)
treeb51839ed7774c3a08af9788c24837887577461af /nixops
parent42fa50f1fa75f62c6e9cada076860196e8185641 (diff)
downloadNix-65e649254aa406277f5e8b99adf1114e6ac373ca.tar.gz
Nix-65e649254aa406277f5e8b99adf1114e6ac373ca.tar.zst
Nix-65e649254aa406277f5e8b99adf1114e6ac373ca.zip
Upgrade MPD to 0.21.7, and move mpd secrets to secure location
Fixes https://git.immae.eu/mantisbt/view.php?id=122
Diffstat (limited to 'nixops')
-rw-r--r--nixops/modules/mpd/default.nix15
-rw-r--r--nixops/modules/mpd/mpd.nix152
2 files changed, 165 insertions, 2 deletions
diff --git a/nixops/modules/mpd/default.nix b/nixops/modules/mpd/default.nix
index d59a34c..9e1715b 100644
--- a/nixops/modules/mpd/default.nix
+++ b/nixops/modules/mpd/default.nix
@@ -1,20 +1,31 @@
1{ lib, pkgs, config, myconfig, mylibs, ... }: 1{ lib, pkgs, config, myconfig, mylibs, ... }:
2{ 2{
3 config = { 3 config = {
4 nixpkgs.overlays = [ (self: super: rec {
5 mpd = (self.callPackage ./mpd.nix {}).mpd;
6 }) ];
4 deployment.keys = { 7 deployment.keys = {
5 mpd = { 8 mpd = {
6 permissions = "0400"; 9 permissions = "0400";
7 text = myconfig.env.mpd.password; 10 text = myconfig.env.mpd.password;
8 }; 11 };
12 mpd-config = {
13 permissions = "0400";
14 user = "mpd";
15 group = "mpd";
16 text = ''
17 password "${myconfig.env.mpd.password}@read,add,control,admin"
18 '';
19 };
9 }; 20 };
10 networking.firewall.allowedTCPPorts = [ 6600 ]; 21 networking.firewall.allowedTCPPorts = [ 6600 ];
11 users.users.mpd.extraGroups = [ "wwwrun" ]; 22 users.users.mpd.extraGroups = [ "wwwrun" "keys" ];
12 services.mpd = { 23 services.mpd = {
13 enable = true; 24 enable = true;
14 network.listenAddress = "any"; 25 network.listenAddress = "any";
15 musicDirectory = myconfig.env.mpd.folder; 26 musicDirectory = myconfig.env.mpd.folder;
16 extraConfig = '' 27 extraConfig = ''
17 password "${myconfig.env.mpd.password}@read,add,control,admin" 28 include "/run/keys/mpd-config"
18 audio_output { 29 audio_output {
19 type "null" 30 type "null"
20 name "No Output" 31 name "No Output"
diff --git a/nixops/modules/mpd/mpd.nix b/nixops/modules/mpd/mpd.nix
new file mode 100644
index 0000000..f19a76f
--- /dev/null
+++ b/nixops/modules/mpd/mpd.nix
@@ -0,0 +1,152 @@
1{ stdenv, fetchFromGitHub, meson, ninja, pkgconfig, glib, systemd, boost, darwin
2# Inputs
3, curl, libmms, libnfs, samba
4# Archive support
5, bzip2, zziplib
6# Codecs
7, audiofile, faad2, ffmpeg, flac, fluidsynth, game-music-emu
8, libmad, libmikmod, mpg123, libopus, libvorbis, lame
9# Filters
10, libsamplerate
11# Outputs
12, alsaLib, libjack2, libpulseaudio, libshout
13# Misc
14, icu, sqlite, avahi, dbus, pcre, libgcrypt, expat
15# Services
16, yajl
17# Client support
18, mpd_clientlib
19# Tag support
20, libid3tag
21}:
22
23let
24 major = "0.21";
25 minor = "7";
26
27 lib = stdenv.lib;
28 mkDisable = f: "-D${f}=disabled";
29 mkEnable = f: "-D${f}=enabled";
30 keys = lib.mapAttrsToList (k: v: k);
31
32 featureDependencies = {
33 # Storage plugins
34 udisks = [ dbus ];
35 webdav = [ curl expat ];
36 # Input plugins
37 curl = [ curl ];
38 mms = [ libmms ];
39 nfs = [ libnfs ];
40 smbclient = [ samba ];
41 # Archive support
42 bzip2 = [ bzip2 ];
43 zzip = [ zziplib ];
44 # Decoder plugins
45 audiofile = [ audiofile ];
46 faad = [ faad2 ];
47 ffmpeg = [ ffmpeg ];
48 flac = [ flac ];
49 fluidsynth = [ fluidsynth ];
50 gme = [ game-music-emu ];
51 mad = [ libmad ];
52 mikmod = [ libmikmod ];
53 mpg123 = [ mpg123 ];
54 opus = [ libopus ];
55 vorbis = [ libvorbis ];
56 # Encoder plugins
57 vorbisenc = [ libvorbis ];
58 lame = [ lame ];
59 # Filter plugins
60 libsamplerate = [ libsamplerate ];
61 # Output plugins
62 alsa = [ alsaLib ];
63 jack = [ libjack2 ];
64 pulse = [ libpulseaudio ];
65 shout = [ libshout ];
66 # Commercial services
67 qobuz = [ curl libgcrypt yajl ];
68 soundcloud = [ curl yajl ];
69 tidal = [ curl yajl ];
70 # Client support
71 libmpdclient = [ mpd_clientlib ];
72 # Tag support
73 id3tag = [ libid3tag ];
74 # Misc
75 dbus = [ dbus ];
76 expat = [ expat ];
77 icu = [ icu ];
78 pcre = [ pcre ];
79 sqlite = [ sqlite ];
80 systemd = [ systemd ];
81 yajl = [ yajl ];
82 zeroconf = [ avahi dbus ];
83 };
84
85 run = { features ? null }:
86 let
87 fl = if (features == null )
88 then keys featureDependencies
89 else features;
90
91 # Disable platform specific features if needed
92 # using libmad to decode mp3 files on darwin is causing a segfault -- there
93 # is probably a solution, but I'm disabling it for now
94 platformMask = lib.optionals stdenv.isDarwin [ "mad" "pulse" "jack" "nfs" "smb" ]
95 ++ lib.optionals (!stdenv.isLinux) [ "alsa" "systemd" ];
96 features_ = lib.subtractLists platformMask fl;
97
98 in stdenv.mkDerivation rec {
99 name = "mpd-${version}";
100 version = "${major}${if minor == "" then "" else "." + minor}";
101
102 src = fetchFromGitHub {
103 owner = "MusicPlayerDaemon";
104 repo = "MPD";
105 rev = "v${version}";
106 sha256 = "11zi8hmlj63ngzl06vzx05669k20j4cdsp0caz4p4ayn46fd4m17";
107 };
108
109 buildInputs = [ glib boost ]
110 ++ (lib.concatLists (lib.attrVals features_ featureDependencies))
111 ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.AudioToolbox;
112
113 nativeBuildInputs = [ meson ninja pkgconfig ];
114
115 enableParallelBuilding = true;
116
117 mesonFlags =
118 map mkEnable features_ ++ map mkDisable (lib.subtractLists features_ (keys featureDependencies))
119 ++ [ "-Dsyslog=enabled" ]
120 ++ lib.optional (lib.any (x: x == "zeroconf") features_)
121 "-Dzeroconf=avahi"
122 ++ lib.optional stdenv.isLinux
123 "-Dsystemd_system_unit_dir=etc/systemd/system";
124
125 meta = with stdenv.lib; {
126 description = "A flexible, powerful daemon for playing music";
127 homepage = http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki;
128 license = licenses.gpl2;
129 maintainers = with maintainers; [ astsmtl fuuzetsu ehmry fpletz ];
130 platforms = platforms.unix;
131
132 longDescription = ''
133 Music Player Daemon (MPD) is a flexible, powerful daemon for playing
134 music. Through plugins and libraries it can play a variety of sound
135 files while being controlled by its network protocol.
136 '';
137 };
138 };
139in
140{
141 mpd = run { };
142 mpd-small = run { features = [
143 "webdav" "curl" "mms" "nfs" "bzip2" "zzip"
144 "audiofile" "faad" "flac" "gme" "mad"
145 "mpg123" "opus" "vorbis"
146 "vorbisenc" "lame" "libsamplerate"
147 "alsa" "shout" "libmpdclient"
148 "id3tag" "expat" "pcre" "yajl" "sqlite"
149 "soundcloud" "qobuz" "tidal"
150 "systemd"
151 ]; };
152}