diff options
author | Andreas Rammhold <andreas@rammhold.de> | 2021-12-18 23:01:33 +0100 |
---|---|---|
committer | Martin Weinelt <hexa@darmstadt.ccc.de> | 2022-06-22 16:20:11 +0200 |
commit | cfbcf381c27f0494f86f97056f43d1101ada715a (patch) | |
tree | a4d69fc77574d2d4f667109d208995067121fdce /nixos/modules | |
parent | e1e08fe28bf0588a41cd556eac40b98d2793da99 (diff) |
nixos/home-assistant: reload the daemon when configuration changed
Reload the service when configuration changes. This means that we don't have a potentially slow startup for every small configuration change.
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/services/home-automation/home-assistant.nix | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/nixos/modules/services/home-automation/home-assistant.nix b/nixos/modules/services/home-automation/home-assistant.nix index e255e5d22188b..2aacc5e55c6e2 100644 --- a/nixos/modules/services/home-automation/home-assistant.nix +++ b/nixos/modules/services/home-automation/home-assistant.nix @@ -369,6 +369,17 @@ in { networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.config.http.server_port ]; + # symlink the configuration to /etc/home-assistant + environment.etc = lib.mkMerge [ + (lib.mkIf (cfg.config != null && !cfg.configWritable) { + "home-assistant/configuration.yaml".source = configFile; + }) + + (lib.mkIf (cfg.lovelaceConfig != null && !cfg.lovelaceConfigWritable) { + "home-assistant/ui-lovelace.yaml".source = lovelaceConfigFile; + }) + ]; + systemd.services.home-assistant = { description = "Home Assistant"; after = [ @@ -378,18 +389,22 @@ in { "mysql.service" "postgresql.service" ]; + reloadTriggers = [ + configFile + lovelaceConfigFile + ]; preStart = let copyConfig = if cfg.configWritable then '' cp --no-preserve=mode ${configFile} "${cfg.configDir}/configuration.yaml" '' else '' rm -f "${cfg.configDir}/configuration.yaml" - ln -s ${configFile} "${cfg.configDir}/configuration.yaml" + ln -s /etc/home-assistant/configuration.yaml "${cfg.configDir}/configuration.yaml" ''; copyLovelaceConfig = if cfg.lovelaceConfigWritable then '' cp --no-preserve=mode ${lovelaceConfigFile} "${cfg.configDir}/ui-lovelace.yaml" '' else '' rm -f "${cfg.configDir}/ui-lovelace.yaml" - ln -s ${lovelaceConfigFile} "${cfg.configDir}/ui-lovelace.yaml" + ln -s /etc/home-assistant/ui-lovelace.yaml "${cfg.configDir}/ui-lovelace.yaml" ''; in (optionalString (cfg.config != null) copyConfig) + |