From ea827812f2b2dbc569f4b3478c3bc4645ea2eb15 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 14 Mar 2026 11:18:30 +0100 Subject: channels: Resolve dependencies recursively. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/channels.scm (closure): New procedure. (resolve-dependencies): Use it. * tests/channels.scm ("channel-instance-dependency-resolver"): New test. Fixes: https://issues.guix.gnu.org/68797 Change-Id: Iaba4f54261e33e18bd57a0a319aa099f259b8570 Signed-off-by: Ludovic Courtès Merges: #7137 --- tests/channels.scm | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/channels.scm b/tests/channels.scm index 15deb551ffa..2df4c86b5a8 100644 --- a/tests/channels.scm +++ b/tests/channels.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Ricardo Wurmus -;;; Copyright © 2019-2020, 2022, 2024 Ludovic Courtès +;;; Copyright © 2019-2020, 2022, 2024, 2026 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -278,6 +278,61 @@ #:current-channels (list new) #:validate-pull validate-pull))))))) +(test-equal "channel-instance-dependency-resolver" + '((c => (a b)) (b => (a)) (a => ())) + ;; Check that channel dependencies propagate. Here we create three channels + ;; that depend on one another: c depends on b, which depends on a. When + ;; resolving dependencies for c, we must get both a and b, such that + ;; (use-modules (b)) from channel c finds (a) when building the derivation + ;; of channel c. See . + (let ((call-with-channel + (lambda (name dependencies channels proc) + (with-temporary-git-repository directory + `((add ,(string-append (symbol->string name) ".scm") + ,(object->string + `(define-module (,name) + ,@(append-map (lambda (dependency) + `(#:use-module (,dependency))) + dependencies)))) + (add ".guix-channel" + ,(object->string + `(channel + (version 0) + (dependencies + ,@(map (lambda (dependency) + `(channel + (name ,dependency) + (url "http://example.org"))) + dependencies))))) + (commit "Initial commit.")) + (proc (cons (channel + (name name) + (url directory)) + channels)))))) + (define-syntax with-channels + (syntax-rules (&initialized) + ((_ &initialized binding (name dependencies) rest ... exp) + (call-with-channel 'name dependencies binding + (lambda (binding) + (with-channels &initialized binding + rest ... exp)))) + ((_ &initialized binding exp) exp) + ((_ binding rest ...) + (let ((binding '())) + (with-channels &initialized binding rest ...))))) + + (with-channels + channels (a '()) (b '(a)) (c '(b)) + (with-store store + (let* ((instances (latest-channel-instances store channels)) + (resolve (channel-instance-dependency-resolver instances))) + (map (lambda (instance) + (list (channel-name (channel-instance-channel instance)) + '=> + (map (compose channel-name channel-instance-channel) + (resolve instance)))) + instances)))))) + (test-assert "channel-instances->manifest" ;; Compute the manifest for a graph of instances and make sure we get a ;; derivation graph that mirrors the instance graph. This test also ensures -- cgit v1.3