From 1a59f4d7b37117b0c470c11bbe8a92620c649469 Mon Sep 17 00:00:00 2001 From: "root@nixos-nas" <> Date: Wed, 11 Jun 2025 19:11:16 +0000 Subject: [PATCH] kodi & tv-wakeup --- configuration.nix | 49 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/configuration.nix b/configuration.nix index 859a67d..325b2cd 100644 --- a/configuration.nix +++ b/configuration.nix @@ -65,7 +65,7 @@ # Wir pinnen den Kernel, bis ZFS 2.3.x für 6.13 bereit ist boot.kernelPackages = pkgs.linuxPackages_6_12; - environment.systemPackages = with pkgs; [ git vim zfs ]; + environment.systemPackages = with pkgs; [ git vim zfs virt-viewer ]; #### Virtualisation @@ -77,8 +77,7 @@ #### nix-Cache - - # --- Binary-Cache ------------------------------------------------------------- + # --- Binary-Cache services.nix-serve = { enable = true; secretKeyFile = "/var/cache/nix/secret-key"; @@ -95,5 +94,49 @@ secret-key-files = [ "/var/cache/nix/secret-key" ]; }; + ########################################################################## + ### Kodi & TV-Detect ##################################################### + ########################################################################## + + ### UDEV-Regel + Skript ################################################## + services.udev.extraRules = '' + ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", \ + RUN+="/etc/udev/scripts/hdmi-handler.sh" + ''; + + environment.etc."udev/scripts/hdmi-handler.sh".text = '' + #!/usr/bin/env bash + PORT="/sys/class/drm/card0-HDMI-A-1/status" + USER="nicole" + + read status < "$PORT" + if [[ "$status" == "connected" ]]; then + # Fernseher an ➜ Kodi starten + runuser -l "$USER" -c "systemctl --user start kodi.service" + # Beispiel: alternative Wartungs-VM + # runuser -l "$USER" -c "systemctl --user start vm-viewer@ha-vm.service" + else + # Fernseher aus ➜ alles stoppen + runuser -l "$USER" -c "systemctl --user stop vm-viewer@ha-vm.service" || true + runuser -l "$USER" -c "systemctl --user stop kodi.service" + fi + ''; + environment.etc."udev/scripts/hdmi-handler.sh".mode = "0755"; + + ### Kodi (GBM-Wayland Variante) ########################################## + programs.kodi = { + enable = true; + package = pkgs.kodi; # ← Standard; wähle ggf. `pkgs.kodi-wayland` + gpuSupport = true; # deaktiviert X11-Abhängigkeit + }; + + ### Virt-Viewer Template-Unit (optional) ################################# + systemd.user.services."vm-viewer@" = { + description = "Virt-viewer fullscreen for %i"; + serviceConfig = { + ExecStart = "${pkgs.virt-viewer}/bin/virt-viewer --full-screen --wait --domain-name %i"; + Restart = "on-failure"; + }; + }; }