refactor: move ESPHome config into Home Assistant folder
This commit is contained in:
parent
029b83ef4e
commit
175960af77
3 changed files with 3 additions and 2 deletions
|
@ -6,6 +6,8 @@ let
|
|||
port = config.services.home-assistant.config.http.server_port;
|
||||
geniePort = 3232;
|
||||
in {
|
||||
imports = [ ./esphome.nix ];
|
||||
|
||||
# just installed for ConBee firmware updates
|
||||
environment.systemPackages = with pkgs; [ deconz ];
|
||||
|
||||
|
|
33
services/home-assistant/esphome.nix
Normal file
33
services/home-assistant/esphome.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
let
|
||||
port = 6052;
|
||||
inherit (config.services.home-assistant) configDir;
|
||||
passwordFile = config.age.secrets.esphome-password.path;
|
||||
in {
|
||||
age.secrets.esphome-password.file = ../../secrets/esphome/password.age;
|
||||
|
||||
services.nginx = {
|
||||
virtualHosts."esphome.felschr.com" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:${toString port}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.esphome = {
|
||||
description = "ESPHome";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig.LoadCredential = [ "password:${passwordFile}" ];
|
||||
script = ''
|
||||
password="$(<"$CREDENTIALS_DIRECTORY/password")"
|
||||
${pkgs.esphome}/bin/esphome dashboard ${configDir}/esphome --password "$password"
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue