idk
This commit is contained in:
25
modules/nixos/homeassistant/dashboards/default.nix
Normal file
25
modules/nixos/homeassistant/dashboards/default.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
namespace,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.${namespace}.services.home-assistant;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
config = lib.mkIf (cfg.enable && cfg.dashboards != [ ]) {
|
||||
${namespace}.home.file = lib.genAttrs cfg.dashboards (
|
||||
dashboard:
|
||||
let
|
||||
dashboardFile = "homeassistant/lovelace/${dashboard.title}.yaml";
|
||||
in
|
||||
{
|
||||
text = lib.generators.toYAML { } dashboard;
|
||||
force = true;
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
10
modules/nixos/homeassistant/dashboards/options.nix
Normal file
10
modules/nixos/homeassistant/dashboards/options.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
let
|
||||
inherit (lib.${namespace}) mkOpt;
|
||||
in
|
||||
{
|
||||
options.${namespace}.services.home-assistant.dashboards =
|
||||
mkOpt (types.listOf types.attrs) [ ]
|
||||
"Home Assistant dashboards configuration";
|
||||
}
|
||||
@@ -8,7 +8,10 @@ let
|
||||
cfg = config.${namespace}.services.home-assistant;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
imports = [
|
||||
./options.nix
|
||||
./dashboards
|
||||
];
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# This bypasses the component validation and places it directly in HA's data directory
|
||||
|
||||
Reference in New Issue
Block a user