nuc
This commit is contained in:
@@ -1,45 +1,28 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
namespace,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.home-assistant;
|
||||
|
||||
# ESPHome with littlefs-python and fatfs-ng added to PYTHONPATH so PlatformIO's
|
||||
# espressif32 platform builder can import them (needed for LittleFS/FAT support).
|
||||
# fatfs-ng is the correct package: it installs under the 'fatfs' namespace and
|
||||
# provides create_extended_partition and ESP32 wear-leveling support required by
|
||||
# pioarduino's platform builder (penv_setup.py specifies "fatfs-ng>=0.1.14").
|
||||
esphomeWithLittlefs = pkgs.esphome.overridePythonAttrs (oldAttrs: {
|
||||
makeWrapperArgs = (oldAttrs.makeWrapperArgs or [ ]) ++ [
|
||||
"--prefix PYTHONPATH : ${pkgs.${namespace}.littlefs-python}/${pkgs.python3.sitePackages}"
|
||||
"--prefix PYTHONPATH : ${pkgs.${namespace}.fatfs-ng}/${pkgs.python3.sitePackages}"
|
||||
];
|
||||
});
|
||||
in
|
||||
{
|
||||
config = mkIf cfg.enable {
|
||||
services = {
|
||||
esphome = {
|
||||
enable = true;
|
||||
openFirewall = true; # 6052
|
||||
address = "0.0.0.0";
|
||||
package = esphomeWithLittlefs;
|
||||
virtualisation.oci-containers.containers.esphome = {
|
||||
autoStart = true;
|
||||
image = "ghcr.io/esphome/esphome:2026.2.4";
|
||||
ports = [ "6052:6052" ];
|
||||
volumes = [
|
||||
"/var/lib/esphome:/config"
|
||||
];
|
||||
environment = {
|
||||
TZ = "America/Chicago";
|
||||
};
|
||||
};
|
||||
|
||||
# Add uv to the ESPHome service PATH so PlatformIO uses the Nix-provided
|
||||
# binary instead of downloading its own (which would fail due to permissions).
|
||||
# Also disable MemoryDenyWriteExecute so uv (a native Rust binary) can run.
|
||||
systemd.services.esphome = {
|
||||
path = [ pkgs.uv ];
|
||||
serviceConfig = {
|
||||
MemoryDenyWriteExecute = lib.mkForce false;
|
||||
};
|
||||
};
|
||||
# Open the ESPHome dashboard port
|
||||
networking.firewall.allowedTCPPorts = [ 6052 ];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
python3Packages,
|
||||
}:
|
||||
|
||||
python3Packages.buildPythonPackage rec {
|
||||
pname = "fatfs-ng";
|
||||
version = "0.1.15";
|
||||
format = "setuptools";
|
||||
|
||||
src = python3Packages.fetchPypi {
|
||||
pname = "fatfs_ng";
|
||||
inherit version;
|
||||
hash = "sha256-qwSMf3s8+IxVi6mHEWr8vYa6/bMUXcaGWhULUMaADAs=";
|
||||
};
|
||||
|
||||
# wrapper.c is pre-generated in the sdist; Cython is not needed at build time.
|
||||
# Patch out setup_requires=['cython'] to prevent setuptools from trying to
|
||||
# fetch it via pip at build time (which fails in the Nix sandbox).
|
||||
postPatch = ''
|
||||
substituteInPlace setup.py \
|
||||
--replace-fail "setup_requires=['cython']," ""
|
||||
'';
|
||||
|
||||
nativeBuildInputs = with python3Packages; [
|
||||
setuptools
|
||||
];
|
||||
|
||||
doCheck = false;
|
||||
|
||||
# fatfs-ng installs under the 'fatfs' namespace (ext_package='fatfs')
|
||||
pythonImportsCheck = [ "fatfs" ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Enhanced Python wrapper around ChaN's FatFS library with ESP32 wear-leveling support";
|
||||
homepage = "https://github.com/Jason2866/pyfatfs";
|
||||
license = licenses.mit;
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
python3Packages,
|
||||
}:
|
||||
|
||||
python3Packages.buildPythonPackage rec {
|
||||
pname = "littlefs-python";
|
||||
version = "0.17.1";
|
||||
pyproject = true;
|
||||
|
||||
src = python3Packages.fetchPypi {
|
||||
pname = "littlefs_python";
|
||||
inherit version;
|
||||
hash = "sha256-O8D9Tnf5T6ZVlRdRfPqj38dCUkcayW4a5fWQaJ4ErtA=";
|
||||
};
|
||||
|
||||
build-system = with python3Packages; [
|
||||
setuptools
|
||||
setuptools-scm
|
||||
cython
|
||||
];
|
||||
|
||||
doCheck = false;
|
||||
|
||||
pythonImportsCheck = [ "littlefs" ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Python bindings for littlefs, the filesystem designed for small embedded targets";
|
||||
homepage = "https://github.com/jrast/littlefs-python";
|
||||
license = licenses.mit;
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
impermanence = {
|
||||
enable = true;
|
||||
extraDirectories = [
|
||||
"/var/lib/private/esphome"
|
||||
"/var/lib/esphome"
|
||||
"/var/lib/homeassistant"
|
||||
"/var/lib/mosquitto"
|
||||
"/var/lib/music-assistant"
|
||||
|
||||
Reference in New Issue
Block a user