about summary refs log tree commit diff
path: root/pkgs/applications/misc/openrgb
diff options
context:
space:
mode:
authorFrancesco Gazzetta <fgaz@fgaz.me>2023-01-27 11:33:58 +0100
committerFrancesco Gazzetta <fgaz@fgaz.me>2023-01-27 11:34:10 +0100
commit9aac134336f7596d8d2f7bb1a6f141673776a5db (patch)
treeff5d9004a384bbab8609b7c4f9786ad4cee78561 /pkgs/applications/misc/openrgb
parent2e03c5e81dd265271234695a4b09cc9ed12e8bff (diff)
openrgb: add withPlugins
Diffstat (limited to 'pkgs/applications/misc/openrgb')
-rw-r--r--pkgs/applications/misc/openrgb/default.nix25
1 files changed, 24 insertions, 1 deletions
diff --git a/pkgs/applications/misc/openrgb/default.nix b/pkgs/applications/misc/openrgb/default.nix
index ea81b58a2098c..bd1664e85ff51 100644
--- a/pkgs/applications/misc/openrgb/default.nix
+++ b/pkgs/applications/misc/openrgb/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitLab, qmake, wrapQtAppsHook, libusb1, hidapi, pkg-config, coreutils, mbedtls_2, qtbase, qttools }:
+{ lib, stdenv, fetchFromGitLab, qmake, wrapQtAppsHook, libusb1, hidapi, pkg-config, coreutils, mbedtls_2, qtbase, qttools, symlinkJoin, openrgb }:
 
 stdenv.mkDerivation rec {
   pname = "openrgb";
@@ -25,6 +25,29 @@ stdenv.mkDerivation rec {
     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";