From patchwork Fri Jan 7 18:37:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jorge Acereda X-Patchwork-Id: 36115 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9A2E427BBEA; Fri, 7 Jan 2022 20:20:57 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 08CC927BBE9 for ; Fri, 7 Jan 2022 20:20:57 +0000 (GMT) Received: from localhost ([::1]:58366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5uEC-0004uk-G0 for patchwork@mira.cbaines.net; Fri, 07 Jan 2022 13:44:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5uDb-0004tk-M7 for guix-patches@gnu.org; Fri, 07 Jan 2022 13:44:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:52987) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n5uDb-0004jO-92 for guix-patches@gnu.org; Fri, 07 Jan 2022 13:44:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n5uDa-0006GJ-FV for guix-patches@gnu.org; Fri, 07 Jan 2022 13:44:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53059] [PATCH v2] gnu: Add gpu-switch. References: <79655b434893691c6647f28087652f162aad80de.1641496236.git.jacereda@gmail.com> In-Reply-To: <79655b434893691c6647f28087652f162aad80de.1641496236.git.jacereda@gmail.com> Resent-From: Jorge Acereda Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 07 Jan 2022 18:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53059 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53059@debbugs.gnu.org Cc: Jorge Acereda Received: via spool by 53059-submit@debbugs.gnu.org id=B53059.164158103624046 (code B ref 53059); Fri, 07 Jan 2022 18:44:02 +0000 Received: (at 53059) by debbugs.gnu.org; 7 Jan 2022 18:43:56 +0000 Received: from localhost ([127.0.0.1]:45890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5uDQ-0006Fg-OU for submit@debbugs.gnu.org; Fri, 07 Jan 2022 13:43:56 -0500 Received: from mail-wr1-f48.google.com ([209.85.221.48]:35651) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5uDJ-0006FI-GU for 53059@debbugs.gnu.org; Fri, 07 Jan 2022 13:43:51 -0500 Received: by mail-wr1-f48.google.com with SMTP id e9so11230077wra.2 for <53059@debbugs.gnu.org>; Fri, 07 Jan 2022 10:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0jOmp8sm+I0njEp1KAjAqRcU4CBb9i/a5zPESWjyQ0I=; b=FcAQhKLPl2tC1zf0Xnaphd5vezVxCBRNAqCdokwrqjzJP3QD+j+vae/Ll3ymqBZvk/ Zc4KsGzAQCmuCiO4wd4tUkyaOiWRiDN2yyUW6Iorv9kaqo7Xbqk3EjF8dV/K1i/4JPHv 6u6Vbm7jDGTLVm5hqwSw9TBSL6kL8X90e0Mc9AQ6KKgXaMRtzON+ua5vHe9iyuy2ZTEh kO9RXuhr7DKKTNNRlE0ZEfwI/GLBTZd6eKTZqhDiv+D7Of65xHKTAHLYaZGPmbV2KJ0w LKhEpLety+qyot/IefQxXAnA6PvebNfaLEIB1kd9EUThc+alcfyv7cH9vmYYWGzjOH1O 99LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0jOmp8sm+I0njEp1KAjAqRcU4CBb9i/a5zPESWjyQ0I=; b=3avCeziLWncHrc7dK1B4USVHnt1BlvtTKTotmrqA3DI5kSocHm0IwVg0HadP7g0R+9 ca9HzDWUqPOmn1ER+tgYkjOQp0d0Ga99ttMJZ7hO4Cfhu+TxHndC7m/aqwHGp+iipN+M +FxUoM5/yxYcyUeDGKfo0+j9hddtVWT+O0E7KSIVpZB9lpA291yh6VY6Ix0oO8VZ3CNt 7oYTAN502IrvblYnAyVj3ZMhPC0X8lcTfoGoKU8GtgDfktzI7h3XwBJpDHRdxLQMRvXK LFJ3igWeN8dGNX78mkpNy2LBn01CO5ctkJ1hfKl/yyNsKXnaPbqBIpKIX76VIo8oLKRq Dezg== X-Gm-Message-State: AOAM530/ZFy65t8rV5WrJQeYcQA95Z+KhGFhGglsTL5WewKVBspFUglt dfS/4QrNjCekT3Ozmm1maMxZDfYbOUYQ2w== X-Google-Smtp-Source: ABdhPJzHzUN2afFc27mPMSrQhbbV45BEK6gJ3/AiK+aRTxmfEA2szMo2G0Yd7j7GcERfa/utdywYLA== X-Received: by 2002:a5d:6389:: with SMTP id p9mr295197wru.125.1641580645954; Fri, 07 Jan 2022 10:37:25 -0800 (PST) Received: from localhost.localdomain ([185.39.42.151]) by smtp.gmail.com with ESMTPSA id b14sm5616018wrg.15.2022.01.07.10.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 10:37:25 -0800 (PST) From: Jorge Acereda Date: Fri, 7 Jan 2022 19:37:20 +0100 Message-Id: <6a263efbca6f379b056e06887de50e6cccac9929.1641580314.git.jacereda@gmail.com> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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))) +