Merge branch 'grafting' into 'master'

Draft: nonguix: Add package-input-grafting.

See merge request nonguix/nonguix!608
This commit is contained in:
Hilton Chain 2025-02-17 02:20:59 +00:00
commit a58d16d5df
3 changed files with 32 additions and 28 deletions

View File

@ -876,19 +876,8 @@ variables @code{__GLX_VENDOR_LIBRARY_NAME=nvidia} and
(package-propagated-inputs nvidia-driver-beta)))
(inputs (list mesa-for-nvda nvidia-driver-beta))))
(define mesa/fake
(package
(inherit mesa)
(replacement nvda)))
(define-public mesa/fake-beta
(hidden-package
(package
(inherit mesa)
(replacement nvdb))))
(define-public replace-mesa
(package-input-rewriting `((,mesa . ,mesa/fake))))
(define-deprecated/public-alias replace-mesa
(package-input-grafting (list (cons mesa nvda))))
;;;

View File

@ -41,10 +41,6 @@
" This build of FFmpeg includes the nonfree NVIDIA encoder for
@code{h264_nvenc} and @code{hevc_nvenc} hardware encoding on NVIDIA GPUs."))))
(define-public replace-ffmpeg-nvenc
(package-input-rewriting
`((,ffmpeg . ,ffmpeg-nvenc))))
(define-public gmmlib
(package
(name "gmmlib")
@ -222,13 +218,3 @@ codec APIs.")
(package-description obs)
" This build of OBS includes embeded Chromium-based browser to enable
Browser source."))))
(define-public obs-nvenc
(let ((obs-ffmpeg-nvenc (replace-ffmpeg-nvenc obs)))
(package/inherit obs-ffmpeg-nvenc
(name "obs-nvenc")
(description
(string-append
(package-description obs)
" This build of OBS includes the nonfree NVIDIA encoder for FFmpeg
@code{h264_nvenc} and @code{hevc_nvenc} hardware encoding on NVIDIA GPUs.")))))

View File

@ -11,7 +11,8 @@
#:use-module (guix utils)
#:use-module (guix packages)
#:use-module (gnu services)
#:export (with-transformation))
#:export (package-input-grafting
with-transformation))
(define-public (to32 package64)
"Build package for i686-linux.
@ -26,6 +27,34 @@ Only x86_64-linux and i686-linux are supported.
,@(package-arguments package64)))))
(_ package64)))
(define (package-input-grafting replacements)
"Return a procedure that, when passed a package, grafts its direct and
indirect dependencies, including implicit inputs, according to REPLACEMENTS.
REPLACEMENTS is a list of package pairs; the first element of each pair is the
package to replace, and the second one is the replacement.
Name and version of replacement packages will be padded to meet graft
requirement."
(package-input-rewriting
(map (match-lambda
((old . new)
`(,old . ,(package
(inherit old)
(replacement
(package
(inherit new)
(name
(string-pad-right
(package-name new)
(string-length (package-name old))
#\0))
(version
(string-pad-right
(package-version new)
(string-length (package-version old))
#\0))))))))
replacements)))
;; For concerns and direction of improvement, see this thread:
;; https://lists.gnu.org/archive/html/guix-devel/2024-06/msg00275.html
(define* (with-transformation proc obj #:optional (pred package?))