From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id aJw3HslBaGKjYwEAbAwnHQ (envelope-from ) for ; Tue, 26 Apr 2022 21:02:33 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id wNRHHslBaGIYFgAAauVa8A (envelope-from ) for ; Tue, 26 Apr 2022 21:02:33 +0200 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 DFC882E882 for ; Tue, 26 Apr 2022 21:02:32 +0200 (CEST) Received: from localhost ([::1]:32928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njQSF-0006c2-4Y for larch@yhetil.org; Tue, 26 Apr 2022 15:02:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njPpE-0000az-Q3 for gwl-devel@gnu.org; Tue, 26 Apr 2022 14:22:12 -0400 Received: from sender4-of-o50.zoho.com ([136.143.188.50]:21047) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njPpC-0005CY-Tr for gwl-devel@gnu.org; Tue, 26 Apr 2022 14:22:12 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1650997326; cv=none; d=zohomail.com; s=zohoarc; b=gnW3tQCPO+Iash/hKdWSLrAUhUxsyysUOuq/xA8yR1hgQihKg1gtc5X6ISlXxqIrfI79CIiUnrcyFIyVUQd+n5v5hePu95Zy5s5Ij3UggUUvMNAqVzTyS6XrJ1nWtI8yrATDR0kn8Au1o9jvM7EVq+4V6OU8s4XUwDHjbH78cHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650997326; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=H8wzN31Y0G0pwTlP55TLm939XvaDbllL7xh3aUBECj4=; b=RKGEUUrP+IgwPf2VHlS23RQqYxA6Q5ZKyDK5nlEQfJzjDTFX5u7ySaFdeSbgiV7q9eZ++igeAP88fb3s2l/zlfSsS7XRH/K+Cq7gfE9CKDJKL1cssYdGW+iWIbg1eS8jiAiAiSTwVMnFcq1j7CGa/PCBadjtHSJtTrmL5XqP79g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1650997326; s=zoho; d=elephly.net; i=rekado@elephly.net; h=References:From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:In-reply-to:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=H8wzN31Y0G0pwTlP55TLm939XvaDbllL7xh3aUBECj4=; b=XXQbvlaOV5NO6yi1JYTKUKKMDzCG1Q00Dq+J1wCv4bvm0E2Lf8bbnNhruorc8sa6 pY8xzbytQBXpQoUcCgzx8hmmtDf8Eozy6oB/w9cnPV7zvToidhpB5G7VLQPL+muxL9z moiqlfRnNj/gm93W1xdPgNvxz4JurDw/ykZMc9mk= Received: from localhost (56-111-142-46.pool.kielnet.net [46.142.111.56]) by mx.zohomail.com with SMTPS id 1650997325407994.651070603066; Tue, 26 Apr 2022 11:22:05 -0700 (PDT) References: <20220421195158.22407-1-olivier.dion@polymtl.ca> <20220422184359.7929-1-olivier.dion@polymtl.ca> <20220422184359.7929-2-olivier.dion@polymtl.ca> User-agent: mu4e 1.6.10; emacs 28.0.50 From: Ricardo Wurmus To: Olivier Dion Subject: Re: [PATCH v2 1/2] packages: Support for full Guix specification Date: Tue, 26 Apr 2022 20:11:39 +0200 In-reply-to: <20220422184359.7929-2-olivier.dion@polymtl.ca> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Message-ID: <87ilqv66yd.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.50; envelope-from=rekado@elephly.net; helo=sender4-of-o50.zoho.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: gwl-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gwl-devel@gnu.org Errors-To: gwl-devel-bounces+larch=yhetil.org@gnu.org Sender: "gwl-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650999753; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=H8wzN31Y0G0pwTlP55TLm939XvaDbllL7xh3aUBECj4=; b=Rb2RJxwlRTcHhygUuLQZRRvZCTkL1ZuqushLfl7MToDA4tAEadfAHf46br1Si4ce/O8Quz H6fXuVumjlHiBJqUc72ZkFuGqY18A6x8Tu57zsv95/QgM06QcYAgbnS85iquWqZZBBR3jx bfk6v0jO8NJsZceawBoWJ/95pajg/gRguRHvAhJMAmEcsvMNQxVBry1BRlRYw+l4dT8oII MZennGfbWuK931pVO0xIbzTfNR4CpNIKdMpzM8HQJ+IHo770UoWxaigoHSZQsq8sD/MvQL lNoP7/Bm3LHVZtTXeWlSwudpUPwSvDBudZw4h6ejs+tArLlM0gQVsSVNenJSIA== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1650999753; a=rsa-sha256; cv=pass; b=XboOvWFW8gyzTc5fq6ZB1D3D6DMBLzSFSDP91hX50AMgYrk03DRZ34taxEtqHN3JH6gsyC CmizNaeqr5/mc/f7ZnXq6bj2/2euuoQIh3CjJS8lfwHbU4bNIbKy1HPj8zr/Z1t+oewKPK wZ2LAlJT2QuVbmUCZwjWeVt5cjPsEo3XnHvo/HPk3Mw8Rr5RL5olAbNkvxQMkrGPsz0RL7 NCXqawteAkgtDx1wAP/R9UTz7IVFckiP4tJ7v0UwzQ5sBeXtMDkLtUe2TrPWaLoe7AoGpx pYACVY0V6aNqLIDucpxNp+3CyQ0PcjlOTKbqyJc9g/KE0DzRokmf9vnEhE+wyg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=elephly.net header.s=zoho header.b=XXQbvlaO; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of "gwl-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="gwl-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.51 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=elephly.net header.s=zoho header.b=XXQbvlaO; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of "gwl-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="gwl-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: DFC882E882 X-Spam-Score: -4.51 X-Migadu-Scanner: scn1.migadu.com X-TUID: t7kaOuk8TgbZ Hi Olivier, thank for the patch! > -(define (lookup-package specification) > +(define (%lookup-package name+version output) > + (list (match (apply lookup-inferior-packages > + (cons (current-guix) (string-split name+version #\= @))) I don=E2=80=99t think we need the cons here. As long as the last argument = to APPLY is a list everything=E2=80=99s fine. > + ((first . rest) first) > + (_ (raise (condition > + (&gwl-package-error > + (package-spec (string-append name+version output))= ))))) > + output)) I=E2=80=99d prefer to have this return multiple values instead of a compound value. And if it had to be a compound value for some reason I=E2=80=99d pr= efer to use a dedicated data type (a record value) instead of a list. > + > +(define* (lookup-package specification #:optional (output "out")) > (log-event 'guix (G_ "Looking up package `~a'~%") specification) > - (match (lookup-inferior-packages (current-guix) specification) > - ((first . rest) first) > - (_ (raise (condition > - (&gwl-package-error > - (package-spec specification))))))) > + (match (string-split specification #\:) > + ((name+version sub-drv) (%lookup-package name+version sub-drv)) > + ((name+version) (simple-package (%lookup-package name+version output= ))))) I=E2=80=99m not sure about forcing SIMPLE-PACKAGE to be used because the re= turn value might be an output. The stuff in (guix inferior) also doesn=E2=80=99t know about outputs, so I feel that we shouldn=E2=80=99t attempt to include syntax for selecting outputs. IIRC we=E2=80=99ll end up with all outputs i= n the environment, so there=E2=80=99s no actual effect of picking a specific outp= ut. I=E2=80=99d prefer to revisit this once (guix inferior) supports selecting outputs. What do you think? > (define (valid-package? val) > - (or (package? val) > - (inferior-package? val))) > + (or > + (and (list? val) > + (valid-package? (car val)) > + (string? (cadr val))) > + (package? val) > + (inferior-package? val))) > + > +(define (simple-package pkg) > + (if (list? pkg) (car pkg) pkg)) Generally, I prefer to use MATCH instead of CAR and CDR. But in this case I=E2=80=99d prefer not to overload the meaning of =E2=80=9Cpackage=E2= =80=9D to include lists. --=20 Ricardo