From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 QMj3IkLvbmI+YgEAbAwnHQ (envelope-from ) for ; Sun, 01 May 2022 22:36:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id mEwrIkLvbmIyeAAAG6o9tA (envelope-from ) for ; Sun, 01 May 2022 22:36:18 +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 7952139A1A for ; Sun, 1 May 2022 22:36:17 +0200 (CEST) Received: from localhost ([::1]:40312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlGIi-0006lh-7o for larch@yhetil.org; Sun, 01 May 2022 16:36:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlGIU-0006kW-7P for guix-patches@gnu.org; Sun, 01 May 2022 16:36:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlGIT-0001t0-QU for guix-patches@gnu.org; Sun, 01 May 2022 16:36:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nlGIT-0002nk-JY for guix-patches@gnu.org; Sun, 01 May 2022 16:36:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55030] [PATCH 00/30] gnu: elm: Update to 0.19.1. Add build system & importer. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 01 May 2022 20:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55030 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Philip McGrath Cc: 55030@debbugs.gnu.org Received: via spool by 55030-submit@debbugs.gnu.org id=B55030.165143734010738 (code B ref 55030); Sun, 01 May 2022 20:36:01 +0000 Received: (at 55030) by debbugs.gnu.org; 1 May 2022 20:35:40 +0000 Received: from localhost ([127.0.0.1]:34298 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlGI7-0002n8-Pe for submit@debbugs.gnu.org; Sun, 01 May 2022 16:35:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlGI6-0002mv-0j for 55030@debbugs.gnu.org; Sun, 01 May 2022 16:35:38 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:43498) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlGI0-0001sP-Jq; Sun, 01 May 2022 16:35:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=3Qrx9yxkL7EDWCjeG9ggGaQ9dSA630nPcfJWekIR7+M=; b=pvZTGDQ+ayOfC97WhoIk UpogXsk9Y55Wcm50XJscSNO3WpgyUzMvtStH/OvzNFZKaANBzIxQRwn1RBhRQL2vWrJk6KgI39teD MeFQUpSiuNocvFJx+p3mLHpvz5ct4P0pOB5FrJDcumA4pXUQKUQKwDqa8YM+VKU6hQAtXFZX2oCnB njMQ0gQ4DmkoPgPEJuhLxXUURZtgmiIge/PfVxAtSXRyFuPVPnOjstSXflN3G5HGJ6gnyMTGr4AjM iaNgP5vRW98UfCWCQSOUBebH8vkNygHjD2DbyFf58PKqGv7cnBoR91Y1hzqxfieS6K0utNyZscFwE WGrYu6BlhnGYeg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:51353 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlGHz-0001DF-JR; Sun, 01 May 2022 16:35:32 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20220419232736.272970-1-philip@philipmcgrath.com> <20220419233214.275789-1-philip@philipmcgrath.com> <20220419233214.275789-3-philip@philipmcgrath.com> Date: Sun, 01 May 2022 22:35:29 +0200 In-Reply-To: <20220419233214.275789-3-philip@philipmcgrath.com> (Philip McGrath's message of "Tue, 19 Apr 2022 19:31:47 -0400") Message-ID: <874k292dpq.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1651437378; 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:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=3Qrx9yxkL7EDWCjeG9ggGaQ9dSA630nPcfJWekIR7+M=; b=N1LCPZppQhvWheF5UGKC3iNOc058M3Q/D6U4cSjghaHBMVJc59829YY+1EZEJ4iC7yPW71 OZqfYLxyCHSh4b6y9akHDVGlDlmN+DDONpa7NektCIZ9TWJnIU57W75CX4ClRTBjZM4I6O Ndz5euIdaAD/mFc/WO7G+ezHt6iDEwj6KcMocoD3PBhTij0RdOQHHiTQqdabeci1AggVzo pTBKuJJLjzZprExwE5D7ry3tmcv0BwVVKQcPvPuqr2cLuj8vadZw6meaa0961L/64qaUga C84ziCrlQG2uthBr4OnXg82nnN4c1nL8ReVc8yu7XX1LU0SaXpoSnlJyLgSDDQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651437378; a=rsa-sha256; cv=none; b=Ur2BSZTyvVgBUvmOmZC+1CVGCKtwSANDgB3qseMP7jda73bWPxmCGWlPkfZCvflsDlinHM z6wpIsmjy9Qig9tT8Wg6pRv8+9KAF4H7zD9dGBjKYJu2K1hn14e+emY/cwzTgKJKanVMgc jHc5P5PavUtuEFXJ40NNNXLZzRLvKlJbtl6RGosmU4g21pcrq5oHTw2yturHCs4hC42mQv g6GoIyU/F7CvafoUnsPwKGaWnHqux/HIJ34l4EnRuLU8tO3DcOtI5ciUfcXfgPTdxtlFrz 6BsCTXiWlEEFQw1gs0QcbvUXlqmXJsoGZqTofMXF0rnRwRS8wJ/Fi1RaSL6/oQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=pvZTGDQ+; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.89 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=pvZTGDQ+; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 7952139A1A X-Spam-Score: -3.89 X-Migadu-Scanner: scn1.migadu.com X-TUID: KLdcb5u97iGj Philip McGrath skribis: > * gnu/packages/patches/elm-offline-package-registry.scm: New file. > * gnu/local.mk (dist_patch_DATA): Add it. > * gnu/packages/elm.scm (elm): Use it. > * guix/build-system/elm.scm, guix/build/elm-build-system.scm, > guix/import/elm.scm, guix/scripts/import/elm.scm: New files. > * guix/scripts/import.scm (importers): Add "elm". I think the custom would be to add the importer in a separate commit; if you can do that, that=E2=80=99s great. Could you add an entry for the importer under =E2=80=9CInvoking guix import= =E2=80=9D, and one for the build system under =E2=80=9CBuild Systems=E2=80=9D in guix.= texi? You can follow existing entries as a template. It would be nice to have tests for the importer. One way to do that is like =E2=80=98tests/cpan.scm=E2=80=99, which spawns an HTTP server that mim= ics the real registry. > +;; COMMENTARY: Nitpick: You can make that literally =E2=80=9C;;; Commentary:=E2=80=9D. T= hat=E2=80=99s what (ice-9 documentation) expects. > +;; CODE: Likewise: =E2=80=9C;;; Code:=E2=80=9D. > +(define elm-package-registry > + ;; It is much nicer to fetch this small (< 40 KB gzipped) > + ;; file once than to do many HTTP requests. > + (mlambda () > + "Fetch the Elm package registry, represented as a vhash mapping pack= age > +names to lists of available versions, sorted from latest to oldest." > + (let ((url "https://package.elm-lang.org/all-packages")) > + (cond > + ((json-fetch url) > + =3D> (lambda (alist) > + (fold (lambda (entry vh) > + (match entry > + ((name . vec) > + (vhash-cons name > + (sort (vector->list vec) version>?) > + vh)))) > + vlist-null > + alist))) > + (else > + (raise (formatted-message > + (G_ "error downloading Elm package registry from ~a") > + url))))))) > + > +(define (make-elm-package-sexp name version) > + "Return two values: the `package' s-expression for the Elm package wit= h the > +given NAME and VERSION, and a list of Elm packages it depends on." > + (define-values (checkout _commit _relation) > + ;; Elm requires that packages use this very specific format > + (update-cached-checkout (string-append "https://github.com/" name) > + #:ref `(tag . ,version))) > + (define info > + (call-with-input-file (string-append checkout "/elm.json") > + json->scm)) > + (define (get-deps key) > + (cond > + ((assoc-ref info key) > + =3D> (cut map car <>)) > + (else > + '()))) The way the importer fiddles with alists isn=E2=80=99t pretty IMO. :-) How about using =E2=80=98define-json-mapping=E2=80=99 (also from Guile-JSON= ) to =E2=80=9Cmap=E2=80=9D JSON data structures to records? See how pypi.scm and others do it. The resulting code should be clearer. Also, instead of or in addition to memoizing =E2=80=98elm-package-registry= =E2=80=99, would it make sense to use =E2=80=98http-fetch/cached=E2=80=99 to fetch tha= t file? Nitpick: Guile has multiple-value truncation, so you can write: (define checkout (update-cached-checkout =E2=80=A6)) I haven=E2=80=99t looked into much detail at the build system, but I=E2=80= =99m sure you know what you=E2=80=99re doing. :-) Ludo=E2=80=99.