@@ -1,13 +1,18 @@
1−{ fetchurl, stdenv, dpkg, xorg, alsaLib, makeWrapper, openssl, freetype
1+{ fetchurl, stdenv, squashfsTools, xorg, alsaLib, makeWrapper, openssl, freetype
22, glib, pango, cairo, atk, gdk_pixbuf, gtk2, cups, nspr, nss, libpng
33, libgcrypt, systemd, fontconfig, dbus, expat, ffmpeg_0_10, curl, zlib, gnome3 }:
44
55let
6− # Please update the stable branch!
7− # Latest version number can be found at:
8− # http://repository-origin.spotify.com/pool/non-free/s/spotify-client/
9− # Be careful not to pick the testing version.
10− version = "1.0.80.480.g51b03ac3-13";
6+ # "rev" decides what is actually being downloaded
7+ version = "1.0.80.474.gef6b503e-7";
8+ # To get the latest stable revision:
9+ # curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/spotify?channel=stable' | jq '.download_url,.version,.last_updated'
10+ # To get general information:
11+ # curl -H 'Snap-Device-Series: 16' 'https://api.snapcraft.io/v2/snaps/info/spotify' | jq '.'
12+ # More exapmles of api usage:
13+ # https://github.com/canonical-websites/snapcraft.io/blob/master/webapp/publisher/snaps/views.py
14+ rev = "16";
15+
1116
1217 deps = [
1318 alsaLib
@@ -49,12 +54,20 @@ in
4954stdenv.mkDerivation {
5055 name = "spotify-${version}";
5156
57+ # fetch from snapcraft instead of the debian repository most repos fetch from.
58+ # That is a bit more cumbersome. But the debian repository only keeps the last
59+ # two versions, while snapcraft should provide versions indefinately:
60+ # https://forum.snapcraft.io/t/how-can-a-developer-remove-her-his-app-from-snap-store/512
61+
62+ # This is the next-best thing, since we're not allowed to re-distribute
63+ # spotify ourselves:
64+ # https://community.spotify.com/t5/Desktop-Linux/Redistribute-Spotify-on-Linux-Distributions/td-p/1695334
5265 src = fetchurl {
53− url = "https://repository-origin.spotify.com/pool/non-free/s/spotify-client/spotify-client_${version}_amd64.deb";
54− sha256 = "e32f4816ae79dbfa0c14086e76df3bc83d526402aac1dbba534127fc00fe50ea";
66+ url = "https://api.snapcraft.io/api/v1/snaps/download/pOBIoZ2LrCB3rDohMxoYGnbN14EHOgD7_${rev}.snap";
67+ sha512 = "45b7ab574b30fb368e0b6f4dd60addbfd1ddc02173b4f98b31c524eed49073432352a361e75959ce8e2f752231e93c79ca1b538c4bd295c935d1e2e0585d147f";
5568 };
5669
57− buildInputs = [ dpkg makeWrapper ];
70+ buildInputs = [ squashfsTools makeWrapper ];
5871
5972 doConfigure = false;
6073 doBuild = false;
@@ -63,7 +76,23 @@ stdenv.mkDerivation {
6376
6477 unpackPhase = ''
6578 runHook preUnpack
66− dpkg-deb -x $src .
79+ unsquashfs "$src" '/usr/share/spotify' '/usr/bin/spotify' '/meta/snap.yaml'
80+ cd squashfs-root
81+ if ! grep -q 'grade: stable' meta/snap.yaml; then
82+ # Unfortunately this check is not reliable: At the moment (2018-07-26) the
83+ # latest version in the "edge" channel is also marked as stable.
84+ echo "The snap package is marked as unstable:"
85+ grep 'grade: ' meta/snap.yaml
86+ echo "You probably chose the wrong revision."
87+ exit 1
88+ fi
89+ if ! grep -q '${version}' meta/snap.yaml; then
90+ echo "Package version differs from version found in snap metadata:"
91+ grep 'version: ' meta/snap.yaml
92+ echo "While the nix package specifies: ${version}."
93+ echo "You probably chose the wrong revision or forgot to update the nix version."
94+ exit 1
95+ fi
6796 runHook postUnpack
6897 '';
6998
@@ -75,6 +104,8 @@ stdenv.mkDerivation {
75104 mkdir -p $libdir
76105 mv ./usr/* $out/
77106
107+ cp meta/snap.yaml $out
108+
78109 # Work around Spotify referring to a specific minor version of
79110 # OpenSSL.
80111