summary refs log tree commit diff
path: root/pkgs/applications/misc/openrgb/default.nix
blob: bd1664e85ff51135f62ab7ca12ac8ff8c9859c06 (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
{ lib, stdenv, fetchFromGitLab, qmake, wrapQtAppsHook, libusb1, hidapi, pkg-config, coreutils, mbedtls_2, qtbase, qttools, symlinkJoin, openrgb }:

stdenv.mkDerivation rec {
  pname = "openrgb";
  version = "0.8";

  src = fetchFromGitLab {
    owner = "CalcProgrammer1";
    repo = "OpenRGB";
    rev = "release_${version}";
    sha256 = "sha256-46dL1D5oVlw6mNuFDCbbrUDmq42yFXV/qFJ1JnPT5/s=";
  };

  nativeBuildInputs = [ qmake pkg-config wrapQtAppsHook ];
  buildInputs = [ libusb1 hidapi mbedtls_2 qtbase qttools ];

  postPatch = ''
    patchShebangs scripts/build-udev-rules.sh
    substituteInPlace scripts/build-udev-rules.sh \
      --replace /bin/chmod "${coreutils}/bin/chmod"
  '';

  doInstallCheck = true;
  installCheckPhase = ''
    HOME=$TMPDIR $out/bin/openrgb --help > /dev/null
  '';

  passthru.withPlugins = plugins:
    let pluginsDir = symlinkJoin {
      name = "openrgb-plugins";
      paths = plugins;
      # Remove all library version symlinks except one,
      # or they will result in duplicates in the UI.
      # We leave the one pointing to the actual library, usually the most
      # qualified one (eg. libOpenRGBHardwareSyncPlugin.so.1.0.0).
      postBuild = ''
        for f in $out/lib/*; do
          if [ "$(dirname $(readlink "$f"))" == "." ]; then
            rm "$f"
          fi
        done
      '';
    };
    in openrgb.overrideAttrs (old: {
      qmakeFlags = old.qmakeFlags or [] ++ [
        # Welcome to Escape Hell, we have backslashes
        ''DEFINES+=OPENRGB_EXTRA_PLUGIN_DIRECTORY=\\\""${lib.escape ["\\" "\"" " "] (toString pluginsDir)}/lib\\\""''
      ];
    });

  meta = with lib; {
    description = "Open source RGB lighting control";
    homepage = "https://gitlab.com/CalcProgrammer1/OpenRGB";
    maintainers = with maintainers; [ jonringer ];
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
  };
}