From: Ismaƫl Bouya Date: Sat, 20 Apr 2019 15:02:18 +0000 (+0200) Subject: Upgrade MPD to 0.21.7, and move mpd secrets to secure location X-Git-Tag: nur_publish~119 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=commitdiff_plain;h=65e649254aa406277f5e8b99adf1114e6ac373ca Upgrade MPD to 0.21.7, and move mpd secrets to secure location Fixes https://git.immae.eu/mantisbt/view.php?id=122 --- 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 @@ { lib, pkgs, config, myconfig, mylibs, ... }: { config = { + nixpkgs.overlays = [ (self: super: rec { + mpd = (self.callPackage ./mpd.nix {}).mpd; + }) ]; deployment.keys = { mpd = { permissions = "0400"; text = myconfig.env.mpd.password; }; + mpd-config = { + permissions = "0400"; + user = "mpd"; + group = "mpd"; + text = '' + password "${myconfig.env.mpd.password}@read,add,control,admin" + ''; + }; }; networking.firewall.allowedTCPPorts = [ 6600 ]; - users.users.mpd.extraGroups = [ "wwwrun" ]; + users.users.mpd.extraGroups = [ "wwwrun" "keys" ]; services.mpd = { enable = true; network.listenAddress = "any"; musicDirectory = myconfig.env.mpd.folder; extraConfig = '' - password "${myconfig.env.mpd.password}@read,add,control,admin" + include "/run/keys/mpd-config" audio_output { type "null" 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 @@ +{ stdenv, fetchFromGitHub, meson, ninja, pkgconfig, glib, systemd, boost, darwin +# Inputs +, curl, libmms, libnfs, samba +# Archive support +, bzip2, zziplib +# Codecs +, audiofile, faad2, ffmpeg, flac, fluidsynth, game-music-emu +, libmad, libmikmod, mpg123, libopus, libvorbis, lame +# Filters +, libsamplerate +# Outputs +, alsaLib, libjack2, libpulseaudio, libshout +# Misc +, icu, sqlite, avahi, dbus, pcre, libgcrypt, expat +# Services +, yajl +# Client support +, mpd_clientlib +# Tag support +, libid3tag +}: + +let + major = "0.21"; + minor = "7"; + + lib = stdenv.lib; + mkDisable = f: "-D${f}=disabled"; + mkEnable = f: "-D${f}=enabled"; + keys = lib.mapAttrsToList (k: v: k); + + featureDependencies = { + # Storage plugins + udisks = [ dbus ]; + webdav = [ curl expat ]; + # Input plugins + curl = [ curl ]; + mms = [ libmms ]; + nfs = [ libnfs ]; + smbclient = [ samba ]; + # Archive support + bzip2 = [ bzip2 ]; + zzip = [ zziplib ]; + # Decoder plugins + audiofile = [ audiofile ]; + faad = [ faad2 ]; + ffmpeg = [ ffmpeg ]; + flac = [ flac ]; + fluidsynth = [ fluidsynth ]; + gme = [ game-music-emu ]; + mad = [ libmad ]; + mikmod = [ libmikmod ]; + mpg123 = [ mpg123 ]; + opus = [ libopus ]; + vorbis = [ libvorbis ]; + # Encoder plugins + vorbisenc = [ libvorbis ]; + lame = [ lame ]; + # Filter plugins + libsamplerate = [ libsamplerate ]; + # Output plugins + alsa = [ alsaLib ]; + jack = [ libjack2 ]; + pulse = [ libpulseaudio ]; + shout = [ libshout ]; + # Commercial services + qobuz = [ curl libgcrypt yajl ]; + soundcloud = [ curl yajl ]; + tidal = [ curl yajl ]; + # Client support + libmpdclient = [ mpd_clientlib ]; + # Tag support + id3tag = [ libid3tag ]; + # Misc + dbus = [ dbus ]; + expat = [ expat ]; + icu = [ icu ]; + pcre = [ pcre ]; + sqlite = [ sqlite ]; + systemd = [ systemd ]; + yajl = [ yajl ]; + zeroconf = [ avahi dbus ]; + }; + + run = { features ? null }: + let + fl = if (features == null ) + then keys featureDependencies + else features; + + # Disable platform specific features if needed + # using libmad to decode mp3 files on darwin is causing a segfault -- there + # is probably a solution, but I'm disabling it for now + platformMask = lib.optionals stdenv.isDarwin [ "mad" "pulse" "jack" "nfs" "smb" ] + ++ lib.optionals (!stdenv.isLinux) [ "alsa" "systemd" ]; + features_ = lib.subtractLists platformMask fl; + + in stdenv.mkDerivation rec { + name = "mpd-${version}"; + version = "${major}${if minor == "" then "" else "." + minor}"; + + src = fetchFromGitHub { + owner = "MusicPlayerDaemon"; + repo = "MPD"; + rev = "v${version}"; + sha256 = "11zi8hmlj63ngzl06vzx05669k20j4cdsp0caz4p4ayn46fd4m17"; + }; + + buildInputs = [ glib boost ] + ++ (lib.concatLists (lib.attrVals features_ featureDependencies)) + ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.AudioToolbox; + + nativeBuildInputs = [ meson ninja pkgconfig ]; + + enableParallelBuilding = true; + + mesonFlags = + map mkEnable features_ ++ map mkDisable (lib.subtractLists features_ (keys featureDependencies)) + ++ [ "-Dsyslog=enabled" ] + ++ lib.optional (lib.any (x: x == "zeroconf") features_) + "-Dzeroconf=avahi" + ++ lib.optional stdenv.isLinux + "-Dsystemd_system_unit_dir=etc/systemd/system"; + + meta = with stdenv.lib; { + description = "A flexible, powerful daemon for playing music"; + homepage = http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki; + license = licenses.gpl2; + maintainers = with maintainers; [ astsmtl fuuzetsu ehmry fpletz ]; + platforms = platforms.unix; + + longDescription = '' + Music Player Daemon (MPD) is a flexible, powerful daemon for playing + music. Through plugins and libraries it can play a variety of sound + files while being controlled by its network protocol. + ''; + }; + }; +in +{ + mpd = run { }; + mpd-small = run { features = [ + "webdav" "curl" "mms" "nfs" "bzip2" "zzip" + "audiofile" "faad" "flac" "gme" "mad" + "mpg123" "opus" "vorbis" + "vorbisenc" "lame" "libsamplerate" + "alsa" "shout" "libmpdclient" + "id3tag" "expat" "pcre" "yajl" "sqlite" + "soundcloud" "qobuz" "tidal" + "systemd" + ]; }; +}