diff mbox series

[bug#50157] gnu: Add xpadneo.

Message ID 20210821220053.31441-1-leo.prikler@student.tugraz.at
State Accepted
Headers show
Series [bug#50157] gnu: Add xpadneo. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Leo Prikler Aug. 21, 2021, 10 p.m. UTC
* gnu/packages/linux.scm (xpadneo): New variable.
---
 gnu/packages/linux.scm | 52 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

Comments

M Aug. 22, 2021, 9:58 a.m. UTC | #1
Leo Prikler schreef op zo 22-08-2021 om 00:00 [+0200]:
> * gnu/packages/linux.scm (xpadneo): New variable.
> ---
>  gnu/packages/linux.scm | 52 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
> 
> diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
> index 7b92be4b9c..385cdd558b 100644
> --- a/gnu/packages/linux.scm
> +++ b/gnu/packages/linux.scm
> @@ -1505,6 +1505,58 @@ allows some more serious things like adding streaming capabilities to an
>  application by hooking GStreamer into the loopback device.")
>      (license license:gpl2+)))
>  
> +(define-public xpadneo
> +  (package
> +    (name "xpadneo")
> +    (version "0.9.1")
> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url "https://github.com/atar-axis/xpadneo")
> +                    (commit (string-append "v" version))))
> +              (file-name (git-file-name name version))
> +              (sha256
> +               (base32
> +                "0xr0zx134s56h4ij6c3fh8ki0h58h61minbfxcl3sgpgxkh14ism"))))
> +    (build-system linux-module-build-system)
> +    (arguments
> +     `(#:tests? #f ; no `check' target
> +       #:modules (((guix build copy-build-system) #:prefix copy:)
> +                  (guix build linux-module-build-system)
> +                  (guix build utils))
> +       #:imported-modules
> +       ((guix build copy-build-system)
> +        ,@%linux-module-build-system-modules)
> +       #:phases
> +       (modify-phases %standard-phases
> +         (replace 'configure
> +           (lambda args
> +             (with-directory-excursion "hid-xpadneo/src"
> +               (apply (assoc-ref %standard-phases 'configure) args))))
> +         (replace 'build
> +           (lambda args
> +             (with-directory-excursion "hid-xpadneo/src"
> +               (apply (assoc-ref %standard-phases 'build) args))))
> +         (replace 'install
> +           (lambda args
> +             (with-directory-excursion "hid-xpadneo/src"
> +               (apply (assoc-ref %standard-phases 'install) args))))

It might be a bit simpler to add a 'chdir' phase:

    (add-after 'unpack 'chdir
      (lambda _
        (chdir "hid-xpadneo/src")))

instead of these 'with-directory-excursion'.

Greetings,
Maxime.
Leo Prikler Aug. 22, 2021, 10:08 a.m. UTC | #2
Am Sonntag, den 22.08.2021, 11:58 +0200 schrieb Maxime Devos:
> Leo Prikler schreef op zo 22-08-2021 om 00:00 [+0200]:
> > * gnu/packages/linux.scm (xpadneo): New variable.
> > ---
> >  gnu/packages/linux.scm | 52
> > ++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 52 insertions(+)
> > 
> > diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
> > index 7b92be4b9c..385cdd558b 100644
> > --- a/gnu/packages/linux.scm
> > +++ b/gnu/packages/linux.scm
> > @@ -1505,6 +1505,58 @@ allows some more serious things like adding
> > streaming capabilities to an
> >  application by hooking GStreamer into the loopback device.")
> >      (license license:gpl2+)))
> >  
> > +(define-public xpadneo
> > +  (package
> > +    (name "xpadneo")
> > +    (version "0.9.1")
> > +    (source (origin
> > +              (method git-fetch)
> > +              (uri (git-reference
> > +                    (url "https://github.com/atar-axis/xpadneo")
> > +                    (commit (string-append "v" version))))
> > +              (file-name (git-file-name name version))
> > +              (sha256
> > +               (base32
> > +                "0xr0zx134s56h4ij6c3fh8ki0h58h61minbfxcl3sgpgxkh14
> > ism"))))
> > +    (build-system linux-module-build-system)
> > +    (arguments
> > +     `(#:tests? #f ; no `check' target
> > +       #:modules (((guix build copy-build-system) #:prefix copy:)
> > +                  (guix build linux-module-build-system)
> > +                  (guix build utils))
> > +       #:imported-modules
> > +       ((guix build copy-build-system)
> > +        ,@%linux-module-build-system-modules)
> > +       #:phases
> > +       (modify-phases %standard-phases
> > +         (replace 'configure
> > +           (lambda args
> > +             (with-directory-excursion "hid-xpadneo/src"
> > +               (apply (assoc-ref %standard-phases 'configure)
> > args))))
> > +         (replace 'build
> > +           (lambda args
> > +             (with-directory-excursion "hid-xpadneo/src"
> > +               (apply (assoc-ref %standard-phases 'build) args))))
> > +         (replace 'install
> > +           (lambda args
> > +             (with-directory-excursion "hid-xpadneo/src"
> > +               (apply (assoc-ref %standard-phases 'install)
> > args))))
> 
> It might be a bit simpler to add a 'chdir' phase:
> 
>     (add-after 'unpack 'chdir
>       (lambda _
>         (chdir "hid-xpadneo/src")))
> 
> instead of these 'with-directory-excursion'.
That may be true, but in that case there's no "clean" way of exiting. 
I could do (chdir "..") in post-install, but that feels weird.

WDYT?
Efraim Flashner Aug. 22, 2021, 11:32 a.m. UTC | #3
On Sun, Aug 22, 2021 at 12:08:57PM +0200, Leo Prikler wrote:
> Am Sonntag, den 22.08.2021, 11:58 +0200 schrieb Maxime Devos:
> > Leo Prikler schreef op zo 22-08-2021 om 00:00 [+0200]:
> > > * gnu/packages/linux.scm (xpadneo): New variable.
> > > ---
> > >  gnu/packages/linux.scm | 52
> > > ++++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 52 insertions(+)
> > > 
> > > diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
> > > index 7b92be4b9c..385cdd558b 100644
> > > --- a/gnu/packages/linux.scm
> > > +++ b/gnu/packages/linux.scm
> > > @@ -1505,6 +1505,58 @@ allows some more serious things like adding
> > > streaming capabilities to an
> > >  application by hooking GStreamer into the loopback device.")
> > >      (license license:gpl2+)))
> > >  
> > > +(define-public xpadneo
> > > +  (package
> > > +    (name "xpadneo")
> > > +    (version "0.9.1")
> > > +    (source (origin
> > > +              (method git-fetch)
> > > +              (uri (git-reference
> > > +                    (url "https://github.com/atar-axis/xpadneo")
> > > +                    (commit (string-append "v" version))))
> > > +              (file-name (git-file-name name version))
> > > +              (sha256
> > > +               (base32
> > > +                "0xr0zx134s56h4ij6c3fh8ki0h58h61minbfxcl3sgpgxkh14
> > > ism"))))
> > > +    (build-system linux-module-build-system)
> > > +    (arguments
> > > +     `(#:tests? #f ; no `check' target
> > > +       #:modules (((guix build copy-build-system) #:prefix copy:)
> > > +                  (guix build linux-module-build-system)
> > > +                  (guix build utils))
> > > +       #:imported-modules
> > > +       ((guix build copy-build-system)
> > > +        ,@%linux-module-build-system-modules)
> > > +       #:phases
> > > +       (modify-phases %standard-phases
> > > +         (replace 'configure
> > > +           (lambda args
> > > +             (with-directory-excursion "hid-xpadneo/src"
> > > +               (apply (assoc-ref %standard-phases 'configure)
> > > args))))
> > > +         (replace 'build
> > > +           (lambda args
> > > +             (with-directory-excursion "hid-xpadneo/src"
> > > +               (apply (assoc-ref %standard-phases 'build) args))))
> > > +         (replace 'install
> > > +           (lambda args
> > > +             (with-directory-excursion "hid-xpadneo/src"
> > > +               (apply (assoc-ref %standard-phases 'install)
> > > args))))
> > 
> > It might be a bit simpler to add a 'chdir' phase:
> > 
> >     (add-after 'unpack 'chdir
> >       (lambda _
> >         (chdir "hid-xpadneo/src")))
> > 
> > instead of these 'with-directory-excursion'.
> That may be true, but in that case there's no "clean" way of exiting. 
> I could do (chdir "..") in post-install, but that feels weird.
> 
> WDYT?
> 

Where is the license file located? You could add a phaes after 'install
to chdir back ".." and then just use install-file for the files for etc.
Then the 'install-license phase would also work correctly.
Leo Prikler Aug. 22, 2021, 12:03 p.m. UTC | #4
Am Sonntag, den 22.08.2021, 14:32 +0300 schrieb Efraim Flashner:
> On Sun, Aug 22, 2021 at 12:08:57PM +0200, Leo Prikler wrote:
> > Am Sonntag, den 22.08.2021, 11:58 +0200 schrieb Maxime Devos:
> > > Leo Prikler schreef op zo 22-08-2021 om 00:00 [+0200]:
> > > > * gnu/packages/linux.scm (xpadneo): New variable.
> > > > ---
> > > >  gnu/packages/linux.scm | 52
> > > > ++++++++++++++++++++++++++++++++++++++++++
> > > >  1 file changed, 52 insertions(+)
> > > > 
> > > > diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
> > > > index 7b92be4b9c..385cdd558b 100644
> > > > --- a/gnu/packages/linux.scm
> > > > +++ b/gnu/packages/linux.scm
> > > > @@ -1505,6 +1505,58 @@ allows some more serious things like
> > > > adding
> > > > streaming capabilities to an
> > > >  application by hooking GStreamer into the loopback device.")
> > > >      (license license:gpl2+)))
> > > >  
> > > > +(define-public xpadneo
> > > > +  (package
> > > > +    (name "xpadneo")
> > > > +    (version "0.9.1")
> > > > +    (source (origin
> > > > +              (method git-fetch)
> > > > +              (uri (git-reference
> > > > +                    (url "https://github.com/atar-axis/xpadneo
> > > > ")
> > > > +                    (commit (string-append "v" version))))
> > > > +              (file-name (git-file-name name version))
> > > > +              (sha256
> > > > +               (base32
> > > > +                "0xr0zx134s56h4ij6c3fh8ki0h58h61minbfxcl3sgpgx
> > > > kh14
> > > > ism"))))
> > > > +    (build-system linux-module-build-system)
> > > > +    (arguments
> > > > +     `(#:tests? #f ; no `check' target
> > > > +       #:modules (((guix build copy-build-system) #:prefix
> > > > copy:)
> > > > +                  (guix build linux-module-build-system)
> > > > +                  (guix build utils))
> > > > +       #:imported-modules
> > > > +       ((guix build copy-build-system)
> > > > +        ,@%linux-module-build-system-modules)
> > > > +       #:phases
> > > > +       (modify-phases %standard-phases
> > > > +         (replace 'configure
> > > > +           (lambda args
> > > > +             (with-directory-excursion "hid-xpadneo/src"
> > > > +               (apply (assoc-ref %standard-phases 'configure)
> > > > args))))
> > > > +         (replace 'build
> > > > +           (lambda args
> > > > +             (with-directory-excursion "hid-xpadneo/src"
> > > > +               (apply (assoc-ref %standard-phases 'build)
> > > > args))))
> > > > +         (replace 'install
> > > > +           (lambda args
> > > > +             (with-directory-excursion "hid-xpadneo/src"
> > > > +               (apply (assoc-ref %standard-phases 'install)
> > > > args))))
> > > 
> > > It might be a bit simpler to add a 'chdir' phase:
> > > 
> > >     (add-after 'unpack 'chdir
> > >       (lambda _
> > >         (chdir "hid-xpadneo/src")))
> > > 
> > > instead of these 'with-directory-excursion'.
> > That may be true, but in that case there's no "clean" way of
> > exiting. 
> > I could do (chdir "..") in post-install, but that feels weird.
> > 
> > WDYT?
> > 
> 
> Where is the license file located? You could add a phaes after
> 'install
> to chdir back ".." and then just use install-file for the files for
> etc.
> Then the 'install-license phase would also work correctly.
The license file is at the root of the tree.  FWIW, there is an ongoing
issue on whether to interpret the license as GPL3 or GPL3+ [1], which I
interpreted as the latter for a lack of file headers.

So in the chdir case, I would have to chdir two to three times,
depending on how much I want to type, leaving the CWD dirty between
phase changes.  The directory-excursion hack is a little more verbose,
but mostly captures my intent and needs to be applied exactly thrice. 
One could probably make it even smarter by writing a lambda for the
phase rewriting or instead provide build-system support for linux
modules in subdirectories.  (Perhaps we could even add modify-phases
support to add "advice" to phases Emacs-style.)

Regards,
Leo

[1] https://github.com/atar-axis/xpadneo/issues/289
diff mbox series

Patch

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 7b92be4b9c..385cdd558b 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1505,6 +1505,58 @@  allows some more serious things like adding streaming capabilities to an
 application by hooking GStreamer into the loopback device.")
     (license license:gpl2+)))
 
+(define-public xpadneo
+  (package
+    (name "xpadneo")
+    (version "0.9.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/atar-axis/xpadneo")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0xr0zx134s56h4ij6c3fh8ki0h58h61minbfxcl3sgpgxkh14ism"))))
+    (build-system linux-module-build-system)
+    (arguments
+     `(#:tests? #f ; no `check' target
+       #:modules (((guix build copy-build-system) #:prefix copy:)
+                  (guix build linux-module-build-system)
+                  (guix build utils))
+       #:imported-modules
+       ((guix build copy-build-system)
+        ,@%linux-module-build-system-modules)
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           (lambda args
+             (with-directory-excursion "hid-xpadneo/src"
+               (apply (assoc-ref %standard-phases 'configure) args))))
+         (replace 'build
+           (lambda args
+             (with-directory-excursion "hid-xpadneo/src"
+               (apply (assoc-ref %standard-phases 'build) args))))
+         (replace 'install
+           (lambda args
+             (with-directory-excursion "hid-xpadneo/src"
+               (apply (assoc-ref %standard-phases 'install) args))))
+         (add-after 'install 'post-install
+           (lambda* (#:key outputs #:allow-other-keys #:rest args)
+             (apply (assoc-ref copy:%standard-phases 'install)
+                    #:install-plan
+                    '(("hid-xpadneo/etc-modprobe.d" "etc/modprobe.d")
+                      ("hid-xpadneo/etc-udev-rules.d" "etc/udev/rules.d"))
+                    args))))))
+    (home-page "https://atar-axis.github.io/xpadneo/")
+    (synopsis "Xbox One Wireless Controller driver")
+    (description
+     "This package provides a driver for the XBox One S Wireless controller
+and some newer models when connected via bluetooth.  In addition to the kernel
+module provided itself, it also contains a modprobe configuration and udev
+rules, which need to be installed separately.")
+    (license license:gpl3+)))
+
 
 ;;;
 ;;; Pluggable authentication modules (PAM).