feat: add yaml2nix script
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-09-13 17:26:50 -04:00
parent defc94db8a
commit e9d02bdf36

View file

@ -1,4 +1,4 @@
{...}: { {pkgs, ...}: {
imports = [ imports = [
./assist.nix ./assist.nix
./bluetooth.nix ./bluetooth.nix
@ -6,6 +6,25 @@
./frontend.nix ./frontend.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
'';
})
];
# TODO: some components / integrations / addons require manual interaction in the GUI, find way to make it all declarative # TODO: some components / integrations / addons require manual interaction in the GUI, find way to make it all declarative
services.home-assistant = { services.home-assistant = {
enable = true; enable = true;