From 54b7074d065bedda4f073cea2e4d73fa0acc51ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 29 Apr 2022 15:42:13 +0200 Subject: [PATCH] spotify-tui: add collection variant patch Co-authored-by: Sandro --- .../0001-Add-Collection-SearchType.patch | 41 +++++++++++++++++++ .../audio/spotify-tui/Cargo.lock.patch | 11 +++++ .../audio/spotify-tui/Cargo.toml.patch | 12 ++++++ .../audio/spotify-tui/default.nix | 37 ++++++++++++++++- 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 pkgs/applications/audio/spotify-tui/0001-Add-Collection-SearchType.patch create mode 100644 pkgs/applications/audio/spotify-tui/Cargo.lock.patch create mode 100644 pkgs/applications/audio/spotify-tui/Cargo.toml.patch 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 000000000000..b9daa79a9719 --- /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 +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 { + "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 000000000000..7509d6c35c41 --- /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 000000000000..606f69ca7488 --- /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 055034df4ce2..2b1d114964bf 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 = [ ]