mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-11 07:10:39 +02:00
fix(zackbiene): esphome platformio directory was resolved wrongly
This commit is contained in:
parent
5d8c1c902d
commit
f9bf4f8e32
2 changed files with 26 additions and 15 deletions
|
@ -1,4 +1,8 @@
|
||||||
{nodeSecrets, ...}: {
|
{
|
||||||
|
config,
|
||||||
|
nodeSecrets,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
imports = [../../modules/esphome.nix];
|
imports = [../../modules/esphome.nix];
|
||||||
|
|
||||||
services.esphome = {
|
services.esphome = {
|
||||||
|
@ -12,7 +16,8 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO esphome.sock permissions pls nginx currently world writable
|
systemd.services.nginx.serviceConfig.SupplementaryGroups = ["esphome"];
|
||||||
|
systemd.services.nginx.requires = ["esphome.service"];
|
||||||
services.nginx.upstreams = {
|
services.nginx.upstreams = {
|
||||||
"esphome" = {
|
"esphome" = {
|
||||||
servers = {"unix:/run/esphome/esphome.sock" = {};};
|
servers = {"unix:/run/esphome/esphome.sock" = {};};
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
inherit
|
inherit
|
||||||
(lib)
|
(lib)
|
||||||
literalExpression
|
literalExpression
|
||||||
|
maintainers
|
||||||
mkEnableOption
|
mkEnableOption
|
||||||
mkIf
|
mkIf
|
||||||
mkOption
|
mkOption
|
||||||
|
@ -16,10 +17,15 @@
|
||||||
|
|
||||||
cfg = config.services.esphome;
|
cfg = config.services.esphome;
|
||||||
|
|
||||||
name = "esphome";
|
stateDir = "/var/lib/esphome";
|
||||||
|
|
||||||
stateDir = "/var/lib/${name}";
|
esphomeParams =
|
||||||
|
if cfg.enableUnixSocket
|
||||||
|
then "--socket /run/esphome/esphome.sock"
|
||||||
|
else "--address ${cfg.address} --port ${toString cfg.port}";
|
||||||
in {
|
in {
|
||||||
|
meta.maintainers = with maintainers; [oddlama];
|
||||||
|
|
||||||
options.services.esphome = {
|
options.services.esphome = {
|
||||||
enable = mkEnableOption (mdDoc "esphome");
|
enable = mkEnableOption (mdDoc "esphome");
|
||||||
|
|
||||||
|
@ -30,9 +36,11 @@ in {
|
||||||
description = mdDoc "The package to use for the esphome command.";
|
description = mdDoc "The package to use for the esphome command.";
|
||||||
};
|
};
|
||||||
|
|
||||||
enableUnixSocket = mkEnableOption (lib.mdDoc ''
|
enableUnixSocket = mkOption {
|
||||||
Expose a unix socket under /run/esphome/esphome.sock instead of using a TCP socket.
|
type = types.bool;
|
||||||
'');
|
default = false;
|
||||||
|
description = lib.mdDoc "Listen on a unix socket `/run/esphome/esphome.sock` instead of the TCP port.";
|
||||||
|
};
|
||||||
|
|
||||||
address = mkOption {
|
address = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
@ -95,20 +103,18 @@ in {
|
||||||
after = ["network.target"];
|
after = ["network.target"];
|
||||||
wantedBy = ["multi-user.target"];
|
wantedBy = ["multi-user.target"];
|
||||||
path = [cfg.package];
|
path = [cfg.package];
|
||||||
|
environment.PLATFORMIO_CORE_DIR = "${stateDir}/.platformio";
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = let
|
ExecStart = "${cfg.package}/bin/esphome dashboard ${esphomeParams} ${stateDir}";
|
||||||
extraParams =
|
|
||||||
if cfg.enableUnixSocket
|
|
||||||
then "--socket /run/${name}/esphome.sock"
|
|
||||||
else "--address ${cfg.address} --port ${toString cfg.port}";
|
|
||||||
in "${cfg.package}/bin/esphome dashboard ${extraParams} ${stateDir}";
|
|
||||||
DynamicUser = true;
|
DynamicUser = true;
|
||||||
|
User = "esphome";
|
||||||
|
Group = "esphome";
|
||||||
WorkingDirectory = stateDir;
|
WorkingDirectory = stateDir;
|
||||||
StateDirectory = name;
|
StateDirectory = "esphome";
|
||||||
StateDirectoryMode = "0750";
|
StateDirectoryMode = "0750";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RuntimeDirectory = mkIf cfg.enableUnixSocket name;
|
RuntimeDirectory = mkIf cfg.enableUnixSocket "esphome";
|
||||||
RuntimeDirectoryMode = "0750";
|
RuntimeDirectoryMode = "0750";
|
||||||
|
|
||||||
# Hardening
|
# Hardening
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue