about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/libspotify
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-01-07 02:18:36 +0000
committerAlyssa Ross <hi@alyssa.is>2019-01-07 02:18:47 +0000
commit36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch)
treeb3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/libraries/libspotify
parent4e31070265257dc67d120c27e0f75c2344fdfa9a (diff)
parentabf060725d7614bd3b9f96764262dfbc2f9c2199 (diff)
downloadnixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs
git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a
git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libspotify')
-rw-r--r--nixpkgs/pkgs/development/libraries/libspotify/default.nix89
1 files changed, 89 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libspotify/default.nix b/nixpkgs/pkgs/development/libraries/libspotify/default.nix
new file mode 100644
index 000000000000..e472fe014ee7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libspotify/default.nix
@@ -0,0 +1,89 @@
+{ stdenv, fetchurl, libspotify, alsaLib, readline, pkgconfig, apiKey, unzip, gnused }:
+
+let
+  version = "12.1.51";
+  isLinux = (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "i686-linux");
+in
+
+if (stdenv.hostPlatform.system != "x86_64-linux" && stdenv.hostPlatform.system != "x86_64-darwin" && stdenv.hostPlatform.system != "i686-linux")
+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 =
+    if stdenv.hostPlatform.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.hostPlatform.system == "x86_64-darwin" then
+      fetchurl {
+        url    = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Darwin-universal.zip";
+        sha256 = "1gcgrc8arim3hnszcc886lmcdb4iigc08abkaa02l6gng43ky1c0";
+      }
+    else if stdenv.hostPlatform.system == "i686-linux" then
+      fetchurl {
+        url    = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Linux-i686-release.tar.gz";
+        sha256 = "1bjmn64gbr4p9irq426yap4ipq9rb84zsyhjjr7frmmw22xb86ll";
+      }
+    else
+      null;
+
+  dontBuild = true;
+
+  installPhase = if (isLinux)
+    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.hostPlatform.system == "x86_64-darwin") unzip;
+
+  # linux-specific
+  installFlags = stdenv.lib.optionalString (isLinux)
+    "prefix=$(out)";
+  patchPhase = stdenv.lib.optionalString (isLinux)
+    "${gnused}/bin/sed -i 's/ldconfig//' Makefile";
+  postInstall = stdenv.lib.optionalString (isLinux)
+    "mv -v share $out";
+
+  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 {
+        name = "libspotify-samples-${version}";
+        src = libspotify.src;
+  nativeBuildInputs = [ pkgconfig ];
+        buildInputs = [ 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 = with stdenv.lib; {
+    description = "Spotify API library";
+    homepage    = https://developer.spotify.com/technologies/libspotify;
+    maintainers = with maintainers; [ lovek323 ];
+    license     = licenses.unfree;
+  };
+}