Subject: [bug#52960] [PATCH 2/2] gnu: Add openrgb.

From: John Kehayias <[email-masked]>
Date: Sun, 02 Jan 2022 17:16:35 +0000

Empty Message

From a94e57199dfe0fa9c3b11d5b6075f7be25105f74 Mon Sep 17 00:00:00 2001
From: John Kehayias <[email-masked]>
Date: Sun, 2 Jan 2022 11:55:27 -0500
Subject: [PATCH 2/2] gnu: Add openrgb.

* gnu/packages/hardware.scm (openrgb): New variable.
* gnu/packages/patches/openrgb-unbundle-hueplusplus.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/hardware.scm                     | 69 +++++++++++++++++++
 .../openrgb-unbundle-hueplusplus.patch        | 58 ++++++++++++++++
 3 files changed, 128 insertions(+)
 create mode 100644 gnu/packages/patches/openrgb-unbundle-hueplusplus.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index b427edb4a4..a162275eca 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1559,6 +1559,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/openmpi-mtl-priorities.patch		\
   %D%/packages/patches/openssh-hurd.patch			\
   %D%/packages/patches/openresolv-restartcmd-guix.patch	\
+  %D%/packages/patches/openrgb-unbundle-hueplusplus.patch	\
   %D%/packages/patches/opensles-add-license-file.patch			\
   %D%/packages/patches/openssl-runpath.patch			\
   %D%/packages/patches/openssl-1.1-c-rehash-in.patch		\
diff --git a/gnu/packages/hardware.scm b/gnu/packages/hardware.scm
index 227a359adb..a146132b04 100644
--- a/gnu/packages/hardware.scm
+++ b/gnu/packages/hardware.scm
@@ -651,6 +651,75 @@ (define-public openhmd
 technology, such as head mounted displays with built in head tracking.")
     (license license:boost1.0)))
 
+(define-public openrgb
+  (package
+    (name "openrgb")
+    (version "0.7")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://gitlab.com/CalcProgrammer1/OpenRGB")
+             (commit (string-append "release_" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0xhfaz0b74nfnh7il2cz5c0338xlzay00g6hc2h3lsncarj8d5n7"))
+       (patches
+        (search-patches "openrgb-unbundle-hueplusplus.patch"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           ;; Delete the bundled hueplusplus and json libraries.
+           (delete-file-recursively "dependencies/hueplusplus-1.0.0")
+           (delete-file-recursively "dependencies/json")))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:tests? #f ; doesn't have tests
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'unbundle
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "OpenRGB.pro"
+               (("dependencies/hueplusplus-1.0.0/include/hueplusplus")
+                (search-input-directory inputs "include/hueplusplus"))
+               (("dependencies/json")
+                (search-input-directory inputs "include/nlohmann")))))
+         ;; Call qmake instead of configure to create a Makefile.
+         (replace 'configure
+           (lambda _ (invoke "qmake" "PREFIX=/" "OpenRGB.pro"))))
+       #:make-flags
+       (list (string-append "INSTALL_ROOT=" (assoc-ref %outputs "out")))))
+    (inputs
+     (list hidapi
+           hueplusplus
+           json-modern-cxx
+           libusb
+           mbedtls-apache
+           qtbase-5))
+    (native-inputs
+     (list pkg-config))
+    (synopsis "Open source RGB lighting control")
+    (description
+     "OpenRGB is lighting control that doesn't depend on manufacturer software.
+ASUS, ASRock, Corsair, G.Skill, Gigabyte, HyperX, MSI, Razer, ThermalTake, and more
+supported.
+
+Features:
+
+@itemize
+@item Set colors and select effect modes for a wide variety of RGB hardware
+@item Save and load profiles
+@item Control lighting from third party software using the OpenRGB SDK
+@item Command line interface
+@item Connect multiple instances of OpenRGB to synchronize lighting across multiple PCs
+@item Can operate standalone or in a client/headless server configuration
+@item View device information
+@item No official/manufacturer software required
+@item Graphical view of device LEDs makes creating custom patterns easy
+@end itemize")
+    (home-page "https://openrgb.org/")
+    (license license:gpl2))) ; Included libccmmk is lgpl3+, CRC is bsd-3
+
 (define-public wavemon
   (package
     (name "wavemon")
diff --git a/gnu/packages/patches/openrgb-unbundle-hueplusplus.patch b/gnu/packages/patches/openrgb-unbundle-hueplusplus.patch
new file mode 100644
index 0000000000..7454e1efbe
--- /dev/null
+++ b/gnu/packages/patches/openrgb-unbundle-hueplusplus.patch
@@ -0,0 +1,58 @@
+Remove references to hueplusplus in order to unbundle and use the input package.
+
+diff --git a/OpenRGB.pro b/OpenRGB.pro
+index 61758892..8702d998 100644
+--- a/OpenRGB.pro
++++ b/OpenRGB.pro
+@@ -493,35 +493,6 @@ SOURCES +=
+     dependencies/Swatches/swatches.cpp                                                          \
+     dependencies/dmiinfo.cpp                                                                    \
+     dependencies/ColorWheel/ColorWheel.cpp                                                      \
+-    dependencies/hueplusplus-1.0.0/src/Action.cpp                                               \
+-    dependencies/hueplusplus-1.0.0/src/APICache.cpp                                             \
+-    dependencies/hueplusplus-1.0.0/src/BaseDevice.cpp                                           \
+-    dependencies/hueplusplus-1.0.0/src/BaseHttpHandler.cpp                                      \
+-    dependencies/hueplusplus-1.0.0/src/Bridge.cpp                                               \
+-    dependencies/hueplusplus-1.0.0/src/BridgeConfig.cpp                                         \
+-    dependencies/hueplusplus-1.0.0/src/CLIPSensors.cpp                                          \
+-    dependencies/hueplusplus-1.0.0/src/ColorUnits.cpp                                           \
+-    dependencies/hueplusplus-1.0.0/src/EntertainmentMode.cpp                                    \
+-    dependencies/hueplusplus-1.0.0/src/ExtendedColorHueStrategy.cpp                             \
+-    dependencies/hueplusplus-1.0.0/src/ExtendedColorTemperatureStrategy.cpp                     \
+-    dependencies/hueplusplus-1.0.0/src/Group.cpp                                                \
+-    dependencies/hueplusplus-1.0.0/src/HueCommandAPI.cpp                                        \
+-    dependencies/hueplusplus-1.0.0/src/HueDeviceTypes.cpp                                       \
+-    dependencies/hueplusplus-1.0.0/src/HueException.cpp                                         \
+-    dependencies/hueplusplus-1.0.0/src/Light.cpp                                                \
+-    dependencies/hueplusplus-1.0.0/src/ModelPictures.cpp                                        \
+-    dependencies/hueplusplus-1.0.0/src/NewDeviceList.cpp                                        \
+-    dependencies/hueplusplus-1.0.0/src/Scene.cpp                                                \
+-    dependencies/hueplusplus-1.0.0/src/Schedule.cpp                                             \
+-    dependencies/hueplusplus-1.0.0/src/Sensor.cpp                                               \
+-    dependencies/hueplusplus-1.0.0/src/SimpleBrightnessStrategy.cpp                             \
+-    dependencies/hueplusplus-1.0.0/src/SimpleColorHueStrategy.cpp                               \
+-    dependencies/hueplusplus-1.0.0/src/SimpleColorTemperatureStrategy.cpp                       \
+-    dependencies/hueplusplus-1.0.0/src/StateTransaction.cpp                                     \
+-    dependencies/hueplusplus-1.0.0/src/TimePattern.cpp                                          \
+-    dependencies/hueplusplus-1.0.0/src/UPnP.cpp                                                 \
+-    dependencies/hueplusplus-1.0.0/src/Utils.cpp                                                \
+-    dependencies/hueplusplus-1.0.0/src/ZLLSensors.cpp                                           \
+     dependencies/libe131/src/e131.c                                                             \
+     dependencies/libcmmk/src/libcmmk.c                                                          \
+     main.cpp                                                                                    \
+@@ -1188,6 +1159,7 @@ unix:!macx {
+     -lmbedx509                                                                                  \
+     -lmbedtls                                                                                   \
+     -lmbedcrypto                                                                                \
++    -lhueplusplusshared                                                                         \
+ 
+     COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
+     if (!versionAtLeast(COMPILER_VERSION, "9")) {
+@@ -1218,7 +1190,6 @@ unix:!macx {
+     }
+ 
+     SOURCES +=                                                                                  \
+-    dependencies/hueplusplus-1.0.0/src/LinHttpHandler.cpp                                       \
+     i2c_smbus/i2c_smbus_linux.cpp                                                               \
+     serial_port/find_usb_serial_port_linux.cpp                                                  \
+     AutoStart/AutoStart-Linux.cpp                                                               \
-- 
2.34.0