summary refs log tree commit diff
path: root/pkgs/development/libraries/libspotify
diff options
context:
space:
mode:
authorJason "Don" O'Conal <lovek323@gmail.com>2013-07-04 19:12:26 +1000
committerJason "Don" O'Conal <lovek323@gmail.com>2013-07-04 19:12:26 +1000
commitcf3364bdb634380ad7f190e085946874f4f16064 (patch)
treeddcfdcb94c56b8d0bd3ad888321a1e245bc662be /pkgs/development/libraries/libspotify
parent9e98650f8d32ed25fe04de141f17391490a1477d (diff)
downloadnixpkgs-cf3364bdb634380ad7f190e085946874f4f16064.tar
nixpkgs-cf3364bdb634380ad7f190e085946874f4f16064.tar.gz
nixpkgs-cf3364bdb634380ad7f190e085946874f4f16064.tar.bz2
nixpkgs-cf3364bdb634380ad7f190e085946874f4f16064.tar.lz
nixpkgs-cf3364bdb634380ad7f190e085946874f4f16064.tar.xz
nixpkgs-cf3364bdb634380ad7f190e085946874f4f16064.tar.zst
nixpkgs-cf3364bdb634380ad7f190e085946874f4f16064.zip
libspotify: add darwin library
Diffstat (limited to 'pkgs/development/libraries/libspotify')
-rw-r--r--pkgs/development/libraries/libspotify/default.nix83
1 files changed, 53 insertions, 30 deletions
diff --git a/pkgs/development/libraries/libspotify/default.nix b/pkgs/development/libraries/libspotify/default.nix
index 1972a4be653..86007920d0e 100644
--- a/pkgs/development/libraries/libspotify/default.nix
+++ b/pkgs/development/libraries/libspotify/default.nix
@@ -1,25 +1,56 @@
-{ stdenv, fetchurl, libspotify, alsaLib, readline, pkgconfig, apiKey }:
+{ stdenv, fetchurl, libspotify, alsaLib, readline, pkgconfig, apiKey, unzip }:
 
 let version = "12.1.51"; in
 
-if stdenv.system != "x86_64-linux" then throw ''
-  Check https://developer.spotify.com/technologies/libspotify/ for a tarball for your system and add it here
-'' else stdenv.mkDerivation {
+if (stdenv.system == "x86_64-linux" && stdenv.system != "x86_64-darwin")
+then throw "Check https://developer.spotify.com/technologies/libspotify/ for a tarball for your system and add it here"
+else stdenv.mkDerivation {
   name = "libspotify-${version}";
 
-  src = fetchurl {
-    url = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Linux-x86_64-release.tar.gz";
-
-    sha256 = "0n0h94i4xg46hfba95n3ypah93crwb80bhgsg00f6sms683lx8a3";
-  };
-
+  src =
+    if stdenv.system == "x86_64-linux" then
+      fetchurl {
+        url    = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Linux-x86_64-release.tar.gz";
+        sha256 = "0n0h94i4xg46hfba95n3ypah93crwb80bhgsg00f6sms683lx8a3";
+      }
+    else if stdenv.system == "x86_64-darwin" then
+      fetchurl {
+        url    = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Darwin-universal.zip";
+        sha256 = "1gcgrc8arim3hnszcc886lmcdb4iigc08abkaa02l6gng43ky1c0";
+      }
+    else
+      null;
+
+  # common
   buildPhase = "true";
-
-  installFlags = "prefix=$(out)";
-
-  postInstall = "mv -v share $out";
-
-  patchPhase = "sed -i 's/ldconfig//' Makefile";
+  # no patch or build phase for darwin
+  phases = [ "unpackPhase" "installPhase" ]
+    ++ stdenv.lib.optionals (stdenv.system == "x86_64-linux")
+      [ "patchPhase" "buildPhase" ];
+  installPhase = if (stdenv.system == "x86_64-linux")
+    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
+    '';
+ 
+
+  # darwin-specific
+  buildInputs = stdenv.lib.optional (stdenv.system == "x86_64-darwin") unzip;
+
+  # linux-specific
+  installFlags = stdenv.lib.optionalString (stdenv.system == "x86_64-linux")
+    "prefix=$(out)";
+  patchPhase = stdenv.lib.optionalString (stdenv.system == "x86_64-linux")
+    "sed -i 's/ldconfig//' Makefile";
+  postInstall = stdenv.lib.optionalString (stdenv.system == "x86_64-linux")
+    "mv -v share $out";
 
   passthru = {
     samples = if apiKey == null
@@ -27,35 +58,27 @@ if stdenv.system != "x86_64-linux" then throw ''
         Please visit ${libspotify.meta.homepage} to get an api key then set config.libspotify.apiKey accordingly
       '' else stdenv.mkDerivation {
         name = "libspotify-samples-${version}";
-
         src = libspotify.src;
-
-        buildInputs = [ pkgconfig libspotify alsaLib readline ];
-
+        buildInputs = [ pkgconfig libspotify readline ]
+          ++ stdenv.lib.optional (!stdenv.isDarwin) alsaLib;
         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;
   };
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Spotify API library";
-
-    homepage = https://developer.spotify.com/technologies/libspotify;
-
-    maintainers = [ stdenv.lib.maintainers.shlevy ];
-
-    license = stdenv.lib.licenses.unfree;
+    homepage    = https://developer.spotify.com/technologies/libspotify;
+    maintainers = with maintainers; [ lovek323 shlevy ];
+    license     = licenses.unfree;
   };
 }