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 ;;; Copyright © 2021 Ekaitz Zarraga ;;; Copyright © 2021 Vinicius Monego +;;; Copyright © 2022 Jorge Acereda ;;; ;;; 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