[PATCH] gnu: Add gpu-switch.

  • Open
  • quality assurance status badge
Details
2 participants
  • Jorge Acereda
  • Maxime Devos
Owner
unassigned
Submitted by
Jorge Acereda
Severity
normal
J
J
Jorge Acereda wrote on 6 Jan 2022 20:11
(address . guix-patches@gnu.org)(name . Jorge Acereda)(address . jacereda@gmail.com)
79655b434893691c6647f28087652f162aad80de.1641496236.git.jacereda@gmail.com
* gnu/packages/graphics.scm (gpu-switch): New variable.
---
gnu/packages/graphics.scm | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)

Toggle diff (62 lines)
diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index fe35aaad2d..b5b50f6192 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -27,6 +27,7 @@
;;; Copyright © 2021 Andy Tai <atai@atai.org>
;;; Copyright © 2021 Ekaitz Zarraga <ekaitz@elenq.tech>
;;; Copyright © 2021 Vinicius Monego <monego@posteo.net>
+;;; Copyright © 2022 Jorge Acereda <jacereda@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -113,6 +114,7 @@ (define-module (gnu packages graphics)
#:use-module (guix build-system meson)
#:use-module (guix build-system python)
#:use-module (guix build-system qt)
+ #:use-module (guix build-system trivial)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix hg-download)
@@ -2011,3 +2013,39 @@ (define-public monado
such as VR and AR on mobile, PC/desktop, and any other device. Monado aims to be
a complete and conforming implementation of the OpenXR API made by Khronos.")
(license license:boost1.0)))
+
+(define-public gpu-switch
+ (package
+ (name "gpu-switch")
+ (version "2017-04-28")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/0xbb/gpu-switch")
+ (commit "a365f56d435c8ef84c4dd2ab935ede4992359e31")))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1jnh43nijkqd83h7piq7225ixziggyzaalabgissyxdyz6szcn0r"))))
+ (build-system trivial-build-system)
+ (arguments
+ `(#:modules ((guix build utils))
+ #:builder
+ (begin
+ (use-modules (guix build utils))
+ (let ((out (assoc-ref %outputs "out"))
+ (gpu-switch (search-input-file %build-inputs "gpu-switch"))
+ (readme (search-input-file %build-inputs "README.md")))
+ (install-file gpu-switch (string-append out "/bin"))
+ (install-file readme (string-append out "/share/doc/gpu-switch-" ,version))
+ #t))))
+ (home-page "https://github.com/0xbb/gpu-switch")
+ (synopsis "GPU switcher for dual-GPU MacBook Pro models")
+ (description
+ "Switch between the integrated and dedicated GPU of dual-GPU MacBook Pro
+models for the next reboot.
+
+It aims to remove the need of booting into OS X and running gfxCardStatus
+v2.2.1 to switch to the integrated card.")
+ (license license:expat)))
+
--
2.34.0
M
M
Maxime Devos wrote on 6 Jan 2022 22:01
(address . 53059@debbugs.gnu.org)(name . Jorge Acereda)(address . jacereda@gmail.com)
c6b5632b9e22deaffbc703216788f72c2dbf043c.camel@telenet.be
Hi,

it appears that it uses 'chattr', 'mount', 'grep', 'cat' and
'basename'. So the corresponding packages would need to be added
to 'inputs' and a few 'substitute*' are required such that gpu-switch
doesn't require 'chattr' & friends to be in the environment.

/sys/firmware/efi/efivars is rather Linux-specific, presumably
non-existent on the hurd, so the hurd systems need to be removed from
supported-systems.

Toggle quote (9 lines)
> + (name "gpu-switch")
> + (version "2017-04-28")
> + (source
> + (origin
> + (method git-fetch)
> + (uri (git-reference
> + (url "https://github.com/0xbb/gpu-switch")
> + (commit "a365f56d435c8ef84c4dd2ab935ede4992359e31")))

Where did you get this version/commit pair from? I'm not seeing it on

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYddYnRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7rtSAQC/JnfwUBSOkNb4sk1VXhifFZyl
Hv0lPy1I3YOyINm3CAEAtDO5VIaoC3QcZpXdkq2sKps3xI3w7pdEQHwB1gGbrgU=
=PWPp
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 7 Jan 2022 11:45
(name . Jorge Acereda)(address . jacereda@gmail.com)(address . 53059@debbugs.gnu.org)
1b5f53af3fc918568cc384add8e74a8256218a63.camel@telenet.be
[Re-adding debbugs to CC]

Jorge Acereda schreef op vr 07-01-2022 om 02:02 [+0100]:
Toggle quote (8 lines)
> [...]
> >
> > /sys/firmware/efi/efivars is rather Linux-specific, presumably
> > non-existent on the hurd, so the hurd systems need to be removed from
> > supported-systems.
>
> Would it be better in linux.scm instead?

While it currently is Linux-specific, in principle it could be ported
to the Hurd, a BSD or Windows or whatever -- in fact, looking at
https://github.com/0xbb/gpu-switch,it appears to support ‘osx’ and
Windows.

linux.scm is more for Linux kernel modules, the Linux kernel, userspace
bindings to kernel syscalls ...

There probably are a few misplaced packages in linux.scm.

Greetings,
Maxime
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYdgZ4hccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gRRAQCZA9T9a4zmyCKEAPOhGbIem2cm
4r0WfpXoHlXdZzMUOwD+Ph4sqzlOWmSue35G2JB1TN+eFBXPbi5oc+SRcGV/6ww=
=Lvbw
-----END PGP SIGNATURE-----


J
J
Jorge Acereda wrote on 7 Jan 2022 19:37
[PATCH v2] gnu: Add gpu-switch.
(address . 53059@debbugs.gnu.org)(name . Jorge Acereda)(address . jacereda@gmail.com)
6a263efbca6f379b056e06887de50e6cccac9929.1641580314.git.jacereda@gmail.com
The package version is the same one used in nixpkgs (current tip).
Should I add some "unstable" string somewhere? Also, I'm pretty sure
I overcomplicated things, there must be some easier way to patch the
executable paths.

* gnu/packages/graphics.scm (gpu-switch): New variable.
---
gnu/packages/graphics.scm | 58 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)

Toggle diff (87 lines)
diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index fe35aaad2d..d425a18c18 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -27,6 +27,7 @@
;;; Copyright © 2021 Andy Tai <atai@atai.org>
;;; Copyright © 2021 Ekaitz Zarraga <ekaitz@elenq.tech>
;;; Copyright © 2021 Vinicius Monego <monego@posteo.net>
+;;; Copyright © 2022 Jorge Acereda <jacereda@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -113,12 +114,14 @@ (define-module (gnu packages graphics)
#:use-module (guix build-system meson)
#:use-module (guix build-system python)
#:use-module (guix build-system qt)
+ #:use-module (guix build-system trivial)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix hg-download)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
- #:use-module (guix utils))
+ #:use-module (guix utils)
+ #:use-module (ice-9 match))
(define-public mmm
(package
@@ -2011,4 +2014,56 @@ (define-public monado
such as VR and AR on mobile, PC/desktop, and any other device. Monado aims to be
a complete and conforming implementation of the OpenXR API made by Khronos.")
(license license:boost1.0)))
+
+(define-public gpu-switch
+ (package
+ (name "gpu-switch")
+ (version "2017-04-28")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/0xbb/gpu-switch")
+ (commit "a365f56d435c8ef84c4dd2ab935ede4992359e31")))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1jnh43nijkqd83h7piq7225ixziggyzaalabgissyxdyz6szcn0r"))))
+ (build-system trivial-build-system)
+ (inputs
+ (list bash e2fsprogs util-linux grep coreutils which))
+ (arguments
+ `(#:modules ((guix build utils))
+ #:builder
+ (begin
+ (use-modules (guix build utils) (ice-9 match))
+ (let* ((out (assoc-ref %outputs "out"))
+ (gpu-switch (search-input-file %build-inputs "gpu-switch"))
+ (bin (string-append out "/bin"))
+ (out-gpu-switch (string-append bin "/gpu-switch"))
+ (readme (search-input-file %build-inputs "README.md")))
+ (install-file gpu-switch bin)
+ (for-each
+ (match-lambda
+ ((pkg . nm) (substitute* out-gpu-switch
+ ((nm)
+ (string-append (assoc-ref %build-inputs pkg)
+ "/bin/" nm)))))
+ '(("coreutils" . "basename")
+ ("bash" . "bash")
+ ("util-linux" . "mount")
+ ("which" . "which")
+ ("coreutils" . "cat")
+ ("e2fsprogs" . "chattr")
+ ("grep" . "grep")))
+ (install-file readme (string-append out "/share/doc/gpu-switch-" ,version))
+ #t))))
+ (home-page "https://github.com/0xbb/gpu-switch")
+ (synopsis "GPU switcher for dual-GPU MacBook Pro models")
+ (description
+ "Switch between the integrated and dedicated GPU of dual-GPU MacBook Pro
+models for the next reboot.
+
+It aims to remove the need of booting into OS X and running gfxCardStatus
+v2.2.1 to switch to the integrated card.")
+ (license license:expat)))
+
--
2.34.0
M
M
Maxime Devos wrote on 8 Jan 2022 16:38
7a15b34a40868bcbc7a63c3aea787b0f176e6077.camel@telenet.be
Jorge Acereda schreef op vr 07-01-2022 om 19:37 [+0100]:
Toggle quote (5 lines)
> The package version is the same one used in nixpkgs (current tip).
> Should I add some "unstable" string somewhere?  Also, I'm pretty sure
> I overcomplicated things, there must be some easier way to patch the
> executable paths.

Ok, but anyone looking at the package definition of gpu-switch would
be having a hard time figuring out these reasons. Also, the version
used by nixpkgs isn't very relevant; nixpkgs might be out-of-date.

An "-unstable" version suffix isn't very informative, and doesn't
seem correct here: there haven't been any changes in gpu-switch for
about five years, which seems rather stable to me.

I suggest having a look at ‘17.4.3 Version Numbers’ in the manual,
in particular the text about VCS vs formal releases.

Because upstream isn't formally releasing anything, using a revision
from git seems appropriate to me, but the reasons needs to be
documented with a comment. E.g., see 'emacs-graphql-mode'.

Toggle quote (10 lines)
> * gnu/packages/graphics.scm (gpu-switch): New variable.
> ---
>  gnu/packages/graphics.scm | 58 ++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 57 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
> index fe35aaad2d..d425a18c18 100644
> --- a/gnu/packages/graphics.scm
> +++ b/gnu/packages/graphics.scm

GPUs aren't only used for graphics, see e.g.
I would put it in hardware.scm instead.

Toggle quote (23 lines)
> @@ -27,6 +27,7 @@
>  ;;; Copyright © 2021 Andy Tai <atai@atai.org>
>  ;;; Copyright © 2021 Ekaitz Zarraga <ekaitz@elenq.tech>
>  ;;; Copyright © 2021 Vinicius Monego <monego@posteo.net>
> +;;; Copyright © 2022 Jorge Acereda <jacereda@gmail.com>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -113,12 +114,14 @@ (define-module (gnu packages graphics)
>    #:use-module (guix build-system meson)
>    #:use-module (guix build-system python)
>    #:use-module (guix build-system qt)
> +  #:use-module (guix build-system trivial)
>    #:use-module (guix download)
>    #:use-module (guix git-download)
>    #:use-module (guix hg-download)
>    #:use-module ((guix licenses) #:prefix license:)
>    #:use-module (guix packages)
> -  #:use-module (guix utils))
> +  #:use-module (guix utils)
> +  #:use-module (ice-9 match))


Not needed, the use of 'match' is only at the build side.

Toggle quote (25 lines)
>  
>  (define-public mmm
>    (package
> @@ -2011,4 +2014,56 @@ (define-public monado
>  such as VR and AR on mobile, PC/desktop, and any other device.  Monado aims to be
>  a complete and conforming implementation of the OpenXR API made by Khronos.")
>      (license license:boost1.0)))
>  +
> +(define-public gpu-switch
> +  (package
> +    (name "gpu-switch")
> +    (version "2017-04-28")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/0xbb/gpu-switch")
> +             (commit "a365f56d435c8ef84c4dd2ab935ede4992359e31")))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32 "1jnh43nijkqd83h7piq7225ixziggyzaalabgissyxdyz6szcn0r"))))
> +    (build-system trivial-build-system)
> +    (inputs
> +     (list bash e2fsprogs util-linux grep coreutils which))

I suggest bash-minimal and coreutils-minimal to reduce the closure.

Toggle quote (7 lines)
> +    (arguments
> +     `(#:modules ((guix build utils))
> +       #:builder
> +       (begin
> +         (use-modules (guix build utils) (ice-9 match))
> +         (let* ((out (assoc-ref %outputs "out"))

%outputs is sort-of deprecated, it is recommended to use G-exps
instead: (let* ((out #$output) ...) ...)

Toggle quote (2 lines)
> +                (gpu-switch (search-input-file %build-inputs "gpu-switch"))

Likewise, %build-inputs is deprecated, and it doesn't do the right
thing when cross-compiling, because (implicit) native inputs go before
native inputs. In this particular case, it would work, but I'd avoid
this fragility, by doing something like (let (... (inputs #$inputs)
(gpu-switch (search-input-file inputs "gpu-switch"))) ...) instead.

Personally, I'd do #$(file-append source "/gpu-switch") instead though.

Toggle quote (4 lines)
> +                (bin (string-append out "/bin"))
> +                (out-gpu-switch (string-append bin "/gpu-switch"))
> +                (readme (search-input-file %build-inputs "README.md")))

Likewise.

Toggle quote (2 lines)
> +           (install-file gpu-switch bin)

The shebang starts with

#!/usr/bin/env /gnu/store/[a hash]-bash-5.1.8/bin/bash

so the script depends on the system's /usr/bin/env. Can this dependency
be removed, e.g. using patch-shebang?

The script has a line

$(/gnu/store/y5jxkx484x7s2c2n7dc8wprh5sbps7pl-coreutils-
8.32/bin/basename $0) --integrated # Switch to the integrated GPU

but this is fragile, what if I create a symlink named "switch the gpu"
pointing to gpu-switch (without the quotes, and with the spaces)?

Then I get

$ ./switch\ the\ gpu
/gnu/store/y5jxkx484x7s2c2n7dc8wprh5sbps7pl-coreutils-
8.32/bin/basename: extra operand 'gpu'
Try '/gnu/store/y5jxkx484x7s2c2n7dc8wprh5sbps7pl-coreutils-
8.32/bin/basename --help' for more information.
/gnu/store/y5jxkx484x7s2c2n7dc8wprh5sbps7pl-coreutils-
8.32/bin/basename: extra operand 'gpu'
Try '/gnu/store/y5jxkx484x7s2c2n7dc8wprh5sbps7pl-coreutils-
8.32/bin/basename --help' for more information.
/gnu/store/y5jxkx484x7s2c2n7dc8wprh5sbps7pl-coreutils-
8.32/bin/basename: extra operand 'gpu'
Try '/gnu/store/y5jxkx484x7s2c2n7dc8wprh5sbps7pl-coreutils-
8.32/bin/basename --help' for more information.

Can this be fixed (upstream)? Putting "" around the $0 would probably
be enough. Also, I thought it might be required to place -- before the
"$0" (in case the symlink is named "--help"), but it seems to work
without in my tests. I would still recommend an -- argument though,
to make things less fragile.

Toggle quote (4 lines)
> +           (for-each
> +            (match-lambda
> +              ((pkg . nm) (substitute* out-gpu-switch

I see the following line in the output of "gpu-switch"

gpu-switch --dedi/gnu/store/y5jxkx484x7s2c2n7dc8wprh5sbps7pl-
coreutils-8.32/bin/cated # Switch to the
dedi/gnu/store/y5jxkx484x7s2c2n7dc8wprh5sbps7pl-coreutils-
8.32/bin/cated GPU

Likewise:

printf "Fatal: Couldn't
/gnu/store/64d0mxsjqifrpashlhyd3rf7zm2r709x-util-linux-2.37.1/bin/mount
'${sysfs_efi_vars}'.\n" 1>&2

Seems like the substitutions are not sufficiently specific.

Toggle quote (3 lines)
> +                            ((nm)
> +                             (string-append (assoc-ref %build-inputs pkg)

%build-inputs -> #$inputs? Or maybe even use search-input-file.

Also, you can substitute multiple things with a single substitute*.
E.g.,

;; From the manual, see (guix)Build Utilities
(substitute* file
(("hello")
"good morning\n")
(("foo([a-z]+)bar(.*)$" all letters end)
(string-append "baz" letter end)))

Toggle quote (2 lines)
> +           #t))))

Returning #true in phases is not required anymore, presumably the same
holds for #:builder.

Toggle quote (6 lines)
> +    (synopsis "GPU switcher for dual-GPU MacBook Pro models")
> +    (description
> +     "Switch between the integrated and dedicated GPU of dual-GPU MacBook Pro
> +models for the next reboot.

Is this specific for ‘MacBook Pro models’, or does it work for any
computer that has a certain combination of ‘integrated’ and ‘dedicated’
GPU?

Toggle quote (3 lines)
> +It aims to remove the need of booting into OS X and running gfxCardStatus
> +v2.2.1 to switch to the integrated card.")

Is this v2.2.1 important?

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYdmv7BccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7lKlAQCGU7vkcgB8PqgN7Zg8KiwTMd4a
TavQS8YHsXOtHFX93QD9G6NnyWSQvtvt1yVQSPJ0JF5CiEkFtzR59i1F3sUtxwQ=
=DQxB
-----END PGP SIGNATURE-----


J
J
Jorge Acereda wrote on 8 Jan 2022 20:42
[PATCH v3] gnu: Add gpu-switch.
(address . 53059@debbugs.gnu.org)(name . Jorge Acereda)(address . jacereda@gmail.com)
2352d01612e4ba02e0021fd8d4bca4215c149b45.1641670916.git.jacereda@gmail.com
* gnu/packages/graphics.scm (gpu-switch): New variable.
---
gnu/packages/hardware.scm | 50 +++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)

Toggle diff (82 lines)
diff --git a/gnu/packages/hardware.scm b/gnu/packages/hardware.scm
index 28647477fe..8ec82f1297 100644
--- a/gnu/packages/hardware.scm
+++ b/gnu/packages/hardware.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name>
;;; Copyright © 2021 Vinicius Monego <monego@posteo.net>
;;; Copyright © 2021 John Kehayias <john.kehayias@protonmail.com>
+;;; Copyright © 2022 Jorge Acereda <jacereda@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -29,6 +30,7 @@ (define-module (gnu packages hardware)
#:use-module (gnu packages)
#:use-module (gnu packages admin)
#:use-module (gnu packages autotools)
+ #:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages compression)
#:use-module (gnu packages check)
@@ -64,7 +66,9 @@ (define-module (gnu packages hardware)
#:use-module (guix build-system gnu)
#:use-module (guix build-system meson)
#:use-module (guix build-system python)
+ #:use-module (guix build-system trivial)
#:use-module (guix download)
+ #:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module (guix svn-download)
#:use-module ((guix licenses) #:prefix license:)
@@ -844,3 +848,49 @@ (define-public tpm2-tss
libtss2-esys, libtss2-sys, libtss2-mu, libtss2-tcti-device, libtss2-tcti-swtpm
and libtss2-tcti-mssim.")
(license license:bsd-2)))
+
+(define-public gpu-switch
+ ;; No tagged commit. No "Version" keyword either.
+ (let ((commit "a365f56d435c8ef84c4dd2ab935ede4992359e31")
+ (revision "1"))
+ (package
+ (name "gpu-switch")
+ (version (git-version "0" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/0xbb/gpu-switch")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1jnh43nijkqd83h7piq7225ixziggyzaalabgissyxdyz6szcn0r"))))
+ (build-system trivial-build-system)
+ (arguments
+ (list
+ #:modules '((guix build utils))
+ #:builder
+ #~(begin
+ (use-modules (guix build utils))
+ (install-file #$(file-append source "/gpu-switch")
+ (string-append #$output "/bin"))
+ (substitute* (string-append #$output "/bin/gpu-switch")
+ (("basename") #$(file-append coreutils-minimal "/bin/basename"))
+ (("cat ") #$(file-append coreutils-minimal "/bin/cat "))
+ (("chattr") #$(file-append e2fsprogs "/bin/chattr"))
+ (("/usr/bin/env bash") #$(file-append bash-minimal "/bin/bash"))
+ (("grep") #$(file-append grep "/bin/grep"))
+ (("! mount")
+ (string-append "! " #$(file-append util-linux "/bin/mount"))))
+ (install-file
+ #$(file-append source "/README.md")
+ (string-append #$output "/share/doc/gpu-switch-" #$version)))))
+ (home-page "https://github.com/0xbb/gpu-switch")
+ (synopsis "GPU switcher for dual-GPU MacBook Pro models")
+ (description
+ "Switch between the integrated and dedicated GPU of dual-GPU MacBook Pro
+models for the next reboot.
+
+It aims to remove the need of booting into OS X and running gfxCardStatus
+v2.2.1 to switch to the integrated card.")
+ (license license:expat))))
--
2.34.0
J
J
Jorge Acereda wrote on 8 Jan 2022 20:53
[PATCH v4] gnu: Add gpu-switch.
(address . 53059@debbugs.gnu.org)(name . Jorge Acereda)(address . jacereda@gmail.com)
4cd31369f81c4d3ced341bbe9d0e3aaba95cdf47.1641671488.git.jacereda@gmail.com
Forgot to specify supported-systems.

* gnu/packages/graphics.scm (gpu-switch): New variable.
---
gnu/packages/hardware.scm | 51 +++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)

Toggle diff (83 lines)
diff --git a/gnu/packages/hardware.scm b/gnu/packages/hardware.scm
index 28647477fe..a8ec6567cd 100644
--- a/gnu/packages/hardware.scm
+++ b/gnu/packages/hardware.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name>
;;; Copyright © 2021 Vinicius Monego <monego@posteo.net>
;;; Copyright © 2021 John Kehayias <john.kehayias@protonmail.com>
+;;; Copyright © 2022 Jorge Acereda <jacereda@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -29,6 +30,7 @@ (define-module (gnu packages hardware)
#:use-module (gnu packages)
#:use-module (gnu packages admin)
#:use-module (gnu packages autotools)
+ #:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages compression)
#:use-module (gnu packages check)
@@ -64,7 +66,9 @@ (define-module (gnu packages hardware)
#:use-module (guix build-system gnu)
#:use-module (guix build-system meson)
#:use-module (guix build-system python)
+ #:use-module (guix build-system trivial)
#:use-module (guix download)
+ #:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module (guix svn-download)
#:use-module ((guix licenses) #:prefix license:)
@@ -844,3 +848,50 @@ (define-public tpm2-tss
libtss2-esys, libtss2-sys, libtss2-mu, libtss2-tcti-device, libtss2-tcti-swtpm
and libtss2-tcti-mssim.")
(license license:bsd-2)))
+
+(define-public gpu-switch
+ ;; No tagged commit. No "Version" keyword either.
+ (let ((commit "a365f56d435c8ef84c4dd2ab935ede4992359e31")
+ (revision "1"))
+ (package
+ (name "gpu-switch")
+ (version (git-version "0" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/0xbb/gpu-switch")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1jnh43nijkqd83h7piq7225ixziggyzaalabgissyxdyz6szcn0r"))))
+ (build-system trivial-build-system)
+ (arguments
+ (list
+ #:modules '((guix build utils))
+ #:builder
+ #~(begin
+ (use-modules (guix build utils))
+ (install-file #$(file-append source "/gpu-switch")
+ (string-append #$output "/bin"))
+ (substitute* (string-append #$output "/bin/gpu-switch")
+ (("basename") #$(file-append coreutils-minimal "/bin/basename"))
+ (("cat ") #$(file-append coreutils-minimal "/bin/cat "))
+ (("chattr") #$(file-append e2fsprogs "/bin/chattr"))
+ (("/usr/bin/env bash") #$(file-append bash-minimal "/bin/bash"))
+ (("grep") #$(file-append grep "/bin/grep"))
+ (("! mount")
+ (string-append "! " #$(file-append util-linux "/bin/mount"))))
+ (install-file
+ #$(file-append source "/README.md")
+ (string-append #$output "/share/doc/gpu-switch-" #$version)))))
+ (home-page "https://github.com/0xbb/gpu-switch")
+ (supported-systems '("x86_64-linux"))
+ (synopsis "GPU switcher for dual-GPU MacBook Pro models")
+ (description
+ "Switch between the integrated and dedicated GPU of dual-GPU MacBook Pro
+models for the next reboot.
+
+It aims to remove the need of booting into OS X and running gfxCardStatus
+v2.2.1 to switch to the integrated card.")
+ (license license:expat))))
--
2.34.0
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 53059@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 53059
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch