From 0d9c6bab752df2a744d7ac7bc888057575623d76 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 22 Sep 2024 20:22:37 -0400 Subject: [PATCH] feat(hass): force use of nixpkgs deps for custom integrations --- legacyPackages/hass-components/default.nix | 12 +-- .../extended-ollama-conversation/default.nix | 10 ++- .../extended-ollama-conversation/openai.nix | 19 ----- .../hass-components/spotifyplus/default.nix | 7 +- .../spotifyplus/spotifywebapi.nix | 2 +- .../hass-components/spotifyplus/urllib3.nix | 82 ------------------- 6 files changed, 17 insertions(+), 115 deletions(-) delete mode 100644 legacyPackages/hass-components/extended-ollama-conversation/openai.nix delete mode 100644 legacyPackages/hass-components/spotifyplus/urllib3.nix diff --git a/legacyPackages/hass-components/default.nix b/legacyPackages/hass-components/default.nix index e434660e..c9ccc817 100644 --- a/legacyPackages/hass-components/default.nix +++ b/legacyPackages/hass-components/default.nix @@ -9,21 +9,15 @@ pkgs.lib.makeScope pkgs.newScope (hass: let spotifywebapi = pkgs.callPackage ./spotifyplus/spotifywebapi.nix { inherit (inputs) spotifywebapi-src; - inherit smartinspect urllib3; + inherit smartinspect; python3Packages = spotPython3Packages; }; - - urllib3 = spotPython3Packages.callPackage ./spotifyplus/urllib3.nix {}; }; }; buildHassComponent = file: extraArgs: hass.callPackage file (inputs // extraArgs // {}); in { - extended-ollama-conversation = buildHassComponent ./extended-ollama-conversation { - openai = import ./extended-ollama-conversation/openai.nix pkgs; - }; - spotifyplus = buildHassComponent ./spotifyplus { - python3Packages = spotPython3Packages; - }; + extended-ollama-conversation = buildHassComponent ./extended-ollama-conversation {}; + spotifyplus = buildHassComponent ./spotifyplus {python3Packages = spotPython3Packages;}; }) diff --git a/legacyPackages/hass-components/extended-ollama-conversation/default.nix b/legacyPackages/hass-components/extended-ollama-conversation/default.nix index dc46649e..efb42a0b 100644 --- a/legacyPackages/hass-components/extended-ollama-conversation/default.nix +++ b/legacyPackages/hass-components/extended-ollama-conversation/default.nix @@ -1,7 +1,6 @@ { extended-ollama-conversation-src, buildHomeAssistantComponent, - openai, python3Packages, ... }: let @@ -16,8 +15,13 @@ in src = extended-ollama-conversation-src; - propagatedBuildInputs = [ - python3Packages.ollama + prePatch = '' + substituteInPlace ./custom_components/extended_ollama_conversation/manifest.json \ + --replace-warn "openai~=1.3.8" "openai>=1.3.8" + ''; + + propagatedBuildInputs = with python3Packages; [ + ollama openai ]; } diff --git a/legacyPackages/hass-components/extended-ollama-conversation/openai.nix b/legacyPackages/hass-components/extended-ollama-conversation/openai.nix deleted file mode 100644 index 5ff86ad2..00000000 --- a/legacyPackages/hass-components/extended-ollama-conversation/openai.nix +++ /dev/null @@ -1,19 +0,0 @@ -pkgs: -pkgs.python3Packages.openai.overrideAttrs (o: rec { - name = "${o.pname}-${version}"; - version = "1.3.8"; - - src = pkgs.fetchFromGitHub { - owner = "openai"; - repo = "openai-python"; - rev = "refs/tags/v${version}"; - hash = "sha256-yU0XWEDYl/oBPpYNFg256H0Hn5AaJiP0vOQhbRLnAxQ="; - }; - - disabledTests = - o.disabledTests - ++ [ - "test_retrying_timeout_errors_doesnt_leak" - "test_retrying_status_errors_doesnt_leak" - ]; -}) diff --git a/legacyPackages/hass-components/spotifyplus/default.nix b/legacyPackages/hass-components/spotifyplus/default.nix index 7b7f5a7b..33cdf338 100644 --- a/legacyPackages/hass-components/spotifyplus/default.nix +++ b/legacyPackages/hass-components/spotifyplus/default.nix @@ -15,6 +15,11 @@ 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 @@ -23,6 +28,6 @@ in zeroconf smartinspect # overridden in this python3Packages spotifywebapi # overridden in this python3Packages - urllib3 # overridden in this python3Packages + urllib3 ]; } diff --git a/legacyPackages/hass-components/spotifyplus/spotifywebapi.nix b/legacyPackages/hass-components/spotifyplus/spotifywebapi.nix index 265ae2fa..e13de7ec 100644 --- a/legacyPackages/hass-components/spotifyplus/spotifywebapi.nix +++ b/legacyPackages/hass-components/spotifyplus/spotifywebapi.nix @@ -26,7 +26,7 @@ in requests_oauthlib zeroconf smartinspect # overridden in this python3Packages - urllib3 # overridden in this python3Packages + urllib3 ]; pythonImportsCheck = [ diff --git a/legacyPackages/hass-components/spotifyplus/urllib3.nix b/legacyPackages/hass-components/spotifyplus/urllib3.nix deleted file mode 100644 index 5d8dfc8e..00000000 --- a/legacyPackages/hass-components/spotifyplus/urllib3.nix +++ /dev/null @@ -1,82 +0,0 @@ -# From nixpkgs 4c0061c983a2bcb888f5c478cfb7631ec1090c22 -{ - lib, - brotli, - brotlicffi, - buildPythonPackage, - certifi, - cryptography, - fetchPypi, - idna, - isPyPy, - mock, - pyopenssl, - pysocks, - pytest-freezegun, - pytest-timeout, - pytestCheckHook, - python-dateutil, - tornado, - trustme, -}: -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 = [ - python-dateutil - mock - pytest-freezegun - pytest-timeout - pytestCheckHook - tornado - trustme - ]; - - doCheck = false; - - preCheck = '' - export CI # Increases LONG_TIMEOUT - ''; - - pythonImportsCheck = [ - "urllib3" - ]; - - passthru.optional-dependencies = { - 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; - }; -}