Commit 3830a3db authored by Atemu's avatar Atemu
Browse files

teamspeak_client: modernise installPhase

parent 49a5c643
Loading
Loading
Loading
Loading
+37 −45
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
  stdenv,
  fetchurl,
  fetchzip,
  makeWrapper,
  makeDesktopItem,
  glib,
  qt5,
@@ -12,20 +11,15 @@
  perl,
  libcxx,
  autoPatchelfHook,
  copyDesktopItems,
}:

let

  arch = "amd64";

  desktopItem = makeDesktopItem {
    name = "teamspeak";
    exec = "ts3client";
    icon = "teamspeak";
    comment = "The TeamSpeak voice communication tool";
    desktopName = "TeamSpeak";
    genericName = "TeamSpeak";
    categories = [ "Network" ];
  pluginsdk = fetchzip {
    url = "https://files.teamspeak-services.com/releases/sdk/3.3.1/ts_sdk_3.3.1.zip";
    hash = "sha256-wx4pBZHpFPoNvEe4xYE80KnXGVda9XcX35ho4R8QxrQ=";
  };
in

@@ -39,17 +33,11 @@ stdenv.mkDerivation rec {
    hash = "sha256-WfEQQ4lxoj+QSnAOfdCoEc+Z1Oa5dbo6pFli1DsAZCI=";
  };

  # grab the plugin sdk for the desktop icon
  pluginsdk = fetchzip {
    url = "https://files.teamspeak-services.com/releases/sdk/3.3.1/ts_sdk_3.3.1.zip";
    hash = "sha256-wx4pBZHpFPoNvEe4xYE80KnXGVda9XcX35ho4R8QxrQ=";
  };

  nativeBuildInputs = [
    makeWrapper
    perl # Installer script needs `shasum`
    qt5.wrapQtAppsHook
    autoPatchelfHook
    copyDesktopItems
  ];

  buildInputs =
@@ -100,35 +88,39 @@ stdenv.mkDerivation rec {
  dontConfigure = true;
  dontBuild = true;

  installPhase =
    ''
  desktopItems = [
    (makeDesktopItem {
      name = "teamspeak";
      exec = "ts3client";
      icon = "teamspeak";
      comment = "The TeamSpeak voice communication tool";
      desktopName = "TeamSpeak";
      genericName = "TeamSpeak";
      categories = [ "Network" ];
    })
  ];

  qtWrapperArgs = [
    # wayland is currently broken, remove when TS3 fixes that
    "--set QT_QPA_PLATFORM xcb"
    "--set NIX_REDIRECTS /usr/share/X11/xkb=${xkeyboard_config}/share/X11/xkb"
  ];

  installPhase = ''
    runHook preInstall

      # Install files.
    mkdir -p $out/lib/teamspeak
    mv * $out/lib/teamspeak/

      # Make a desktop item
      mkdir -p $out/share/applications/ $out/share/icons/hicolor/64x64/apps/
      cp ${pluginsdk}/doc/_static/logo.png $out/share/icons/hicolor/64x64/apps/teamspeak.png
      cp ${desktopItem}/share/applications/* $out/share/applications/
    # Grab the desktop icon from the plugin sdk
    install ${pluginsdk}/doc/_static/logo.png -D $out/share/icons/hicolor/64x64/apps/teamspeak.png

      # Make a symlink to the binary from bin.
    mkdir -p $out/bin/
    ln -s $out/lib/teamspeak/ts3client $out/bin/ts3client

    runHook postInstall
  '';

  preFixup =
    ''
      wrapProgram $out/bin/ts3client \
    '' # wayland is currently broken, remove when TS3 fixes that
    + ''
      --set QT_QPA_PLATFORM xcb \
      --set NIX_REDIRECTS /usr/share/X11/xkb=${xkeyboard_config}/share/X11/xkb
    '';

  meta = with lib; {
    description = "TeamSpeak voice communication tool";
    homepage = "https://teamspeak.com/";