From 06669e8679ad99ba7523ac170af5dd2ae06b1759 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 30 Sep 2024 21:45:18 -0400 Subject: [PATCH] fix(hass): override urllib for spotifyplus --- .../homie/modules/home-assistant/default.nix | 12 +++- .../hass-components/spotifyplus/default.nix | 6 +- .../spotifyplus/spotifyplus.nix | 5 -- packages/default.nix | 2 + packages/urllib3/default.nix | 67 +++++++++++++++++++ 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 packages/urllib3/default.nix diff --git a/devices/homie/modules/home-assistant/default.nix b/devices/homie/modules/home-assistant/default.nix index 251836d4..e39bcdc9 100644 --- a/devices/homie/modules/home-assistant/default.nix +++ b/devices/homie/modules/home-assistant/default.nix @@ -1,4 +1,8 @@ -{pkgs, ...}: { +{ + pkgs, + self, + ... +}: { imports = [ ./assist.nix ./bluetooth.nix @@ -47,6 +51,12 @@ services.home-assistant = { enable = true; + package = pkgs.home-assistant.override { + packageOverrides = _: super: { + inherit (self.packages.${pkgs.system}) urllib3; + }; + }; + extraComponents = [ "androidtv_remote" "caldav" diff --git a/legacyPackages/hass-components/spotifyplus/default.nix b/legacyPackages/hass-components/spotifyplus/default.nix index b2173c10..bf09a40c 100644 --- a/legacyPackages/hass-components/spotifyplus/default.nix +++ b/legacyPackages/hass-components/spotifyplus/default.nix @@ -1,4 +1,5 @@ { + self, buildHassComponent, smartinspect-src, spotifywebapi-src, @@ -6,13 +7,16 @@ ... }: let python3Packages = pkgs.python3Packages.override { - overrides = self: super: rec { + overrides = _: super: rec { smartinspect = pkgs.callPackage ./smartinspect.nix { inherit python3Packages smartinspect-src; }; spotifywebapi = pkgs.callPackage ./spotifywebapi.nix { inherit python3Packages smartinspect spotifywebapi-src; }; + urllib3 = self.packages.${pkgs.system}.urllib3.override { + inherit python3Packages; + }; }; }; in diff --git a/legacyPackages/hass-components/spotifyplus/spotifyplus.nix b/legacyPackages/hass-components/spotifyplus/spotifyplus.nix index da864dac..82a8bf98 100644 --- a/legacyPackages/hass-components/spotifyplus/spotifyplus.nix +++ b/legacyPackages/hass-components/spotifyplus/spotifyplus.nix @@ -15,11 +15,6 @@ in src = spotifyplus-src; - prePatch = '' - substituteInPlace ./custom_components/spotifyplus/manifest.json \ - --replace-warn "urllib3>=1.21.1,<1.27" "urllib3>=1.21.1" - ''; - propagatedBuildInputs = with python3Packages; [ oauthlib platformdirs diff --git a/packages/default.nix b/packages/default.nix index 9eda7ca5..baa03e27 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -41,4 +41,6 @@ trash-d = pkgs.callPackage ./trash-d { inherit (inputs) trash-d-src; }; + + urllib3 = pkgs.callPackage ./urllib3 {}; } diff --git a/packages/urllib3/default.nix b/packages/urllib3/default.nix new file mode 100644 index 00000000..1780e00e --- /dev/null +++ b/packages/urllib3/default.nix @@ -0,0 +1,67 @@ +# From nixpkgs 4c0061c983a2bcb888f5c478cfb7631ec1090c22 +{ + lib, + fetchPypi, + python3Packages, +}: +python3Packages.buildPythonPackage rec { + pname = "urllib3"; + version = "1.26.16"; + format = "setuptools"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-jxNfZQJ1a95rKpsomJ31++h8mXDOyqaQQe3M5/BYmxQ="; + }; + + propagatedBuildInputs = + passthru.optional-dependencies.brotli + ++ passthru.optional-dependencies.socks; + + nativeCheckInputs = with python3Packages; [ + python-dateutil + mock + pytest-freezegun + pytest-timeout + pytestCheckHook + tornado + trustme + ]; + + doCheck = false; + + preCheck = '' + export CI # Increases LONG_TIMEOUT + ''; + + pythonImportsCheck = [ + "urllib3" + ]; + + passthru.optional-dependencies = with python3Packages; { + brotli = + if isPyPy + then [ + brotlicffi + ] + else [ + brotli + ]; + secure = [ + certifi + cryptography + idna + pyopenssl + ]; + socks = [ + pysocks + ]; + }; + + meta = with lib; { + description = "Powerful, sanity-friendly HTTP client for Python"; + homepage = "https://github.com/shazow/urllib3"; + changelog = "https://github.com/urllib3/urllib3/blob/${version}/CHANGES.rst"; + license = licenses.mit; + }; +}