From e01ccd6245fe1fe34aa49aa48fe3d53e3b013c20 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 20 Feb 2023 16:54:37 +0100 Subject: [PATCH] home-assistant: Inject extra dependencies through PYTHONPATH Injecting configuration specific dependencies into the propagatedBuildInputs of the home-assistant package forces alot of rebuilds while setting up home-assistant, which is annoying. By passing optional dependencies into home-assistant via the systemd units PYTHONPATH environment variable, only he concatenation of library paths in the systemd unit requires a rebuild. This also means users can rely heavily on the cached home-assistant package and will rarely have to build from source, if ever. --- nixos/modules/services/home-automation/home-assistant.nix | 1 + pkgs/servers/home-assistant/default.nix | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/home-automation/home-assistant.nix b/nixos/modules/services/home-automation/home-assistant.nix index 9f6f153a1056..6adc58ec58ec 100644 --- a/nixos/modules/services/home-automation/home-assistant.nix +++ b/nixos/modules/services/home-automation/home-assistant.nix @@ -409,6 +409,7 @@ in { (optionalString (cfg.config != null) copyConfig) + (optionalString (cfg.lovelaceConfig != null) copyLovelaceConfig) ; + environment.PYTHONPATH = package.pythonPath; serviceConfig = let # List of capabilities to equip home-assistant with, depending on configured components capabilities = lib.unique ([ diff --git a/pkgs/servers/home-assistant/default.nix b/pkgs/servers/home-assistant/default.nix index 7ff1473edec3..b5e42fca6ae4 100644 --- a/pkgs/servers/home-assistant/default.nix +++ b/pkgs/servers/home-assistant/default.nix @@ -355,7 +355,7 @@ in python.pkgs.buildPythonApplication rec { yarl # Implicit dependency via homeassistant/requirements.py setuptools - ] ++ componentBuildInputs ++ extraBuildInputs; + ]; makeWrapperArgs = lib.optional skipPip "--add-flags --skip-pip"; @@ -431,6 +431,7 @@ in python.pkgs.buildPythonApplication rec { getPackages python supportedComponentsWithTests; + pythonPath = python3.pkgs.makePythonPath (componentBuildInputs ++ extraBuildInputs); intents = python.pkgs.home-assistant-intents; tests = { nixos = nixosTests.home-assistant;