2019-02-03 15:30:21 +00:00
|
|
|
{ stdenv, fetchurl, libspotify, alsaLib, readline, pkgconfig, apiKey ? null, unzip, gnused }:
|
2013-01-25 06:10:36 +00:00
|
|
|
|
2016-05-04 11:08:35 +01:00
|
|
|
let
|
|
|
|
version = "12.1.51";
|
2018-08-20 20:11:29 +01:00
|
|
|
isLinux = (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "i686-linux");
|
2015-06-24 00:54:59 +01:00
|
|
|
in
|
2013-01-25 06:10:36 +00:00
|
|
|
|
2018-08-20 20:11:29 +01:00
|
|
|
if (stdenv.hostPlatform.system != "x86_64-linux" && stdenv.hostPlatform.system != "x86_64-darwin" && stdenv.hostPlatform.system != "i686-linux")
|
2013-07-04 10:12:26 +01:00
|
|
|
then throw "Check https://developer.spotify.com/technologies/libspotify/ for a tarball for your system and add it here"
|
|
|
|
else stdenv.mkDerivation {
|
2019-08-13 22:52:01 +01:00
|
|
|
pname = "libspotify";
|
|
|
|
inherit version;
|
2013-01-25 06:10:36 +00:00
|
|
|
|
2013-07-04 10:12:26 +01:00
|
|
|
src =
|
2018-08-20 20:11:29 +01:00
|
|
|
if stdenv.hostPlatform.system == "x86_64-linux" then
|
2013-07-04 10:12:26 +01:00
|
|
|
fetchurl {
|
|
|
|
url = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Linux-x86_64-release.tar.gz";
|
|
|
|
sha256 = "0n0h94i4xg46hfba95n3ypah93crwb80bhgsg00f6sms683lx8a3";
|
|
|
|
}
|
2018-08-20 20:11:29 +01:00
|
|
|
else if stdenv.hostPlatform.system == "x86_64-darwin" then
|
2013-07-04 10:12:26 +01:00
|
|
|
fetchurl {
|
|
|
|
url = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Darwin-universal.zip";
|
|
|
|
sha256 = "1gcgrc8arim3hnszcc886lmcdb4iigc08abkaa02l6gng43ky1c0";
|
|
|
|
}
|
2018-08-20 20:11:29 +01:00
|
|
|
else if stdenv.hostPlatform.system == "i686-linux" then
|
2015-06-24 00:54:59 +01:00
|
|
|
fetchurl {
|
|
|
|
url = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Linux-i686-release.tar.gz";
|
|
|
|
sha256 = "1bjmn64gbr4p9irq426yap4ipq9rb84zsyhjjr7frmmw22xb86ll";
|
|
|
|
}
|
2013-07-04 10:12:26 +01:00
|
|
|
else
|
|
|
|
null;
|
|
|
|
|
2016-05-04 11:08:35 +01:00
|
|
|
dontBuild = true;
|
|
|
|
|
2015-06-24 00:54:59 +01:00
|
|
|
installPhase = if (isLinux)
|
2013-07-04 10:12:26 +01:00
|
|
|
then "installPhase"
|
|
|
|
else ''
|
|
|
|
mkdir -p "$out"/include/libspotify
|
|
|
|
mv -v libspotify.framework/Versions/Current/Headers/api.h \
|
|
|
|
"$out"/include/libspotify
|
|
|
|
mkdir -p "$out"/lib
|
|
|
|
mv -v libspotify.framework/Versions/Current/libspotify \
|
|
|
|
"$out"/lib/libspotify.dylib
|
|
|
|
mkdir -p "$out"/share/man
|
|
|
|
mv -v man3 "$out"/share/man
|
|
|
|
'';
|
2016-05-04 11:08:35 +01:00
|
|
|
|
2013-07-04 10:12:26 +01:00
|
|
|
|
|
|
|
# darwin-specific
|
2018-08-20 20:11:29 +01:00
|
|
|
buildInputs = stdenv.lib.optional (stdenv.hostPlatform.system == "x86_64-darwin") unzip;
|
2013-07-04 10:12:26 +01:00
|
|
|
|
|
|
|
# linux-specific
|
2015-06-24 00:54:59 +01:00
|
|
|
installFlags = stdenv.lib.optionalString (isLinux)
|
2013-07-04 10:12:26 +01:00
|
|
|
"prefix=$(out)";
|
2015-06-24 00:54:59 +01:00
|
|
|
patchPhase = stdenv.lib.optionalString (isLinux)
|
2013-07-22 15:28:33 +01:00
|
|
|
"${gnused}/bin/sed -i 's/ldconfig//' Makefile";
|
2015-06-24 00:54:59 +01:00
|
|
|
postInstall = stdenv.lib.optionalString (isLinux)
|
2013-07-04 10:12:26 +01:00
|
|
|
"mv -v share $out";
|
2013-01-25 06:10:36 +00:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
samples = if apiKey == null
|
|
|
|
then throw ''
|
|
|
|
Please visit ${libspotify.meta.homepage} to get an api key then set config.libspotify.apiKey accordingly
|
|
|
|
'' else stdenv.mkDerivation {
|
2019-08-13 22:52:01 +01:00
|
|
|
pname = "libspotify-samples";
|
|
|
|
inherit version;
|
2013-01-25 06:10:36 +00:00
|
|
|
src = libspotify.src;
|
2017-09-05 22:26:13 +01:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
|
|
buildInputs = [ libspotify readline ]
|
2013-07-04 10:12:26 +01:00
|
|
|
++ stdenv.lib.optional (!stdenv.isDarwin) alsaLib;
|
2013-01-25 06:10:36 +00:00
|
|
|
postUnpack = "sourceRoot=$sourceRoot/share/doc/libspotify/examples";
|
|
|
|
patchPhase = "cp ${apiKey} appkey.c";
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
install -m 755 jukebox/jukebox $out/bin
|
|
|
|
install -m 755 spshell/spshell $out/bin
|
|
|
|
install -m 755 localfiles/posix_stu $out/bin
|
|
|
|
'';
|
|
|
|
meta = libspotify.meta // { description = "Spotify API library samples"; };
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit apiKey;
|
|
|
|
};
|
|
|
|
|
2013-07-04 10:12:26 +01:00
|
|
|
meta = with stdenv.lib; {
|
2013-01-25 06:10:36 +00:00
|
|
|
description = "Spotify API library";
|
2013-07-04 10:12:26 +01:00
|
|
|
homepage = https://developer.spotify.com/technologies/libspotify;
|
2014-02-03 23:38:01 +00:00
|
|
|
maintainers = with maintainers; [ lovek323 ];
|
2013-07-04 10:12:26 +01:00
|
|
|
license = licenses.unfree;
|
2013-01-25 06:10:36 +00:00
|
|
|
};
|
|
|
|
}
|