Repository navigation
nixos/esphome: replace DynamicUser with static system user - #508178
Conversation
|
tomfitzhenry
left a comment
There was a problem hiding this comment.
One thing I'm not sure how to handle: users with existing data in /var/lib/private/esphome will need to move it to /var/lib/esphome and chown to esphome:esphome.
Since it's a breaking change, this at least needs a mention in the release notes.
It's a shame to lose DynamicUser, and also introduce a breaking change, especially since the upstream fix might be easy if only the developers know. Is it worth raising an issue at https://github.com/esphome/esphome ?
|
This seems related enough to consider when reviewing: #486701 |
It isn't really a breaking change. I disabled DynamicUser and systemd does everything for you:
No, it really isn't. We are easily storing a few 100 MBs of cached data in many files, the existing socket option works poor with DynamicUser and it causes permission errors and all of that for very little benefit.
I do not think fixing that is easy. It might need fixes in esphome and platformio and maybe also some third component and they will likely tell you to use their esphome docker image or the home assistant addon. |
|
And the compile cache currently gets invalidated with every run. I would not be surprised by all means if DynamicUser caused that somehow, but I did not investigate that at all. |
Might be breaking for people using impermanence. Systemd will migrate the data from a persistent directory into a non persisted directory which effectively deletes the files on next reboot. Now arguably impermanence isnt NixOS core stuff, but it might affect enough users to warrant a release note entry. |
DynamicUser symlinks /var/lib/esphome to /var/lib/private/esphome, which breaks PlatformIO path resolution during compilation. Use a static system user instead. Also set PLATFORMIO_CORE_DIR and HOME to real paths, and enable NoNewPrivileges, PrivateTmp, RemoveIPC, RestrictSUIDSGID (previously implied by DynamicUser). Fixes: NixOS#339557
c9deb50 to
596d3a1
Compare
@oddlama Added a release note in the latest push. It mentions the auto-migration and the impermanence caveat.
@tomfitzhenry I filed platformio/platformio-core#5427 against platformio-core. The symlink issue is really platformio's path resolution, not esphome's. That said, upstream's track record on NixOS issues is "use our Docker image," so I wouldn't hold this PR for it. |
Great work, great PR! |
It looks like ExecPaths was removed in #508178, after adding it in #498811. ExecPaths is required to fix building firmware for LibreTiny-based devices, otherwise we get the following error: ``` sh: line 1: /var/lib/esphome/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++: Permission denied ``` Signed-off-by: David Wronek <[email protected]>
DynamicUsersymlinks/var/lib/esphometo/var/lib/private/esphome. PlatformIO can't resolve paths through the symlink, so firmware compilation fails with permission errors or duplicate target errors.This switches to a static
esphomesystem user and group, same pattern as zigbee2mqtt and other stateful services.PLATFORMIO_CORE_DIRandHOMEnow point to real paths.Hardening options that were previously implied by
DynamicUser(NoNewPrivileges,PrivateTmp,RemoveIPC,RestrictSUIDSGID) are now set explicitly.One thing I'm not sure how to handle: users with existing data in
/var/lib/private/esphomewill need to move it to/var/lib/esphomeand chown toesphome:esphome.Fixes #339557
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.