From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mMEOLjl8pmAo7gAAgWs5BA (envelope-from ) for ; Thu, 20 May 2021 17:11:53 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 2LCxKTl8pmBFbQAAbx9fmQ (envelope-from ) for ; Thu, 20 May 2021 15:11:53 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2F3181D62B for ; Thu, 20 May 2021 17:11:53 +0200 (CEST) Received: from localhost ([::1]:46956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljkL2-0006r7-AC for larch@yhetil.org; Thu, 20 May 2021 11:11:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljk8y-0008Ci-6j for guix-devel@gnu.org; Thu, 20 May 2021 10:59:24 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35230) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljk8x-0001kn-US; Thu, 20 May 2021 10:59:23 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=45618 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljk8w-0005bZ-UV; Thu, 20 May 2021 10:59:23 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-devel@gnu.org Subject: [PATCH RFC 2/4] DRAFT packages: Allow inputs to be plain package lists. Date: Thu, 20 May 2021 16:58:28 +0200 Message-Id: <20210520145830.14108-3-ludo@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520145830.14108-1-ludo@gnu.org> References: <20210520145830.14108-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621523513; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NuywspPzM4+JCFY6neL5KW6icSdZ4a9gFtKrtGRLeeU=; b=X82RoGOxRRI0dvg32RUBwr1dzYEB+jCIIu0he7WRoxLNYo52CcSWPFfUf4BWIGvov/KcXZ sRUFkJruvXE0Ya8VmrRdSbORh7Kdn8fLSRS9g2tyVaWBL67N0xjif2CVgOaZT8OOPy5zll hEV2Br6/wUntiZmvQmTeVVt6/8gJSDA/G0uHK8QMFTmuQP+g5HMEYjtRXqoVlYU7KQ8Wuy /hIczMK70kCytQHn3BY+gfGOPezbCGUsU5NDuUCbb7sy5COCv5tENxN9DgilUA/KpM7h8a S9qYJDy9p3FjovqFkBK+wkJ0HBhhcQy64QK1lzOtHb9PtNi8dDHKYmF/cgQeHA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621523513; a=rsa-sha256; cv=none; b=hdICmjHNwbLmM7L3TfcYLRRWKEP8KSqlfF8HvFQYPegOJOgjIN+bPCNndbE7vDj1j+6GNJ +wSBHqd3nEgOzwSJieSNcIvrQ17Npy8P9ly0KvryVunPejwxhr93ZDA6dD6Cc62bSPYse2 tg6Rdux4rOvTtLz/gq+5VBOWGPibUUTAExAkWzQbkBQsRrIsonIpJt8dWfSN3g/BvDFYmP /PpB1a+TLL7VAilMnCva+I684aRAjWox+Z+s0fSB+Ao/SS9QoYOaPXeNW7xdG56KTP0kWp rkXh7gyqLuZXoiXnAmI/XEzM8K7vYmyCtbNPBKDYP6lX2xlKYnobNkDhsBaLEw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Spam-Score: 2.06 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 2F3181D62B X-Spam-Score: 2.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: npOg/opV8WZ8 DRAFT: Is it a good idea? If it is, add tests and doc. * guix/packages.scm (add-input-label, sanitize-inputs): New procedures. ()[inputs, propagated-inputs, native-inputs]: Add 'sanitize' property. --- guix/packages.scm | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/guix/packages.scm b/guix/packages.scm index ba19174646..fc3290b8e8 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -366,6 +366,32 @@ name of its URI." ;; . (fold delete %supported-systems '("mips64el-linux"))) +(define (add-input-label input) + "Add an input label to INPUT." + (match input + ((? package? package) + (list (package-name package) package)) + (((? package? package) output) ;XXX: ugly? + (list (package-name package) package output)) + ((? gexp-input?) ;XXX: misplaced because 'native?' field is ignored? + (let ((obj (gexp-input-thing input)) + (output (gexp-input-output input))) + `(,(if (package? obj) + (package-name obj) + "_") + ,obj + ,@(if (string=? output "out") '() (list output))))) + (x + `("_" ,x)))) + +(define-inlinable (sanitize-inputs inputs) + "Sanitize INPUTS by turning it into a list of name/package tuples if it's +not already the case." + (cond ((null? inputs) inputs) + ((and (pair? (car inputs)) + (string? (caar inputs))) + inputs) + (else (map add-input-label inputs)))) ;; A package. (define-record-type* @@ -380,11 +406,14 @@ name of its URI." (default '()) (thunked)) (inputs package-inputs ; input packages or derivations - (default '()) (thunked)) + (default '()) (thunked) + (sanitize sanitize-inputs)) (propagated-inputs package-propagated-inputs ; same, but propagated - (default '()) (thunked)) + (default '()) (thunked) + (sanitize sanitize-inputs)) (native-inputs package-native-inputs ; native input packages/derivations - (default '()) (thunked)) + (default '()) (thunked) + (sanitize sanitize-inputs)) (outputs package-outputs ; list of strings (default '("out"))) -- 2.31.1