GNU bug report logs - #53059
[PATCH] gnu: Add gpu-switch.

Previous Next

Package: guix-patches;

Reported by: Jorge Acereda <jacereda <at> gmail.com>

Date: Thu, 6 Jan 2022 19:12:01 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 53059 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#53059; Package guix-patches. (Thu, 06 Jan 2022 19:12:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jorge Acereda <jacereda <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 06 Jan 2022 19:12:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jorge Acereda <jacereda <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Jorge Acereda <jacereda <at> gmail.com>
Subject: [PATCH] gnu: Add gpu-switch.
Date: Thu,  6 Jan 2022 20:11:08 +0100
* gnu/packages/graphics.scm (gpu-switch): New variable.
---
 gnu/packages/graphics.scm | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

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 <at> atai.org>
 ;;; Copyright © 2021 Ekaitz Zarraga <ekaitz <at> elenq.tech>
 ;;; Copyright © 2021 Vinicius Monego <monego <at> posteo.net>
+;;; Copyright © 2022 Jorge Acereda <jacereda <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#53059; Package guix-patches. (Thu, 06 Jan 2022 21:02:02 GMT) Full text and rfc822 format available.

Message #8 received at 53059 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: 53059 <at> debbugs.gnu.org
Cc: Jorge Acereda <jacereda <at> gmail.com>
Subject: Re: [PATCH] gnu: Add gpu-switch.
Date: Thu, 06 Jan 2022 22:01:17 +0100
[Message part 1 (text/plain, inline)]
Hi,

Looking at <https://github.com/0xbb/gpu-switch/blob/master/gpu-switch>,
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.

> +    (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
<https://github.com/0xbb/gpu-switch/releases>.

Greetings,
Maxime.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#53059; Package guix-patches. (Fri, 07 Jan 2022 10:47:02 GMT) Full text and rfc822 format available.

Message #11 received at 53059 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Jorge Acereda <jacereda <at> gmail.com>
Cc: 53059 <at> debbugs.gnu.org
Subject: Re: [PATCH] gnu: Add gpu-switch.
Date: Fri, 07 Jan 2022 11:45:54 +0100
[Message part 1 (text/plain, inline)]
[Re-adding debbugs to CC]

Jorge Acereda schreef op vr 07-01-2022 om 02:02 [+0100]:
> [...]
> > 
> > /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
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#53059; Package guix-patches. (Fri, 07 Jan 2022 18:44:02 GMT) Full text and rfc822 format available.

Message #14 received at 53059 <at> debbugs.gnu.org (full text, mbox):

From: Jorge Acereda <jacereda <at> gmail.com>
To: 53059 <at> debbugs.gnu.org
Cc: Jorge Acereda <jacereda <at> gmail.com>
Subject: [PATCH v2] gnu: Add gpu-switch.
Date: Fri,  7 Jan 2022 19:37:20 +0100
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(-)

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 <at> atai.org>
 ;;; Copyright © 2021 Ekaitz Zarraga <ekaitz <at> elenq.tech>
 ;;; Copyright © 2021 Vinicius Monego <monego <at> posteo.net>
+;;; Copyright © 2022 Jorge Acereda <jacereda <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#53059; Package guix-patches. (Sat, 08 Jan 2022 15:39:01 GMT) Full text and rfc822 format available.

Message #17 received at 53059 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Jorge Acereda <jacereda <at> gmail.com>, 53059 <at> debbugs.gnu.org
Subject: Re: [PATCH v2] gnu: Add gpu-switch.
Date: Sat, 08 Jan 2022 15:38:20 +0000
[Message part 1 (text/plain, inline)]
Jorge Acereda schreef op vr 07-01-2022 om 19:37 [+0100]:
> 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'.

> * 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.
<https://boinc.berkeley.edu/wiki/GPU_computing>.
I would put it in hardware.scm instead.

> @@ -27,6 +27,7 @@
>  ;;; Copyright © 2021 Andy Tai <atai <at> atai.org>
>  ;;; Copyright © 2021 Ekaitz Zarraga <ekaitz <at> elenq.tech>
>  ;;; Copyright © 2021 Vinicius Monego <monego <at> posteo.net>
> +;;; Copyright © 2022 Jorge Acereda <jacereda <at> 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.

>  
>  (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.

> +    (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) ...) ...)

> +                (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.

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

Likewise.

> +           (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.

> +           (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.

> +                            ((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)))

> +           #t))))

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

> +    (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.

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

> +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.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#53059; Package guix-patches. (Sat, 08 Jan 2022 19:44:02 GMT) Full text and rfc822 format available.

Message #20 received at 53059 <at> debbugs.gnu.org (full text, mbox):

From: Jorge Acereda <jacereda <at> gmail.com>
To: 53059 <at> debbugs.gnu.org
Cc: Jorge Acereda <jacereda <at> gmail.com>
Subject: [PATCH v3] gnu: Add gpu-switch.
Date: Sat,  8 Jan 2022 20:42:23 +0100
* gnu/packages/graphics.scm (gpu-switch): New variable.
---
 gnu/packages/hardware.scm | 50 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

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 <at> raghavgururajan.name>
 ;;; Copyright © 2021 Vinicius Monego <monego <at> posteo.net>
 ;;; Copyright © 2021 John Kehayias <john.kehayias <at> protonmail.com>
+;;; Copyright © 2022 Jorge Acereda <jacereda <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#53059; Package guix-patches. (Sat, 08 Jan 2022 19:54:02 GMT) Full text and rfc822 format available.

Message #23 received at 53059 <at> debbugs.gnu.org (full text, mbox):

From: Jorge Acereda <jacereda <at> gmail.com>
To: 53059 <at> debbugs.gnu.org
Cc: Jorge Acereda <jacereda <at> gmail.com>
Subject: [PATCH v4] gnu: Add gpu-switch.
Date: Sat,  8 Jan 2022 20:53:04 +0100
Forgot to specify supported-systems.

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

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 <at> raghavgururajan.name>
 ;;; Copyright © 2021 Vinicius Monego <monego <at> posteo.net>
 ;;; Copyright © 2021 John Kehayias <john.kehayias <at> protonmail.com>
+;;; Copyright © 2022 Jorge Acereda <jacereda <at> 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





This bug report was last modified 2 years and 100 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.