From 4caa67738f0043ad65af48f0f0b653727ae47736 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sun, 6 Jul 2025 16:35:13 +0800 Subject: [PATCH] feat: Use inputs from bags in inputs-from To support arbitrary build system with its all build inputs, use bags instead of packages for obtaining inputs. --- modules/cross-shells/cross-profile.scm | 61 ++++++++++++++++---------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/modules/cross-shells/cross-profile.scm b/modules/cross-shells/cross-profile.scm index be9a57b..a20afc8 100644 --- a/modules/cross-shells/cross-profile.scm +++ b/modules/cross-shells/cross-profile.scm @@ -1,6 +1,7 @@ (define-module (cross-shells cross-profile) #:use-module (srfi srfi-1) #:use-module (cross-shells cross-packages) + #:use-module (guix build-system) #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix records) @@ -62,6 +63,17 @@ (define transitive-inputs (@@ (guix packages) transitive-inputs)) +(define (cross-profile-inputs-from->bags cross-profile) + (match-record + cross-profile + (target-system host-system inputs-from) + (map + (lambda (package) + (package->bag package + host-system + target-system)) + inputs-from))) + (define (collect-cross-profile-target-inputs cross-profile) ;; Get all inputs (merged inputs and inputs-from inputs) ;; Also collect propagated inputs. Make sure only unique packages. @@ -69,12 +81,14 @@ (match-record cross-profile (target-inputs base-target-inputs host-system target-system) - (map (lambda (input) - (car (cdr input))) - (transitive-inputs - (append - (base-target-inputs host-system target-system) - target-inputs))))) + (filter package? + (map (lambda (input) + (car (cdr input))) + (transitive-inputs + (append + (base-target-inputs host-system target-system) + (apply append (map bag-target-inputs (cross-profile-inputs-from->bags cross-profile))) + target-inputs)))))) (define (collect-cross-profile-inputs cross-profile) ;; Get all inputs (merged inputs and inputs-from inputs) @@ -83,28 +97,31 @@ (match-record cross-profile (inputs inputs-from base-inputs host-system target-system) - (map (lambda (input) - (if (package? input) - input - (car (cdr input)))) - (transitive-inputs - (append - (base-inputs host-system target-system) - (apply append (map package-inputs inputs-from)) - inputs))))) + (filter package? + (map (lambda (input) + (if (package? input) + input + (car (cdr input)))) + (transitive-inputs + (append + (base-inputs host-system target-system) + (apply append (map bag-host-inputs (cross-profile-inputs-from->bags cross-profile))) + inputs)))))) (define (collect-cross-profile-native-inputs cross-profile) ;; Get all nativeinputs (merged native-inputs and inputs-from native-inputs) (match-record cross-profile (native-inputs inputs-from base-native-inputs host-system target-system) - (map (lambda (input) - (car (cdr input))) - (transitive-inputs - (append - (base-native-inputs host-system target-system) - (apply append (map package-native-inputs inputs-from)) - native-inputs))))) + (filter package? + (map (lambda (input) + (car (cdr input))) + (transitive-inputs + (append + (base-native-inputs host-system target-system) + (apply append (map package-native-inputs inputs-from)) + (apply append (map bag-build-inputs (cross-profile-inputs-from->bags cross-profile))) + native-inputs)))))) (define (collect-cross-profile-search-paths cross-profile) (match-record -- 2.49.0