git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit4f03644c56ddd8c57bec062d3de79ec13887a0be authorRebecca Turner <rbt@sent.as> dateSun 20 Sep 2020, 17:37 (6 years ago) parent41e883a
3 files changed+35−2
pkgs/applications/audio/spotify/default.nix+1−1 pkgs/applications/audio/spotify/wrapper.nix+31 pkgs/top-level/all-packages.nix+3−1
pkgs/applications/audio/spotify/default.nix+1−1
@@ -64,7 +64,7 @@ let
6464in
6565
6666stdenv.mkDerivation {
67− pname = "spotify";
67+ pname = "spotify-unwrapped";
6868 inherit version;
6969
7070 # fetch from snapcraft instead of the debian repository most repos fetch from.
pkgs/applications/audio/spotify/wrapper.nixnew file+31
@@ -0,0 +1,31 @@
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+}
pkgs/top-level/all-packages.nix+3−1
@@ -23326,7 +23326,7 @@ in
2332623326
2332723327 spek = callPackage ../applications/audio/spek { };
2332823328
23329− spotify = callPackage ../applications/audio/spotify {
23329+ spotify-unwrapped = callPackage ../applications/audio/spotify {
2333023330 libgcrypt = libgcrypt_1_5;
2333123331 libpng = libpng12;
2333223332 curl = curl.override {
@@ -23334,6 +23334,8 @@ in
2333423334 };
2333523335 };
2333623336
23337+ spotify = callPackage ../applications/audio/spotify/wrapper.nix { };
23338+
2333723339 libspotify = callPackage ../development/libraries/libspotify (config.libspotify or {});
2333823340
2333923341 sourcetrail = callPackage ../development/tools/sourcetrail { };