about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorRobert Schütz <rschuetz17@gmail.com>2019-03-03 02:23:23 +0100
committerGitHub <noreply@github.com>2019-03-03 02:23:23 +0100
commita3b6b49eac91baa25a01ef10b74a7aeb89a963a1 (patch)
tree0644ee4ab1f1eef8b9002f6b2080142341393610 /nixos
parent9fcbe8ef1725ce7c32f63429f4d5154dbf4a75ae (diff)
parent2f589e7d3d88041c08379873106a4ab17620bb94 (diff)
downloadnixlib-a3b6b49eac91baa25a01ef10b74a7aeb89a963a1.tar
nixlib-a3b6b49eac91baa25a01ef10b74a7aeb89a963a1.tar.gz
nixlib-a3b6b49eac91baa25a01ef10b74a7aeb89a963a1.tar.bz2
nixlib-a3b6b49eac91baa25a01ef10b74a7aeb89a963a1.tar.lz
nixlib-a3b6b49eac91baa25a01ef10b74a7aeb89a963a1.tar.xz
nixlib-a3b6b49eac91baa25a01ef10b74a7aeb89a963a1.tar.zst
nixlib-a3b6b49eac91baa25a01ef10b74a7aeb89a963a1.zip
Merge pull request #55383 from dotlambda/home-assistant-0.87
home-assistant: 0.86.4 -> 0.87.1
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/misc/home-assistant.nix20
1 files changed, 15 insertions, 5 deletions
diff --git a/nixos/modules/services/misc/home-assistant.nix b/nixos/modules/services/misc/home-assistant.nix
index 95a7f2ea989b..7f8d31bcf0b8 100644
--- a/nixos/modules/services/misc/home-assistant.nix
+++ b/nixos/modules/services/misc/home-assistant.nix
@@ -9,13 +9,13 @@ let
   configJSON = pkgs.writeText "configuration.json"
     (builtins.toJSON (if cfg.applyDefaultConfig then
     (recursiveUpdate defaultConfig cfg.config) else cfg.config));
-  configFile = pkgs.runCommand "configuration.yaml" { } ''
+  configFile = pkgs.runCommand "configuration.yaml" { preferLocalBuild = true; } ''
     ${pkgs.remarshal}/bin/json2yaml -i ${configJSON} -o $out
   '';
 
   lovelaceConfigJSON = pkgs.writeText "ui-lovelace.json"
     (builtins.toJSON cfg.lovelaceConfig);
-  lovelaceConfigFile = pkgs.runCommand "ui-lovelace.yaml" { } ''
+  lovelaceConfigFile = pkgs.runCommand "ui-lovelace.yaml" { preferLocalBuild = true; } ''
     ${pkgs.remarshal}/bin/json2yaml -i ${lovelaceConfigJSON} -o $out
   '';
 
@@ -29,14 +29,24 @@ let
   #   platform = "luftdaten";
   #   ...
   # } ];
+  #
+  # Beginning with 0.87 Home Assistant is migrating their components to the
+  # scheme "platform.subComponent", e.g. "hue.light" instead of "light.hue".
+  # See https://developers.home-assistant.io/blog/2019/02/19/the-great-migration.html.
+  # Hence, we also check whether we find an entry in the config when interpreting
+  # the first part of the path as the component.
   useComponentPlatform = component:
     let
       path = splitString "." component;
+      # old: platform is the last part of path
       parentConfig = attrByPath (init path) null cfg.config;
       platform = last path;
-    in isList parentConfig && any
-      (item: item.platform or null == platform)
-      parentConfig;
+      # new: platform is the first part of the path
+      parentConfig' = attrByPath (tail path) null cfg.config;
+      platform' = head path;
+    in
+      (isList parentConfig && any (item: item.platform or null == platform) parentConfig)
+      || (isList parentConfig' && any (item: item.platform or null == platform') parentConfig');
 
   # Returns whether component is used in config
   useComponent = component: