diff mbox series

[bug#41294] gnu: Add libfreenect.

Message ID 5kf9uJF2SDo9zwlTUoFI13o7P7q68o-AuSp72MvOp5PUaF2SlAPxzQJvFws5aaTOB5EHY4T3-En0Mhba7hADMIeJkgCeWUOY_Ciy0fv24Ck=@elenq.tech
State Accepted
Headers show
Series [bug#41294] gnu: Add libfreenect. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job

Commit Message

Ekaitz Zarraga May 15, 2020, 9:47 p.m. UTC
Hi,

Adding libfreenect as discussed here:

https://issues.guix.gnu.org/40492

I have some doubts with this package:

- It has some extra flags that can be set in the configure step to build some python bindings. I didn't set them because they also require a python interpreter. How is the best way to handle that? Make another package with the flags set? Activate them by default? Leave them as I did?

- The package is 300 megs checking `guix size` that's because it has some testing binaries that have extra dependencies. If only the library is compiled it doesn't depend on GLUT and that reduces the size a lot. I tried to separate the package's outputs but I don't know how to do it correctly (I checked the docs but it doesn't go in detail). I'd like to do it but I need some help.

- I'm not sure if the file where I added it is a good choice.

Best,

Ekaitz

---

From aa74e0b4872f6a2748ed919ebe3c265472d04664 Mon Sep 17 00:00:00 2001
From: Ekaitz Zarraga <ekaitz@elenq.tech>
Date: Fri, 15 May 2020 23:22:04 +0200
Subject: [PATCH] gnu: Add libfreenect.

    * gnu/packages/libusb (libfreenect): New variable.
---
 gnu/packages/libusb.scm | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

--
2.26.1

Comments

宋文武 May 16, 2020, 3:48 a.m. UTC | #1
Ekaitz Zarraga <ekaitz@elenq.tech> writes:

> Hi,

Hello,
>
> Adding libfreenect as discussed here:
>
> https://issues.guix.gnu.org/40492
>
> I have some doubts with this package:
>
> - It has some extra flags that can be set in the configure step to build some python bindings. I didn't set them because they also require a python interpreter. How is the best way to handle that? Make another package with the flags set? Activate them by default? Leave them as I did?

We generally try to enable all optional features when adding a package,
I'd go with:

  1. Build the python bindings by default.

  2. Try seperate the python bindings into another output.  (eg: newt)

  3. If 1 and 2 seems difficult, try add a seperate package for the
  python bindings, and it better only contains the bindings, reuse the
  original package as input.  (eg: python-libxml2)

  4. If not feel lucky, just leave a TODO comment for it...


>
> - The package is 300 megs checking `guix size` that's because it has some testing binaries that have extra dependencies. If only the library is compiled it doesn't depend on GLUT and that reduces the size a lot. I tried to separate the package's outputs but I don't know how to do it correctly (I checked the docs but it doesn't go in detail). I'd like to do it but I need some help.

To define a packages with multiple outputs:

- Decide what ‘outputs’ can be made, eg: ‘doc’, ‘bin’, ‘examples’,
  etc.  In this case, I’d add an ‘examples’ output, to put those
  ‘freenect-*’ binaries, built from the “examples” directory.
  
- Add an ‘outputs’ field, it default to ‘(list "out")’, We’d use
  ‘(outputs '("out" "examples")’.

- Modify the install flags or phases to get files into their output
  directory.  Sometimes we can configure the target directory by flags,
  but usually we have to move the files around after the install phase…
  
You can see ‘newt’ in ‘gnu/packages/slang.scm’ for a example.  

>
> - I'm not sure if the file where I added it is a good choice.

Same here, we can always move it later…

>
> Best,
>
> Ekaitz
>
> ---
>
>>From aa74e0b4872f6a2748ed919ebe3c265472d04664 Mon Sep 17 00:00:00 2001
> From: Ekaitz Zarraga <ekaitz@elenq.tech>
> Date: Fri, 15 May 2020 23:22:04 +0200
> Subject: [PATCH] gnu: Add libfreenect.
>
>     * gnu/packages/libusb (libfreenect): New variable.
> ---
>  gnu/packages/libusb.scm | 39 ++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm
> index 3842f3fead..a27373c15a 100644
> --- a/gnu/packages/libusb.scm
> +++ b/gnu/packages/libusb.scm
> @@ -10,6 +10,7 @@
>  ;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
>  ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
>  ;;; Copyright © 2020 Christopher Howard <christopher@librehacker.com>
> +;;; Copyright © 2020 Ekaitz Zarraga <ekaitz@elenq.tech>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -48,7 +49,8 @@
>    #:use-module (gnu packages python)
>    #:use-module (gnu packages python-xyz)
>    #:use-module (gnu packages tls)
> -  #:use-module (gnu packages xiph))
> +  #:use-module (gnu packages xiph)
> +  #:use-module (gnu packages gl))
>
>  (define-public libusb
>    (package
> @@ -679,3 +681,38 @@ HID-Class devices.")
>
>  (define-public python2-hidapi
>    (package-with-python2 python-hidapi))
> +
> +(define-public libfreenect
> +  (let ((version "0.6.1"))
> +    (package
> +      (name "libfreenect")
> +      (version version)
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url "https://github.com/OpenKinect/libfreenect")
> +                      (commit (string-append "v" version))))
> +                (sha256
> +                 (base32 "0was1va167rqshmpn382h36yyprpfi9cwillb6ylppmnfdrfrhrr"))))
> +      (build-system cmake-build-system)
> +      (arguments
> +       `(#:tests? #f ;; Project has not tests
This ` quasiquote is unnecessary here, a ' quote is enough, because we
refer nothing outside in the arguments list.

By convention, a single semicolon is for comment after expression in the
same line. a double semicolon is for comment the next lines.

> +         #:phases
> +         (modify-phases %standard-phases
> +           (add-after 'install 'install-udev-rules
> +             (lambda* (#:key outputs #:allow-other-keys)
> +               (let* ((out (assoc-ref outputs "out"))
> +                      (rules-out (string-append out "/lib/udev/rules.d")))
> +                 (install-file "../source/platform/linux/udev/51-kinect.rules"
> +                               (string-append rules-out "51-kinect.rules"))
> +                 #t))))))
> +      (native-inputs
> +       `(("libusb" ,libusb)
> +         ("pkg-config" ,pkg-config)))
> +      (inputs
> +       `(("glut" ,freeglut)))
> +      (synopsis "Drivers and libraries for the Xbox Kinect device")
> +      (description "libfreenect is a userspace driver for the Microsoft Kinect.
> +It supports: RGB and Depth Images, Motors, Accelerometer, LED and Audio.")
> +      (home-page "https://openkinect.org/")
> +      (license license:gpl2+))))
> --
> 2.26.1

Otherwise, look goods to me, hope it helps!
Ekaitz Zarraga May 16, 2020, 10:18 a.m. UTC | #2
Hi,

On Saturday, May 16, 2020 5:48 AM, <iyzsong@member.fsf.org> wrote:

> We generally try to enable all optional features when adding a package,
> I'd go with:
>
> 1.  Build the python bindings by default.
> 2.  Try seperate the python bindings into another output. (eg: newt)
> 3.  If 1 and 2 seems difficult, try add a seperate package for the
>     python bindings, and it better only contains the bindings, reuse the
>     original package as input. (eg: python-libxml2)
>
> 4.  If not feel lucky, just leave a TODO comment for it...
>

I don't really like the first because it forces you to add a python interpreter that is not needed otherwise.
2 and 3 sound good to me.
It can handle both python2 and 3. What would you do with that?
Maybe make option 3 and add two outputs to that with python2 and python3? Or two different packages?
(or just forget the python2?)

>
> > -   The package is 300 megs checking `guix size` that's because it has some testing binaries that have extra dependencies. If only the library is compiled it doesn't depend on GLUT and that reduces the size a lot. I tried to separate the package's outputs but I don't know how to do it correctly (I checked the docs but it doesn't go in detail). I'd like to do it but I need some help.
>
> To define a packages with multiple outputs:
>
> -   Decide what ‘outputs’ can be made, eg: ‘doc’, ‘bin’, ‘examples’,
>     etc. In this case, I’d add an ‘examples’ output, to put those
>     ‘freenect-*’ binaries, built from the “examples” directory.
>
> -   Add an ‘outputs’ field, it default to ‘(list "out")’, We’d use
>     ‘(outputs '("out" "examples")’.
>
> -   Modify the install flags or phases to get files into their output
>     directory. Sometimes we can configure the target directory by flags,
>     but usually we have to move the files around after the install phase…
>
>     You can see ‘newt’ in ‘gnu/packages/slang.scm’ for a example.

Great! Thank you. That's more or less what I understood from some code examples I checked but they were complex and I tried to make the same thing and didn't work for me. I'll give it a new try with this example.

Inputs can also be defined with an extra argument for different outputs, right? It should be something like:

`(inputs `("freeglut" ,freeglut "examples"))

Am I right?

>
> > -   I'm not sure if the file where I added it is a good choice.
>
> Same here, we can always move it later…

Yeah, sure.

Thank you very much for your help.

Best,
Ekaitz
Ekaitz Zarraga May 16, 2020, 1:06 p.m. UTC | #3
> Inputs can also be defined with an extra argument for different outputs, right? It should be something like:
>
> `(inputs`("freeglut" ,freeglut "examples"))
>
> Am I right?

Nope!

I've been digging and I got this wrong. The third part in the tuple is the output of the dependency.
So there's no way to indicate which dependencies are needed for each output.

I also found a flag to compile OpenCV wrappers, which depends on OpenCV. OpenCV is huge and it's going to be downloaded regardless if its output is used or not. Best choice here seems to be to separate the package in multiple sub-packages.

I made this with the examples (see below), how does it look?
I used libfreenect as a dependency for examples too, so I needed to patch the CMakeLists.txt to avoid it compile the `src` folder again.
Is it cool if I do the same thing with OpenCV and Python?

(now we can move it to its own module because it's going to be long :) )

---

(define-public libfreenect
  (let ((version "0.6.1"))
    (package
      (name "libfreenect")
      (version version)
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://github.com/OpenKinect/libfreenect")
                      (commit (string-append "v" version))))
                (sha256
                 (base32 "0was1va167rqshmpn382h36yyprpfi9cwillb6ylppmnfdrfrhrr"))))
      (build-system cmake-build-system)
      (outputs '("out" "opencv" "examples"))
      (arguments
       '(#:tests? #f ; Project has not tests
         #:configure-flags '("-DBUILD_EXAMPLES=ON"
                             "-DBUILD_FAKENECT=ON"
                             "-DBUILD_CPP=ON"
                             "-DBUILD_CV=OFF"
                             "-DBUILD_C_SYNC=ON")
         #:phases
         (modify-phases %standard-phases
           (add-after 'install 'install-udev-rules
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (rules-out (string-append out "/lib/udev/rules.d")))
                 (install-file "../source/platform/linux/udev/51-kinect.rules"
                               (string-append rules-out "51-kinect.rules"))
                 #t))))))
      (native-inputs
       `(("pkg-config" ,pkg-config)))
      (inputs
       `(("libusb" ,libusb)))
      (synopsis "Drivers and libraries for the Xbox Kinect device")
      (description "libfreenect is a userspace driver for the Microsoft Kinect.
It supports: RGB and Depth Images, Motors, Accelerometer, LED and Audio.")
      (home-page "https://openkinect.org/")
      (license license:gpl2+))))

(define-public libfreenect-examples
  (package
    (inherit libfreenect)
    (name "libfreenect-examples")
    (inputs
     `(("libusb" ,libusb)
       ("libfreenect" ,libfreenect)
       ("glut" ,freeglut)))
    (arguments
     '(#:tests? #f ; Project has not tests
       #:configure-flags '("-DBUILD_EXAMPLES=ON"
                           "-DBUILD_FAKENECT=OFF"
                           "-DBUILD_CPP=OFF"
                           "-DBUILD_C_SYNC=OFF")
       #:phases
       (modify-phases
         %standard-phases
         (add-after
           'unpack 'remove-sources
           (lambda* (#:key outputs #:allow-other-keys)
                    (substitute* "CMakeLists.txt"
                                 (("add_subdirectory \\(src\\)") "")
                                 ((".*libfreenectConfig.cmake.*") "")))))))
    (synopsis "Examples for libfreenect, the Xbox Kinect device library")))
Ekaitz Zarraga May 16, 2020, 1:28 p.m. UTC | #4
> (outputs '("out" "opencv" "examples"))

Ignore this line, I forgot to remove it :S
宋文武 May 17, 2020, 1:56 a.m. UTC | #5
Ekaitz Zarraga <ekaitz@elenq.tech> writes:

> Hi,
>
> On Saturday, May 16, 2020 5:48 AM, <iyzsong@member.fsf.org> wrote:
>
>> We generally try to enable all optional features when adding a package,
>> I'd go with:
>>
>> 1.  Build the python bindings by default.
>> 2.  Try seperate the python bindings into another output. (eg: newt)
>> 3.  If 1 and 2 seems difficult, try add a seperate package for the
>>     python bindings, and it better only contains the bindings, reuse the
>>     original package as input. (eg: python-libxml2)
>>
>> 4.  If not feel lucky, just leave a TODO comment for it...
>>
>
> I don't really like the first because it forces you to add a python interpreter that is not needed otherwise.
> 2 and 3 sound good to me.
Sure, to me both are acceptable.

> It can handle both python2 and 3. What would you do with that?
> Maybe make option 3 and add two outputs to that with python2 and python3? Or two different packages?
> (or just forget the python2?)

Unless there is a need for the python2 bindings, we should forget it, as
Python 2 is end-of-life.

>
>>
>> > - The package is 300 megs checking `guix size` that's because it
>> > has some testing binaries that have extra dependencies. If only
>> > the library is compiled it doesn't depend on GLUT and that reduces
>> > the size a lot. I tried to separate the package's outputs but I
>> > don't know how to do it correctly (I checked the docs but it
>> > doesn't go in detail). I'd like to do it but I need some help.
>>
>> To define a packages with multiple outputs:
>>
>> -   Decide what ‘outputs’ can be made, eg: ‘doc’, ‘bin’, ‘examples’,
>>     etc. In this case, I’d add an ‘examples’ output, to put those
>>     ‘freenect-*’ binaries, built from the “examples” directory.
>>
>> -   Add an ‘outputs’ field, it default to ‘(list "out")’, We’d use
>>     ‘(outputs '("out" "examples")’.
>>
>> -   Modify the install flags or phases to get files into their output
>>     directory. Sometimes we can configure the target directory by flags,
>>     but usually we have to move the files around after the install phase…
>>
>>     You can see ‘newt’ in ‘gnu/packages/slang.scm’ for a example.
>
> Great! Thank you. That's more or less what I understood from some code
> examples I checked but they were complex and I tried to make the same
> thing and didn't work for me. I'll give it a new try with this
> example.
>
> Inputs can also be defined with an extra argument for different outputs, right? It should be something like:
>
> `(inputs `("freeglut" ,freeglut "examples"))
>
> Am I right?

Inputs are used (not defined) here, the code you wrote:

- Need a freeglut package, which should contain a "examples" output.

- In the build environment of this package, a "freeglut" input is
  available, and its path is store path of the "examples" output of that
  freeglut package.  freeglut's "out" output is not available here.

> Nope!

> I've been digging and I got this wrong. The third part in the tuple is the output of the dependency.
> So there's no way to indicate which dependencies are needed for each output.
Yes, the dependencies of outputs are scanned after the build results,
not before.  This works by searching  '/gnu/store' paths in all files
from the output's store path.


> I also found a flag to compile OpenCV wrappers, which depends on OpenCV. OpenCV is huge and it's going to be downloaded regardless if its output is used or not. Best choice here seems to be to separate the package in multiple sub-packages.
If in the same package (multiple outputs), all inputs are needed when
build a package, but not all dependencies are needed when install a
output by binary substitutes.


> I made this with the examples (see below), how does it look?
> [...]
Will reply to in that email...
宋文武 May 17, 2020, 2:15 a.m. UTC | #6
Ekaitz Zarraga <ekaitz@elenq.tech> writes:

> [...]
>
> I made this with the examples (see below), how does it look?
> I used libfreenect as a dependency for examples too, so I needed to patch the CMakeLists.txt to avoid it compile the `src` folder again.
> Is it cool if I do the same thing with OpenCV and Python?
>
> (now we can move it to its own module because it's going to be long :) )
>
> ---
>
> (define-public libfreenect
>   (let ((version "0.6.1"))
>     (package
>       (name "libfreenect")
>       (version version)
>       (source (origin
>                 (method git-fetch)
>                 (uri (git-reference
>                       (url "https://github.com/OpenKinect/libfreenect")
>                       (commit (string-append "v" version))))
>                 (sha256
>                  (base32 "0was1va167rqshmpn382h36yyprpfi9cwillb6ylppmnfdrfrhrr"))))
>       (build-system cmake-build-system)
>       (outputs '("out" "opencv" "examples"))
As note in your latest email, this line should be removed, as it's a single
output package now.

>       (arguments
>        '(#:tests? #f ; Project has not tests
>          #:configure-flags '("-DBUILD_EXAMPLES=ON"
Should be "-DBUILD_EXAMPLES=OFF"?

>                              "-DBUILD_FAKENECT=ON"
>                              "-DBUILD_CPP=ON"
>                              "-DBUILD_CV=OFF"
>                              "-DBUILD_C_SYNC=ON")
>          #:phases
>          (modify-phases %standard-phases
>            (add-after 'install 'install-udev-rules
>              (lambda* (#:key outputs #:allow-other-keys)
>                (let* ((out (assoc-ref outputs "out"))
>                       (rules-out (string-append out "/lib/udev/rules.d")))
>                  (install-file "../source/platform/linux/udev/51-kinect.rules"
>                                (string-append rules-out "51-kinect.rules"))
>                  #t))))))
>       (native-inputs
>        `(("pkg-config" ,pkg-config)))
>       (inputs
>        `(("libusb" ,libusb)))
>       (synopsis "Drivers and libraries for the Xbox Kinect device")
>       (description "libfreenect is a userspace driver for the Microsoft Kinect.
> It supports: RGB and Depth Images, Motors, Accelerometer, LED and Audio.")
>       (home-page "https://openkinect.org/")
>       (license license:gpl2+))))
>
> (define-public libfreenect-examples
>   (package
>     (inherit libfreenect)
>     (name "libfreenect-examples")
>     (inputs
>      `(("libusb" ,libusb)
>        ("libfreenect" ,libfreenect)
>        ("glut" ,freeglut)))
>     (arguments
>      '(#:tests? #f ; Project has not tests
>        #:configure-flags '("-DBUILD_EXAMPLES=ON"
>                            "-DBUILD_FAKENECT=OFF"
>                            "-DBUILD_CPP=OFF"
>                            "-DBUILD_C_SYNC=OFF")
>        #:phases
>        (modify-phases
>          %standard-phases
>          (add-after
>            'unpack 'remove-sources
Maybe 'configure-examples?  This phases doesn't remove sources, but
avoid building them.

>            (lambda* (#:key outputs #:allow-other-keys)
How about add a comment here: Reuse "libfreenect" from input, avoid building it again.

>                     (substitute* "CMakeLists.txt"
>                                  (("add_subdirectory \(src\)") "")
>                                  ((".*libfreenectConfig.cmake.*") "")))))))
>     (synopsis "Examples for libfreenect, the Xbox Kinect device library")))

Also check the outputs of libfreenect and libfreenect-examples, they
shouldn't have same files (maybe by guix install them).

Otherwise, look goods to me.
Ekaitz Zarraga May 17, 2020, 9:37 a.m. UTC | #7
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, May 17, 2020 4:15 AM, <iyzsong@member.fsf.org> wrote:

> Ekaitz Zarraga ekaitz@elenq.tech writes:
>
> > [...]
> > I made this with the examples (see below), how does it look?
> > I used libfreenect as a dependency for examples too, so I needed to patch the CMakeLists.txt to avoid it compile the `src` folder again.
> > Is it cool if I do the same thing with OpenCV and Python?
> > (now we can move it to its own module because it's going to be long :) )
> >
> > (define-public libfreenect
> > (let ((version "0.6.1"))
> > (package
> > (name "libfreenect")
> > (version version)
> > (source (origin
> > (method git-fetch)
> > (uri (git-reference
> > (url "https://github.com/OpenKinect/libfreenect")
> > (commit (string-append "v" version))))
> > (sha256
> > (base32 "0was1va167rqshmpn382h36yyprpfi9cwillb6ylppmnfdrfrhrr"))))
> > (build-system cmake-build-system)
> > (outputs '("out" "opencv" "examples"))
>
> As note in your latest email, this line should be removed, as it's a single
> output package now.
>
> >       (arguments
> >        '(#:tests? #f ; Project has not tests
> >          #:configure-flags '("-DBUILD_EXAMPLES=ON"
> >
>
> Should be "-DBUILD_EXAMPLES=OFF"?
>
> >                              "-DBUILD_FAKENECT=ON"
> >                              "-DBUILD_CPP=ON"
> >                              "-DBUILD_CV=OFF"
> >                              "-DBUILD_C_SYNC=ON")
> >          #:phases
> >          (modify-phases %standard-phases
> >            (add-after 'install 'install-udev-rules
> >              (lambda* (#:key outputs #:allow-other-keys)
> >                (let* ((out (assoc-ref outputs "out"))
> >                       (rules-out (string-append out "/lib/udev/rules.d")))
> >                  (install-file "../source/platform/linux/udev/51-kinect.rules"
> >                                (string-append rules-out "51-kinect.rules"))
> >                  #t))))))
> >       (native-inputs
> >        `(("pkg-config" ,pkg-config)))
> >       (inputs
> >        `(("libusb" ,libusb)))
> >       (synopsis "Drivers and libraries for the Xbox Kinect device")
> >       (description "libfreenect is a userspace driver for the Microsoft Kinect.
> >
> >
> > It supports: RGB and Depth Images, Motors, Accelerometer, LED and Audio.")
> > (home-page "https://openkinect.org/")
> > (license license:gpl2+))))
> > (define-public libfreenect-examples
> > (package
> > (inherit libfreenect)
> > (name "libfreenect-examples")
> > (inputs
> > `(("libusb" ,libusb)
> > ("libfreenect" ,libfreenect)
> > ("glut" ,freeglut)))
> > (arguments
> > '(#:tests? #f ; Project has not tests
> > #:configure-flags '("-DBUILD_EXAMPLES=ON"
> > "-DBUILD_FAKENECT=OFF"
> > "-DBUILD_CPP=OFF"
> > "-DBUILD_C_SYNC=OFF")
> > #:phases
> > (modify-phases
> > %standard-phases
> > (add-after
> > 'unpack 'remove-sources
>
> Maybe 'configure-examples? This phases doesn't remove sources, but
> avoid building them.
>
> >            (lambda* (#:key outputs #:allow-other-keys)
> >
>
> How about add a comment here: Reuse "libfreenect" from input, avoid building it again.
>
> >                     (substitute* "CMakeLists.txt"
> >                                  (("add_subdirectory \\(src\\)") "")
> >                                  ((".*libfreenectConfig.cmake.*") "")))))))
> >     (synopsis "Examples for libfreenect, the Xbox Kinect device library")))
> >
>
> Also check the outputs of libfreenect and libfreenect-examples, they
> shouldn't have same files (maybe by guix install them).
>
> Otherwise, look goods to me.

Hi!

Thanks. I was worried about if this is a common practice.

I already prepared something. I'll send the patch soon. Thanks for your explanations, they are very helpful.

Best,
Ekaitz
diff mbox series

Patch

diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm
index 3842f3fead..a27373c15a 100644
--- a/gnu/packages/libusb.scm
+++ b/gnu/packages/libusb.scm
@@ -10,6 +10,7 @@ 
 ;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2020 Christopher Howard <christopher@librehacker.com>
+;;; Copyright © 2020 Ekaitz Zarraga <ekaitz@elenq.tech>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -48,7 +49,8 @@ 
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages xiph))
+  #:use-module (gnu packages xiph)
+  #:use-module (gnu packages gl))

 (define-public libusb
   (package
@@ -679,3 +681,38 @@  HID-Class devices.")

 (define-public python2-hidapi
   (package-with-python2 python-hidapi))
+
+(define-public libfreenect
+  (let ((version "0.6.1"))
+    (package
+      (name "libfreenect")
+      (version version)
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/OpenKinect/libfreenect")
+                      (commit (string-append "v" version))))
+                (sha256
+                 (base32 "0was1va167rqshmpn382h36yyprpfi9cwillb6ylppmnfdrfrhrr"))))
+      (build-system cmake-build-system)
+      (arguments
+       `(#:tests? #f ;; Project has not tests
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'install 'install-udev-rules
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (rules-out (string-append out "/lib/udev/rules.d")))
+                 (install-file "../source/platform/linux/udev/51-kinect.rules"
+                               (string-append rules-out "51-kinect.rules"))
+                 #t))))))
+      (native-inputs
+       `(("libusb" ,libusb)
+         ("pkg-config" ,pkg-config)))
+      (inputs
+       `(("glut" ,freeglut)))
+      (synopsis "Drivers and libraries for the Xbox Kinect device")
+      (description "libfreenect is a userspace driver for the Microsoft Kinect.
+It supports: RGB and Depth Images, Motors, Accelerometer, LED and Audio.")
+      (home-page "https://openkinect.org/")
+      (license license:gpl2+))))