#
# Home assistant desktop app.
#
# vim: et:ts=2:sw=2:
{
  lib,
  appimageTools,
  fetchurl,
}:
let
  pname = "home-assistant-desktop";
  version = "1.5.3";

  src = fetchurl {
    url = "https://github.com/iprodanovbg/homeassistant-desktop/releases/download/v1.5.3/Home-Assistant-Desktop-v1.5.3-linux-x86_64.AppImage";
    hash = "sha256-0N4xXbqQP1ybkTdzRceyYjgda09U8Dp7eIG22cXWRwE=";
  };

  appImageContent = appimageTools.extractType2 { inherit pname version src; };
in
appimageTools.wrapType2 {
  inherit pname version src;

  runScript = "appimage-exec.sh -w ${appImageContent} -- \${NIXOS_OZONE_WL:+\${WAYLAND_DISPLAY:+--ozone-platform-hint=auto}} --disable-sandbox";
  extraPkgs =
    { pkgs, ... }@args: [ pkgs.libappindicator ] ++ appimageTools.defaultFhsEnvArgs.multiPkgs args;

  meta = {
    homepage = "https://github.com/iprodanovbg/homeassistant-desktop";
    description = "HomeAssistant UI for the desktop";
    platforms = [ "x86_64-linux" ];
    license = lib.licenses.asl20;
  };
}
