From c68779da234c1092b08c1cf5fc274d02fc44df37 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 30 Sep 2024 13:39:09 -0400 Subject: [PATCH] refactor(hass): clean up and remove sonos for spotifyplus --- .../modules/home-assistant/bluetooth.nix | 1 - legacyPackages/hass-components/default.nix | 17 +------ .../hass-components/spotifyplus/default.nix | 45 +++++++------------ .../spotifyplus/spotifyplus.nix | 34 ++++++++++++++ .../spotifyplus/spotifywebapi.nix | 3 +- 5 files changed, 52 insertions(+), 48 deletions(-) create mode 100644 legacyPackages/hass-components/spotifyplus/spotifyplus.nix diff --git a/devices/homie/modules/home-assistant/bluetooth.nix b/devices/homie/modules/home-assistant/bluetooth.nix index 73bfc40b..6decac53 100644 --- a/devices/homie/modules/home-assistant/bluetooth.nix +++ b/devices/homie/modules/home-assistant/bluetooth.nix @@ -36,7 +36,6 @@ in { extraComponents = [ "mpd" - "sonos" # BT components "ibeacon" diff --git a/legacyPackages/hass-components/default.nix b/legacyPackages/hass-components/default.nix index 8c84ece6..02db5d18 100644 --- a/legacyPackages/hass-components/default.nix +++ b/legacyPackages/hass-components/default.nix @@ -1,24 +1,9 @@ {pkgs, ...} @ inputs: pkgs.lib.makeScope pkgs.newScope (hass: let - spotPython3Packages = pkgs.python3Packages.override { - overrides = self: super: rec { - smartinspect = pkgs.callPackage ./spotifyplus/smartinspect.nix { - inherit (inputs) smartinspect-src; - python3Packages = spotPython3Packages; - }; - - spotifywebapi = pkgs.callPackage ./spotifyplus/spotifywebapi.nix { - inherit (inputs) spotifywebapi-src; - inherit smartinspect; - python3Packages = spotPython3Packages; - }; - }; - }; - buildHassComponent = file: extraArgs: hass.callPackage file (inputs // extraArgs // {}); in { extended-ollama-conversation = buildHassComponent ./extended-ollama-conversation {}; + spotifyplus = import ./spotifyplus ({inherit buildHassComponent;} // inputs); tuya-local = buildHassComponent ./tuya-local {}; - spotifyplus = buildHassComponent ./spotifyplus {python3Packages = spotPython3Packages;}; }) diff --git a/legacyPackages/hass-components/spotifyplus/default.nix b/legacyPackages/hass-components/spotifyplus/default.nix index da864dac..b2173c10 100644 --- a/legacyPackages/hass-components/spotifyplus/default.nix +++ b/legacyPackages/hass-components/spotifyplus/default.nix @@ -1,34 +1,19 @@ { - spotifyplus-src, - buildHomeAssistantComponent, - python3Packages, + buildHassComponent, + smartinspect-src, + spotifywebapi-src, + pkgs, ... }: let - inherit (builtins) fromJSON readFile; - - manifest = fromJSON (readFile "${spotifyplus-src}/custom_components/spotifyplus/manifest.json"); + python3Packages = pkgs.python3Packages.override { + overrides = self: super: rec { + smartinspect = pkgs.callPackage ./smartinspect.nix { + inherit python3Packages smartinspect-src; + }; + spotifywebapi = pkgs.callPackage ./spotifywebapi.nix { + inherit python3Packages smartinspect spotifywebapi-src; + }; + }; + }; in - buildHomeAssistantComponent { - owner = "thlucas1"; - - inherit (manifest) domain version; - - 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 - requests - requests_oauthlib - soco - urllib3 - zeroconf - smartinspect # overridden in this python3Packages - spotifywebapi # overridden in this python3Packages - ]; - } + buildHassComponent ./spotifyplus.nix {inherit python3Packages;} diff --git a/legacyPackages/hass-components/spotifyplus/spotifyplus.nix b/legacyPackages/hass-components/spotifyplus/spotifyplus.nix new file mode 100644 index 00000000..da864dac --- /dev/null +++ b/legacyPackages/hass-components/spotifyplus/spotifyplus.nix @@ -0,0 +1,34 @@ +{ + spotifyplus-src, + buildHomeAssistantComponent, + python3Packages, + ... +}: let + inherit (builtins) fromJSON readFile; + + manifest = fromJSON (readFile "${spotifyplus-src}/custom_components/spotifyplus/manifest.json"); +in + buildHomeAssistantComponent { + owner = "thlucas1"; + + inherit (manifest) domain version; + + 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 + requests + requests_oauthlib + soco + urllib3 + zeroconf + smartinspect # overridden in this python3Packages + spotifywebapi # overridden in this python3Packages + ]; + } diff --git a/legacyPackages/hass-components/spotifyplus/spotifywebapi.nix b/legacyPackages/hass-components/spotifyplus/spotifywebapi.nix index e13de7ec..9d3d6768 100644 --- a/legacyPackages/hass-components/spotifyplus/spotifywebapi.nix +++ b/legacyPackages/hass-components/spotifyplus/spotifywebapi.nix @@ -12,6 +12,7 @@ in src = spotifywebapi-src; + # FIXME: https://github.com/thlucas1/SpotifyWebApiPython/issues/1 patchPhase = '' substituteInPlace ./setup.py --replace-warn \ "docspdoc/build/spotifywebapiPython/" \ @@ -24,9 +25,9 @@ in platformdirs requests requests_oauthlib + urllib3 zeroconf smartinspect # overridden in this python3Packages - urllib3 ]; pythonImportsCheck = [