about summary refs log tree commit diff
path: root/pkgs/applications/audio/spotify-tui
diff options
context:
space:
mode:
authorMoritz Böhme <mail@moritzboeh.me>2022-04-29 15:42:13 +0200
committerMoritz Böhme <mail@moritzboeh.me>2022-07-08 13:49:36 +0200
commit54b7074d065bedda4f073cea2e4d73fa0acc51ef (patch)
treec8a5e5e773d2f7631ad41458682ae4d19bd8d63e /pkgs/applications/audio/spotify-tui
parent0fe250c8f35d6ac1210ac2696754f37a336d7f82 (diff)
spotify-tui: add collection variant patch
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Diffstat (limited to 'pkgs/applications/audio/spotify-tui')
-rw-r--r--pkgs/applications/audio/spotify-tui/0001-Add-Collection-SearchType.patch41
-rw-r--r--pkgs/applications/audio/spotify-tui/Cargo.lock.patch11
-rw-r--r--pkgs/applications/audio/spotify-tui/Cargo.toml.patch12
-rw-r--r--pkgs/applications/audio/spotify-tui/default.nix37
4 files changed, 99 insertions, 2 deletions
diff --git a/pkgs/applications/audio/spotify-tui/0001-Add-Collection-SearchType.patch b/pkgs/applications/audio/spotify-tui/0001-Add-Collection-SearchType.patch
new file mode 100644
index 0000000000000..b9daa79a97193
--- /dev/null
+++ b/pkgs/applications/audio/spotify-tui/0001-Add-Collection-SearchType.patch
@@ -0,0 +1,41 @@
+From 408e6a5170bbe9f854bf46e1cbae21265cf25294 Mon Sep 17 00:00:00 2001
+From: Florian Bruhin <me@the-compiler.org>
+Date: Mon, 25 Apr 2022 18:39:07 +0200
+Subject: [PATCH] Add Collection SearchType
+
+Backport of https://github.com/ramsayleung/rspotify/pull/306
+---
+ src/senum.rs | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/senum.rs b/src/senum.rs
+index c94c31c..79d8730 100644
+--- a/src/senum.rs
++++ b/src/senum.rs
+@@ -87,6 +87,7 @@ pub enum Type {
+     User,
+     Show,
+     Episode,
++    Collection,
+ }
+ impl Type {
+     pub fn as_str(&self) -> &str {
+@@ -98,6 +99,7 @@ pub fn as_str(&self) -> &str {
+             Type::User => "user",
+             Type::Show => "show",
+             Type::Episode => "episode",
++            Type::Collection => "collection",
+         }
+     }
+ }
+@@ -112,6 +114,7 @@ fn from_str(s: &str) -> Result<Self, Self::Err> {
+             "user" => Ok(Type::User),
+             "show" => Ok(Type::Show),
+             "episode" => Ok(Type::Episode),
++            "collection" => Ok(Type::Collection),
+             _ => Err(Error::new(ErrorKind::NoEnum(s.to_owned()))),
+         }
+     }
+-- 
+2.35.3
+
diff --git a/pkgs/applications/audio/spotify-tui/Cargo.lock.patch b/pkgs/applications/audio/spotify-tui/Cargo.lock.patch
new file mode 100644
index 0000000000000..7509d6c35c413
--- /dev/null
+++ b/pkgs/applications/audio/spotify-tui/Cargo.lock.patch
@@ -0,0 +1,11 @@
+--- a/Cargo.lock	2022-04-27 17:25:49.017415644 +0300
++++ b/Cargo.lock	2022-04-27 17:25:51.307433984 +0300
+@@ -1722,8 +1722,6 @@
+ [[package]]
+ name = "rspotify"
+ version = "0.10.0"
+-source = "registry+https://github.com/rust-lang/crates.io-index"
+-checksum = "eefd7bb58b714606b30a490f751d7926942e2874eef5e82934d60d7a4a68dca4"
+ dependencies = [
+  "base64 0.10.1",
+  "chrono",
diff --git a/pkgs/applications/audio/spotify-tui/Cargo.toml.patch b/pkgs/applications/audio/spotify-tui/Cargo.toml.patch
new file mode 100644
index 0000000000000..606f69ca74883
--- /dev/null
+++ b/pkgs/applications/audio/spotify-tui/Cargo.toml.patch
@@ -0,0 +1,12 @@
+--- a/Cargo.toml	2022-04-25 18:20:04.329712912 +0200
++++ b/Cargo.toml	2022-04-25 18:20:44.296429608 +0200
+@@ -29,6 +29,9 @@
+ rand = "0.8.3"
+ anyhow = "1.0.43"
+ 
++[patch.crates-io]
++rspotify = { path = "./rspotify-0.10.0" }
++
+ [[bin]]
+ bench = false
+ path = "src/main.rs"
diff --git a/pkgs/applications/audio/spotify-tui/default.nix b/pkgs/applications/audio/spotify-tui/default.nix
index 055034df4ce2e..2b1d114964bfa 100644
--- a/pkgs/applications/audio/spotify-tui/default.nix
+++ b/pkgs/applications/audio/spotify-tui/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitHub, rustPlatform, installShellFiles, pkg-config, openssl, python3, libxcb, AppKit, Security }:
+{ lib, stdenv, fetchFromGitHub, fetchCrate, rustPlatform, installShellFiles, pkg-config, openssl, python3, libxcb, AppKit, Security }:
 
 rustPlatform.buildRustPackage rec {
   pname = "spotify-tui";
@@ -11,7 +11,40 @@ rustPlatform.buildRustPackage rec {
     sha256 = "sha256-L5gg6tjQuYoAC89XfKE38KCFONwSAwfNoFEUPH4jNAI=";
   };
 
-  cargoSha256 = "sha256-iucI4/iMF+uXRlnMttobu4xo3IQXq7tGiSSN8eCrLM0=";
+  # Use patched rspotify
+  cargoPatches = [
+    ./Cargo.lock.patch
+  ];
+  patches = [
+    ./Cargo.toml.patch
+  ];
+
+  preBuild = let
+    rspotify = stdenv.mkDerivation rec {
+      pname = "rspotify";
+      version = "0.10.0";
+
+      src = fetchCrate {
+        inherit pname version;
+        sha256 = "sha256-KDtqjVQlMHlhL1xXP3W1YG/YuX9pdCjwW/7g18469Ts=";
+      };
+
+      dontBuild = true;
+      installPhase = ''
+        mkdir $out
+        cp -R . $out
+      '';
+
+      patches = [
+        # add `collection` variant
+        ./0001-Add-Collection-SearchType.patch
+      ];
+    };
+  in ''
+    ln -s ${rspotify} ./rspotify-${rspotify.version}
+  '';
+
+  cargoSha256 = "sha256-S8zuVYcyYvrwggIvlpxNydhoN9kx6xLBwYJSHcbEK40=";
 
   nativeBuildInputs = [ installShellFiles ] ++ lib.optionals stdenv.isLinux [ pkg-config python3 ];
   buildInputs = [ ]