Skip to content

esphome: allow user to configure state dir - #486701

Closed
karlbeecken wants to merge 1 commit into
NixOS:masterfrom
karlbeecken:patch-3
Closed

karlbeecken wants to merge 1 commit into
NixOS:masterfrom
karlbeecken:patch-3

Conversation

@karlbeecken

@karlbeecken karlbeecken commented Feb 3, 2026 •

Copy link
Copy Markdown
Member

Hi!

I wanted to erase my darlings and noticed esphome used a hardcoded state dir. I changed this and added an option to the esphome service that allows the user to set a custom stateDir. I tested it with my esphome setup, it is backwards-compatible and I also added a condition to disable ProtectHome when the state dir is under /home. DynamicUser needs to be disabled for a different state dir than the default, and is conditionally disabled if the user changes this option. Otherwise, the behaviour stays as it was.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Feb 3, 2026
@karlbeecken

Copy link
Copy Markdown
Member Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 486701
Commit: 2c5a20f1f5ca9363cb53d693456bc5d654084016

@karlbeecken

Copy link
Copy Markdown
Member Author

@oddlama you are listed as maintainer, not sure why the bot didn't tag you

@oddlama

oddlama commented Feb 5, 2026 •

Copy link
Copy Markdown
Member

I also use impermanence and in this case it should suffice to use impermance to add /var/lib/private/esphome to your persisted directories, which should then just automatically install a bind mount.

Adding an option to change directories like this usually comes with some caveats, for example having to disable ProtectHome, disabling other hardening options or disabling DynamicUser (which then requires a real uid allocation on which we are short for system services). All of this just makes the service more complex, so if this can be solved with a simple bind mount, I would first advocate to use those and only add options to change the directory if there's a good reason to do so.

Is there any reason a bind mount would not work for your usecase?

@SuperSandro2000

Copy link
Copy Markdown
Member

I do not like that this will make the module rather complicated with many conditions most people cannot even reasonable verify.

The PR linked above this comment removes DynamcUser which already removes much of the currently required complexity and maybe after that all those things can easily live in a persons own config?

@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 11, 2026
@karlbeecken

Copy link
Copy Markdown
Member Author

The PR linked above this comment removes DynamcUser which already removes much of the currently required complexity and maybe after that all those things can easily live in a persons own config?

I agree, I think with #508178 this PR isn't really needed anymore, and anything further can be done in the user-side config. Thanks for the heads-up!

@karlbeecken karlbeecken mentioned this pull request Nov 7, 2026
2 of 13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants