Merge pull request #170915 from MoritzBoehme/spotify-tui-collection-patch

This commit is contained in:
Sandro 2022-07-14 20:21:08 +02:00 committed by GitHub
commit fd00fef45d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 99 additions and 2 deletions

View file

@ -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

View file

@ -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",

View file

@ -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"

View file

@ -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 = [ ]