Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-18.03 89 lines 3.2 kB view raw
1{ stdenv, fetchurl, libspotify, alsaLib, readline, pkgconfig, apiKey, unzip, gnused }: 2 3let 4 version = "12.1.51"; 5 isLinux = (stdenv.system == "x86_64-linux" || stdenv.system == "i686-linux"); 6in 7 8if (stdenv.system != "x86_64-linux" && stdenv.system != "x86_64-darwin" && stdenv.system != "i686-linux") 9then throw "Check https://developer.spotify.com/technologies/libspotify/ for a tarball for your system and add it here" 10else stdenv.mkDerivation { 11 name = "libspotify-${version}"; 12 13 src = 14 if stdenv.system == "x86_64-linux" then 15 fetchurl { 16 url = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Linux-x86_64-release.tar.gz"; 17 sha256 = "0n0h94i4xg46hfba95n3ypah93crwb80bhgsg00f6sms683lx8a3"; 18 } 19 else if stdenv.system == "x86_64-darwin" then 20 fetchurl { 21 url = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Darwin-universal.zip"; 22 sha256 = "1gcgrc8arim3hnszcc886lmcdb4iigc08abkaa02l6gng43ky1c0"; 23 } 24 else if stdenv.system == "i686-linux" then 25 fetchurl { 26 url = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Linux-i686-release.tar.gz"; 27 sha256 = "1bjmn64gbr4p9irq426yap4ipq9rb84zsyhjjr7frmmw22xb86ll"; 28 } 29 else 30 null; 31 32 dontBuild = true; 33 34 installPhase = if (isLinux) 35 then "installPhase" 36 else '' 37 mkdir -p "$out"/include/libspotify 38 mv -v libspotify.framework/Versions/Current/Headers/api.h \ 39 "$out"/include/libspotify 40 mkdir -p "$out"/lib 41 mv -v libspotify.framework/Versions/Current/libspotify \ 42 "$out"/lib/libspotify.dylib 43 mkdir -p "$out"/share/man 44 mv -v man3 "$out"/share/man 45 ''; 46 47 48 # darwin-specific 49 buildInputs = stdenv.lib.optional (stdenv.system == "x86_64-darwin") unzip; 50 51 # linux-specific 52 installFlags = stdenv.lib.optionalString (isLinux) 53 "prefix=$(out)"; 54 patchPhase = stdenv.lib.optionalString (isLinux) 55 "${gnused}/bin/sed -i 's/ldconfig//' Makefile"; 56 postInstall = stdenv.lib.optionalString (isLinux) 57 "mv -v share $out"; 58 59 passthru = { 60 samples = if apiKey == null 61 then throw '' 62 Please visit ${libspotify.meta.homepage} to get an api key then set config.libspotify.apiKey accordingly 63 '' else stdenv.mkDerivation { 64 name = "libspotify-samples-${version}"; 65 src = libspotify.src; 66 nativeBuildInputs = [ pkgconfig ]; 67 buildInputs = [ libspotify readline ] 68 ++ stdenv.lib.optional (!stdenv.isDarwin) alsaLib; 69 postUnpack = "sourceRoot=$sourceRoot/share/doc/libspotify/examples"; 70 patchPhase = "cp ${apiKey} appkey.c"; 71 installPhase = '' 72 mkdir -p $out/bin 73 install -m 755 jukebox/jukebox $out/bin 74 install -m 755 spshell/spshell $out/bin 75 install -m 755 localfiles/posix_stu $out/bin 76 ''; 77 meta = libspotify.meta // { description = "Spotify API library samples"; }; 78 }; 79 80 inherit apiKey; 81 }; 82 83 meta = with stdenv.lib; { 84 description = "Spotify API library"; 85 homepage = https://developer.spotify.com/technologies/libspotify; 86 maintainers = with maintainers; [ lovek323 ]; 87 license = licenses.unfree; 88 }; 89}