diff --git a/devices/homie/modules/home-assistant/default.nix b/devices/homie/modules/home-assistant/default.nix index 5ed36529..8fc8bec6 100644 --- a/devices/homie/modules/home-assistant/default.nix +++ b/devices/homie/modules/home-assistant/default.nix @@ -9,43 +9,6 @@ ./timer.nix ]; - environment.systemPackages = [ - (pkgs.writeShellApplication { - name = "yaml2nix"; - runtimeInputs = with pkgs; [yj]; - text = '' - input="$(yj < "$1")" - output="''${2:-""}" - - nixCode="$(nix eval --expr "builtins.fromJSON '''$input'''" --impure | alejandra -q | sed 's/ = null;/ = {};/g')" - - if [[ "$output" != "" ]]; then - echo "$nixCode" > "$output" - else - echo "$nixCode" - fi - ''; - }) - - (pkgs.writeShellApplication { - name = "nix2yaml"; - runtimeInputs = with pkgs; [remarshal]; - text = '' - input="$1" - output="''${2:-""}" - - yamlCode="$(nix eval --json --file "$input" | remarshal --if json --of yaml)" - - if [[ "$output" != "" ]]; then - echo "$yamlCode" > "$output" - else - echo "$yamlCode" - fi - ''; - }) - ]; - - # TODO: some components / integrations / addons require manual interaction in the GUI, find way to make it all declarative services.home-assistant = { enable = true; @@ -90,4 +53,40 @@ zeroconf = {}; }; }; + + environment.systemPackages = [ + (pkgs.writeShellApplication { + name = "yaml2nix"; + runtimeInputs = with pkgs; [yj]; + text = '' + input="$(yj < "$1")" + output="''${2:-""}" + + nixCode="$(nix eval --expr "builtins.fromJSON '''$input'''" --impure | alejandra -q | sed 's/ = null;/ = {};/g')" + + if [[ "$output" != "" ]]; then + echo "$nixCode" > "$output" + else + echo "$nixCode" + fi + ''; + }) + + (pkgs.writeShellApplication { + name = "nix2yaml"; + runtimeInputs = with pkgs; [remarshal]; + text = '' + input="$1" + output="''${2:-""}" + + yamlCode="$(nix eval --json --file "$input" | remarshal --if json --of yaml)" + + if [[ "$output" != "" ]]; then + echo "$yamlCode" > "$output" + else + echo "$yamlCode" + fi + ''; + }) + ]; } diff --git a/devices/homie/modules/home-assistant/frontend.nix b/devices/homie/modules/home-assistant/frontend.nix index de94ba25..3a74529e 100644 --- a/devices/homie/modules/home-assistant/frontend.nix +++ b/devices/homie/modules/home-assistant/frontend.nix @@ -36,7 +36,7 @@ in { material-symbols = pkgs.stdenv.mkDerivation { pname = "material-symbols"; - version = "0.0.0"; + version = "0.0.0+${material-symbols-src.shortRev}"; src = material-symbols-src; phases = ["installPhase"]; installPhase = '' @@ -51,6 +51,18 @@ in { extra_module_url = ["/local/nixos-lovelace-modules/card-mod.js"]; }; + config.template = [ + { + sensor = [ + { + name = "Material Rounded Base Color Matt"; + unique_id = "material_rounded_base_color_matt"; + state = ''{{ states("sensor.pixel_8_accent_color") }}''; + } + ]; + } + ]; + lovelaceConfig = { title = "Our House"; views = [