spotify: support --force-device-scale-factor

Add a Spotify wrapper with a `deviceScaleFactor` argument to set the
`--force-device-scale-factor` flag for high-DPI displays. If unset,
nothing is added.

This allows e.g.

spotify.override { deviceScaleFactor = 1.66; }

Uses a separate wrapper derivation as suggested by @Ma27.
Uses `wrapProgram` instead of `makeWrapper` as suggested by @Ma27.

+35 -2
+1 -1
pkgs/applications/audio/spotify/default.nix
··· 64 in 65 66 stdenv.mkDerivation { 67 - pname = "spotify"; 68 inherit version; 69 70 # fetch from snapcraft instead of the debian repository most repos fetch from.
··· 64 in 65 66 stdenv.mkDerivation { 67 + pname = "spotify-unwrapped"; 68 inherit version; 69 70 # fetch from snapcraft instead of the debian repository most repos fetch from.
+31
pkgs/applications/audio/spotify/wrapper.nix
···
··· 1 + { symlinkJoin 2 + , lib 3 + , spotify-unwrapped 4 + , makeWrapper 5 + 6 + # High-DPI support: Spotify's --force-device-scale-factor argument; not added 7 + # if `null`, otherwise, should be a number. 8 + , deviceScaleFactor ? null 9 + }: 10 + 11 + symlinkJoin { 12 + name = "spotify-${spotify-unwrapped.version}"; 13 + 14 + paths = [ spotify-unwrapped.out ]; 15 + 16 + nativeBuildInputs = [ makeWrapper ]; 17 + preferLocalBuild = true; 18 + passthru.unwrapped = spotify-unwrapped; 19 + postBuild = '' 20 + wrapProgram $out/bin/spotify \ 21 + ${lib.optionalString (deviceScaleFactor != null) '' 22 + --add-flags ${lib.escapeShellArg "--force-device-scale-factor=${ 23 + builtins.toString deviceScaleFactor 24 + }"} 25 + ''} 26 + ''; 27 + 28 + meta = spotify-unwrapped.meta // { 29 + priority = (spotify-unwrapped.meta.priority or 0) - 1; 30 + }; 31 + }
+3 -1
pkgs/top-level/all-packages.nix
··· 23326 23327 spek = callPackage ../applications/audio/spek { }; 23328 23329 - spotify = callPackage ../applications/audio/spotify { 23330 libgcrypt = libgcrypt_1_5; 23331 libpng = libpng12; 23332 curl = curl.override { 23333 sslSupport = false; gnutlsSupport = true; 23334 }; 23335 }; 23336 23337 libspotify = callPackage ../development/libraries/libspotify (config.libspotify or {}); 23338
··· 23326 23327 spek = callPackage ../applications/audio/spek { }; 23328 23329 + spotify-unwrapped = callPackage ../applications/audio/spotify { 23330 libgcrypt = libgcrypt_1_5; 23331 libpng = libpng12; 23332 curl = curl.override { 23333 sslSupport = false; gnutlsSupport = true; 23334 }; 23335 }; 23336 + 23337 + spotify = callPackage ../applications/audio/spotify/wrapper.nix { }; 23338 23339 libspotify = callPackage ../development/libraries/libspotify (config.libspotify or {}); 23340