Subject: [bug#49970] [PATCH] gnu: Add librealsense.

From: phodina <[email-masked]>
Date: Mon, 09 Aug 2021 20:54:04 +0000

* gnu/packages/video.scm (librealsense): New variable.

diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm
index 399327741f..1d4a8ad3df 100644
--- a/gnu/packages/video.scm
+++ b/gnu/packages/video.scm
@@ -53,6 +53,7 @@
 ;;; Copyright © 2021 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2020 Hartmut Goebel <[email-masked]>
 ;;; Copyright © 2021 Raghav Gururajan <[email-masked]>
+;;; Copyright © 2021 Petr Hodina <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -145,6 +146,7 @@
   #:use-module (gnu packages mp3)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages networking)
+  #:use-module (gnu packages ninja)
   #:use-module (gnu packages ocr)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages perl)
@@ -577,6 +579,53 @@ other software.")
       ;; Library.
       license:lgpl3+))))

+(define-public librealsense
+ (package
+  (name "librealsense")
+  (version "2.45.0")
+  (source (origin
+           (method git-fetch)
+           (uri (git-reference
+                 (url "https://github.com/IntelRealSense/librealsense")
+                 (commit (string-append "v" version))))
+           (patches
+            (search-patches "librealsense-remove-network-connectivity.patch"))
+           (file-name (git-file-name name version))
+           (modules '((guix build utils)))
+            (sha256
+             (base32
+              "0aqf48zl7825v7x8c3x5w4d17m4qq377f1mn6xyqzf9b0dnk4i1j"))))
+  (build-system cmake-build-system)
+  (arguments
+       `(#:tests? #f
+         #:configure-flags (list "-DBUILD_EXAMPLES=ON"
+                                 "-DBUILD_GRAPHICAL_EXAMPLES=ON"
+                                 "-DINTERNET_CONNECTION=OFF"
+                                 "-DCHECK_FOR_UPDATES=OFF")
+         #:phases
+           (modify-phases %standard-phases
+            ;; more convenient than manually invoking setup_udev_rules.sh
+            ;; and substituting the path in the script
+            (add-after 'install 'copy-udev-rules
+              (lambda* (#:key outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out")))
+               (mkdir-p (string-append out "/etc/udev/rules.d"))
+               (copy-file "config/99-realsense-libusb.rules"
+                          (string-append out
+                           "/etc/udev/rules.d/99-realsense-libusb.rules"))))))))
+  (native-inputs `(("pkg-config" ,pkg-config)
+                   ("ninja" ,ninja)))
+  (inputs `(("glfw" ,glfw)
+            ("gtk+" ,gtk+)
+            ("libusb" ,libusb)
+            ("glu" ,glu)))
+  (synopsis "Intel RealSense SDK")
+  (description "Intel RealSense SDK 2.0 is a cross-platform library for
+Intel RealSense depth cameras (D400 & L500 series and the SR300) and the
+T265 tracking camera.")
+  (home-page "https://github.com/IntelRealSense/librealsense")
+  (license license:gpl3)))
+
 (define-public tslib
   (package
     (name "tslib")
--
2.32.0