feat(hass): package spotifyplus
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
72bd94bffd
commit
41707ac4ae
14 changed files with 287 additions and 56 deletions
|
@ -12,7 +12,10 @@
|
|||
services = {
|
||||
home-assistant = {
|
||||
customComponents = builtins.attrValues {
|
||||
inherit (self.legacyPackages.${pkgs.system}.hass-components) extended-ollama-conversation;
|
||||
inherit
|
||||
(self.legacyPackages.${pkgs.system}.hass-components)
|
||||
extended-ollama-conversation
|
||||
;
|
||||
};
|
||||
|
||||
extraComponents = [
|
||||
|
|
|
@ -2,22 +2,12 @@
|
|||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
self,
|
||||
...
|
||||
}: {
|
||||
# Turn On the speaker automatically when openwakeword is used
|
||||
services.home-assistant = {
|
||||
extraComponents = [
|
||||
"mpd"
|
||||
}: let
|
||||
inherit (lib) getExe;
|
||||
|
||||
# BT components
|
||||
"ibeacon"
|
||||
"led_ble"
|
||||
"kegtron"
|
||||
"xiaomi_ble"
|
||||
];
|
||||
|
||||
config = {
|
||||
shell_command.turn_on_ue = lib.getExe (pkgs.writeShellApplication {
|
||||
turnOnUE = pkgs.writeShellApplication {
|
||||
name = "turnOnUE";
|
||||
|
||||
runtimeInputs = [config.hardware.bluetooth.package];
|
||||
|
@ -32,7 +22,31 @@
|
|||
|
||||
exec gatttool -b $bt_device_addr --char-write-req --handle=$cmd --value=$bt_controller_addr
|
||||
'';
|
||||
});
|
||||
};
|
||||
in {
|
||||
environment.systemPackages = [turnOnUE];
|
||||
|
||||
services.home-assistant = {
|
||||
customComponents = builtins.attrValues {
|
||||
inherit
|
||||
(self.legacyPackages.${pkgs.system}.hass-components)
|
||||
spotifyplus
|
||||
;
|
||||
};
|
||||
|
||||
extraComponents = [
|
||||
"mpd"
|
||||
|
||||
# BT components
|
||||
"ibeacon"
|
||||
"led_ble"
|
||||
"kegtron"
|
||||
"xiaomi_ble"
|
||||
];
|
||||
|
||||
# Turn On the speaker automatically when openwakeword is used
|
||||
config = {
|
||||
shell_command.turn_on_ue = getExe turnOnUE;
|
||||
|
||||
automation = [
|
||||
{
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
"isal"
|
||||
"met"
|
||||
"spotify"
|
||||
"switchbot"
|
||||
"upnp"
|
||||
"yamaha_musiccast"
|
||||
];
|
||||
|
|
BIN
flake.lock
BIN
flake.lock
Binary file not shown.
BIN
flake.nix
BIN
flake.nix
Binary file not shown.
15
inputs.nix
15
inputs.nix
|
@ -172,6 +172,21 @@ let
|
|||
owner = "TheNimaj";
|
||||
repo = "extended_ollama_conversation";
|
||||
}
|
||||
{
|
||||
name = "spotifyplus-src";
|
||||
owner = "thlucas1";
|
||||
repo = "homeassistantcomponent_spotifyplus";
|
||||
}
|
||||
{
|
||||
name = "smartinspect-src";
|
||||
owner = "thlucas1";
|
||||
repo = "SmartInspectPython";
|
||||
}
|
||||
{
|
||||
name = "spotifywebapi-src";
|
||||
owner = "thlucas1";
|
||||
repo = "SpotifyWebApiPython";
|
||||
}
|
||||
|
||||
{
|
||||
name = "wakewords-src";
|
||||
|
|
|
@ -1,7 +1,29 @@
|
|||
{pkgs, ...} @ inputs:
|
||||
pkgs.lib.makeScope pkgs.newScope (hass: let
|
||||
buildHassComponent = file:
|
||||
hass.callPackage file (inputs // {});
|
||||
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 urllib3;
|
||||
python3Packages = spotPython3Packages;
|
||||
};
|
||||
|
||||
urllib3 = spotPython3Packages.callPackage ./spotifyplus/urllib3.nix {};
|
||||
};
|
||||
};
|
||||
|
||||
buildHassComponent = file: extraArgs:
|
||||
hass.callPackage file (inputs // extraArgs // {});
|
||||
in {
|
||||
extended-ollama-conversation = buildHassComponent ./extended-ollama-conversation.nix;
|
||||
extended-ollama-conversation = buildHassComponent ./extended-ollama-conversation {
|
||||
openai = import ./extended-ollama-conversation/openai.nix pkgs;
|
||||
};
|
||||
spotifyplus = buildHassComponent ./spotifyplus {
|
||||
python3Packages = spotPython3Packages;
|
||||
};
|
||||
})
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
extended-ollama-conversation-src,
|
||||
buildHomeAssistantComponent,
|
||||
fetchFromGitHub,
|
||||
python3Packages,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) fromJSON readFile;
|
||||
|
||||
manifest = fromJSON (readFile "${extended-ollama-conversation-src}/custom_components/extended_ollama_conversation/manifest.json");
|
||||
|
||||
openai = python3Packages.openai.overrideAttrs (o: rec {
|
||||
name = "${o.pname}-${version}";
|
||||
version = "1.3.8";
|
||||
|
||||
src = 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"];
|
||||
});
|
||||
in
|
||||
buildHomeAssistantComponent {
|
||||
owner = "TheNimaj";
|
||||
|
||||
inherit (manifest) domain version;
|
||||
|
||||
src = extended-ollama-conversation-src;
|
||||
|
||||
propagatedBuildInputs = [python3Packages.ollama openai];
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
extended-ollama-conversation-src,
|
||||
buildHomeAssistantComponent,
|
||||
openai,
|
||||
python3Packages,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) fromJSON readFile;
|
||||
|
||||
manifest = fromJSON (readFile "${extended-ollama-conversation-src}/custom_components/extended_ollama_conversation/manifest.json");
|
||||
in
|
||||
buildHomeAssistantComponent {
|
||||
owner = "TheNimaj";
|
||||
|
||||
inherit (manifest) domain version;
|
||||
|
||||
src = extended-ollama-conversation-src;
|
||||
|
||||
propagatedBuildInputs = [
|
||||
python3Packages.ollama
|
||||
openai
|
||||
];
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
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"
|
||||
];
|
||||
})
|
28
legacyPackages/hass-components/spotifyplus/default.nix
Normal file
28
legacyPackages/hass-components/spotifyplus/default.nix
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
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;
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [
|
||||
oauthlib
|
||||
platformdirs
|
||||
requests
|
||||
requests_oauthlib
|
||||
zeroconf
|
||||
smartinspect # overridden in this python3Packages
|
||||
spotifywebapi # overridden in this python3Packages
|
||||
urllib3 # overridden in this python3Packages
|
||||
];
|
||||
}
|
23
legacyPackages/hass-components/spotifyplus/smartinspect.nix
Normal file
23
legacyPackages/hass-components/spotifyplus/smartinspect.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
smartinspect-src,
|
||||
python3Packages,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) elemAt head readFile split;
|
||||
tag = head (split "\"" (elemAt (split "VERSION:str = \"" (readFile "${smartinspect-src}/smartinspectpython/siconst.py")) 2));
|
||||
in
|
||||
python3Packages.buildPythonPackage {
|
||||
pname = "smartinspectPython";
|
||||
version = "${tag}+${smartinspect-src.shortRev}";
|
||||
|
||||
src = smartinspect-src;
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [
|
||||
pycryptodome
|
||||
watchdog
|
||||
];
|
||||
|
||||
pythonImportsCheck = [
|
||||
"smartinspectpython"
|
||||
];
|
||||
}
|
35
legacyPackages/hass-components/spotifyplus/spotifywebapi.nix
Normal file
35
legacyPackages/hass-components/spotifyplus/spotifywebapi.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
spotifywebapi-src,
|
||||
python3Packages,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) elemAt head readFile split;
|
||||
tag = head (split "\"" (elemAt (split "VERSION:str = \"" (readFile "${spotifywebapi-src}/spotifywebapipython/const.py")) 2));
|
||||
in
|
||||
python3Packages.buildPythonPackage {
|
||||
pname = "spotifywebapiPython";
|
||||
version = "${tag}+${spotifywebapi-src.shortRev}";
|
||||
|
||||
src = spotifywebapi-src;
|
||||
|
||||
patchPhase = ''
|
||||
substituteInPlace ./setup.py --replace-warn \
|
||||
"docspdoc/build/spotifywebapiPython/" \
|
||||
"docspdoc/build/spotifywebapipython/"
|
||||
'';
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [
|
||||
lxml
|
||||
oauthlib
|
||||
platformdirs
|
||||
requests
|
||||
requests_oauthlib
|
||||
zeroconf
|
||||
smartinspect # overridden in this python3Packages
|
||||
urllib3 # overridden in this python3Packages
|
||||
];
|
||||
|
||||
pythonImportsCheck = [
|
||||
"spotifywebapipython"
|
||||
];
|
||||
}
|
82
legacyPackages/hass-components/spotifyplus/urllib3.nix
Normal file
82
legacyPackages/hass-components/spotifyplus/urllib3.nix
Normal file
|
@ -0,0 +1,82 @@
|
|||
# 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;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue