diff options
author | Robert Schütz <robert.schuetz@stud.uni-heidelberg.de> | 2019-02-27 14:32:37 +0100 |
---|---|---|
committer | Robert Schütz <robert.schuetz@stud.uni-heidelberg.de> | 2019-03-02 12:37:48 +0100 |
commit | 971187eadaf00a86a57951823ab844e9c23694ac (patch) | |
tree | 61bda59227fb67d940fcada90012b06346f7f12b | |
parent | 27fb4f46d2af70ba59d3d49f1c9f8dbb5fd974d4 (diff) | |
download | nixlib-971187eadaf00a86a57951823ab844e9c23694ac.tar nixlib-971187eadaf00a86a57951823ab844e9c23694ac.tar.gz nixlib-971187eadaf00a86a57951823ab844e9c23694ac.tar.bz2 nixlib-971187eadaf00a86a57951823ab844e9c23694ac.tar.lz nixlib-971187eadaf00a86a57951823ab844e9c23694ac.tar.xz nixlib-971187eadaf00a86a57951823ab844e9c23694ac.tar.zst nixlib-971187eadaf00a86a57951823ab844e9c23694ac.zip |
nixos/home-assistant: account for "The Great Migration"
See https://developers.home-assistant.io/blog/2019/02/19/the-great-migration.html and https://github.com/NixOS/nixpkgs/issues/55958#issuecomment-466793526.
-rw-r--r-- | nixos/modules/services/misc/home-assistant.nix | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/nixos/modules/services/misc/home-assistant.nix b/nixos/modules/services/misc/home-assistant.nix index 95a7f2ea989b..5ee5e4dc5632 100644 --- a/nixos/modules/services/misc/home-assistant.nix +++ b/nixos/modules/services/misc/home-assistant.nix @@ -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: |