about summary refs log tree commit diff
path: root/pkgs/by-name/mo/moonlight-qt/package.nix
blob: a0ca66b61e644264b5a67749b1c878ddeb9be344 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{
  stdenv,
  lib,
  fetchFromGitHub,
  fetchpatch,
  darwin,
  overrideSDK,
  qt6,
  pkg-config,
  vulkan-headers,
  SDL2,
  SDL2_ttf,
  ffmpeg,
  libopus,
  libplacebo,
  openssl,
  alsa-lib,
  libpulseaudio,
  libva,
  libvdpau,
  libxkbcommon,
  wayland,
  libdrm,
  nix-update-script,
}:

let
  inherit (darwin.apple_sdk_11_0.frameworks)
    AVFoundation
    AppKit
    AudioUnit
    Cocoa
    VideoToolbox
    ;
  stdenv' = if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv;
in

stdenv'.mkDerivation rec {
  pname = "moonlight-qt";
  version = "6.0.1";

  src = fetchFromGitHub {
    owner = "moonlight-stream";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-zrl8WPXvQ/7FTqFnpwoXEJ85prtgJWoWNsdckw5+JHI=";
    fetchSubmodules = true;
  };

  patches = [
    # Don't precompile QML files with disable-prebuilts, fix build on darwin
    (fetchpatch {
      url = "https://github.com/moonlight-stream/moonlight-qt/commit/d73df12367749425b86b72c250bb0fba13ddfd29.patch";
      hash = "sha256-RIrQpZWbwUHs1Iwz/pXfXgshJeHYrzGxuaR5mRG85QY=";
    })
  ];

  nativeBuildInputs = [
    qt6.qmake
    qt6.wrapQtAppsHook
    pkg-config
    vulkan-headers
  ];

  buildInputs =
    [
      (SDL2.override { drmSupport = stdenv.isLinux; })
      SDL2_ttf
      ffmpeg
      libopus
      libplacebo
      qt6.qtdeclarative
      qt6.qtsvg
      openssl
    ]
    ++ lib.optionals stdenv.isLinux [
      alsa-lib
      libpulseaudio
      libva
      libvdpau
      libxkbcommon
      qt6.qtwayland
      wayland
      libdrm
    ]
    ++ lib.optionals stdenv.isDarwin [
      AVFoundation
      AppKit
      AudioUnit
      Cocoa
      VideoToolbox
    ];

  qmakeFlags = [ "CONFIG+=disable-prebuilts" ];

  postInstall = lib.optionalString stdenv.isDarwin ''
    mkdir $out/Applications $out/bin
    mv app/Moonlight.app $out/Applications
    ln -s $out/Applications/Moonlight.app/Contents/MacOS/Moonlight $out/bin/moonlight
  '';

  passthru.updateScript = nix-update-script { };

  meta = with lib; {
    description = "Play your PC games on almost any device";
    homepage = "https://moonlight-stream.org";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [
      azuwis
      luc65r
      zmitchell
    ];
    platforms = platforms.all;
    mainProgram = "moonlight";
  };
}