fix(esphome): add patch to fix python env
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2025-02-06 17:01:45 -05:00
parent 277a462031
commit 6e2c84a050

View file

@ -47,6 +47,7 @@ in {
};
config = mkIf cfg.enable {
# Fixes https://github.com/NixOS/nixpkgs/issues/339557
users = {
users.esphome = {
isNormalUser = true;
@ -56,7 +57,42 @@ in {
groups.esphome = {};
};
# https://github.com/NixOS/nixpkgs/issues/339557
# Fixes https://github.com/NixOS/nixpkgs/issues/370611
nixpkgs.overlays = [
(final: prev: {
esphome = prev.esphome.overrideAttrs (o: {
patches = [
(builtins.toFile "post-build.patch" ''
--- a/esphome/components/esp32/post_build.py.script
+++ b/esphome/components/esp32/post_build.py.script
@@ -2,10 +2,13 @@
# pylint: disable=E0602
Import("env") # noqa
+#print(env.Dump())
import os
import shutil
+os.environ["PATH"] = os.path.dirname(env.get("PYTHONEXE")) + os.pathsep + os.environ["PATH"]
+
if os.environ.get("ESPHOME_USE_SUBPROCESS") is None:
try:
import esptool
@@ -63,6 +66,7 @@ def esp32_create_combined_bin(source, target, env):
esptool.main(cmd)
else:
subprocess.run(["esptool.py", *cmd])
+ #subprocess.run([env.get("PYTHONEXE"), "/var/lib/esphome/.platformio/packages/tool-esptoolpy/esptool.py", *cmd])
def esp32_copy_ota_bin(source, target, env):
'')
];
});
})
];
systemd.services.esphome = {
serviceConfig =
(optionalAttrs (cfg.firmwareConfigs != {}) {
@ -94,6 +130,7 @@ in {
});
})
// {
# Fixes https://github.com/NixOS/nixpkgs/issues/339557
DynamicUser = mkForce "off";
};
};