From patchwork Wed May 18 18:10:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Philip McGrath X-Patchwork-Id: 777 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2780027BBEA; Wed, 18 May 2022 19:13:39 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6D96E27BBE9 for ; Wed, 18 May 2022 19:13:38 +0100 (BST) Received: from localhost ([::1]:36024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrOAz-0007iN-IJ for patchwork@mira.cbaines.net; Wed, 18 May 2022 14:13:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrOAQ-0007i6-HD for guix-patches@gnu.org; Wed, 18 May 2022 14:13:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nrOAQ-0005D8-7c for guix-patches@gnu.org; Wed, 18 May 2022 14:13:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nrOAQ-0006L5-2g for guix-patches@gnu.org; Wed, 18 May 2022 14:13:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55030] [PATCH v2 00/34] gnu: elm: Update to 0.19.1. Add build system & importer. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 18 May 2022 18:13: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: 55030@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Philip McGrath Received: via spool by 55030-submit@debbugs.gnu.org id=B55030.165289752324102 (code B ref 55030); Wed, 18 May 2022 18:13:01 +0000 Received: (at 55030) by debbugs.gnu.org; 18 May 2022 18:12:03 +0000 Received: from localhost ([127.0.0.1]:33466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nrO9S-0006Ga-CY for submit@debbugs.gnu.org; Wed, 18 May 2022 14:12:03 -0400 Received: from mail-ua1-f43.google.com ([209.85.222.43]:44729) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nrO9Q-0006G2-Db for 55030@debbugs.gnu.org; Wed, 18 May 2022 14:12:01 -0400 Received: by mail-ua1-f43.google.com with SMTP id f13so1126741uax.11 for <55030@debbugs.gnu.org>; Wed, 18 May 2022 11:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VZ5KiVXTpQ91/A3OpXqSqY0BKZJz7GNFRsVHBT4anMA=; b=bkRrqfZu/Et+NfqkMBaRHe5azPmsA9ZQzXInGe8xbKZvNl7F7KpcVgc0sr0M+7V6OQ 0/we6YlPeM6qL/CxxswNvTTCKdJz0c6/PVQZ37rN7Q2qXNONpjNq85NRw/eDaZkNxPTA HuVm6Db6nrH6iAlngccwocE3TMliIgC5qs34sn/xhWYGclFA5VMbd6S6tHLyMxyNxaB0 hOEIxJNQQMUWeimNUdigtei8gUWqKo1rI7IfuSpbVUKrb1ThJ1WnHVqzQjGcu8xV+Wy2 t4MlRwDWuTQCe+jY45T5uYvq9AKfSvMzzVFS3PGXRVGqh4nYRalubDNwOY2fjuoIWCg/ OzeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VZ5KiVXTpQ91/A3OpXqSqY0BKZJz7GNFRsVHBT4anMA=; b=mRbMN5DcQDaVvpmRi0FHzJOc0FIm3ZJLF7bXp3pu4wQaKNbG+ISyVr4pYMSM8vmROc 8TNoOCXMSEtVp15BzKT0FgLA0vEr1JmamceQhVxOVHhfGRa/6xWjdB2/E/aVx090+nh5 ePab7fKd2WFmw0OwC081PZZM+WlHciWvaz9dfSquKKp5ouuy3ERBdUBGrq4dFRdVu/E0 uA8XOyQJqRR3v6jbbdl36TMqVQh8dCj/Xgb8h1aXJvLhERxH822IfZ9bIRf1PMaTlo9x 9AYX8f+ey0/CTZ72T1mirO/t64euvFVLURcO3T7WN8eSlkucIBWMGrOM8+gcLxp5a1Ty +ciA== X-Gm-Message-State: AOAM531eZdn2P4T6fUaF76Rpv8XFF164e0+Q11RQcU4ZGmo2PH+bo4vL 2NB3yzOZcGnhLl1vyLJhPBRGDbQRT4ujWOHW X-Google-Smtp-Source: ABdhPJwDGEHf+ODzmfGDtexnJtaJSw1eP2KLSzf8KjpKyrtflx6XAJ/GY8LwOEIsgkxJAs+lP2qEHA== X-Received: by 2002:ab0:72d5:0:b0:368:aad4:5ef8 with SMTP id g21-20020ab072d5000000b00368aad45ef8mr560858uap.27.1652897514356; Wed, 18 May 2022 11:11:54 -0700 (PDT) Received: from localhost (c-73-125-98-51.hsd1.fl.comcast.net. [73.125.98.51]) by smtp.gmail.com with UTF8SMTPSA id b3-20020a05610222e300b00335bc2b4042sm254885vsh.28.2022.05.18.11.11.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 11:11:54 -0700 (PDT) From: Philip McGrath Date: Wed, 18 May 2022 14:10:47 -0400 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220419232736.272970-1-philip@philipmcgrath.com> References: <20220419232736.272970-1-philip@philipmcgrath.com> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi, Here is v2! A few notes before the patches: On 5/1/22 18:17, Philip McGrath wrote: > Hi, > > On 5/1/22 16:37, Ludovic Courtès wrote: >> Philip McGrath skribis: >> >>> + (package >>> + (name "elm-virtual-dom") >> >> [...] >> >>> + (properties '((upstream-name . "elm/virtual-dom"))))) >> >> Could/should the importer infer the upstream name from the Guix name by >> default? >> >> That way, we’d only need to specify that property where the automatic >> Guix->upstream name mapping wouldn’t work. > > It could, but the heuristics seemed a bit brittle. To pick a few examples: > > 1. elm-virtual-dom -> "elm/virtual-dom" > 2. elm-explorations-markdown -> "elm-explorations/markdown" > 2. elm-terezka-intervals -> "terezka/intervals" > > We could add a special case for the "elm-explorations/*" namespace, but > at least one of the others would need an explicit property. I *think* > most of the packages in the "elm/*" namespace are single-element (e.g. > "elm/html"), so maybe we could require the property for e.g. > "elm/virtual-dom" and "elm/project-metadata-utils" ... > I think I've come up with an approach to inferring upstream names that handles most cases (everything in this series but "elm/virtual-dom" and "elm/project-metadata-utils") while also not adding so much magic that the behavior would be unpredictable. I've put the functions going in both directions in `(guix build-system elm)` rather than `(guix import elm)` (which seemed somewhat more common) because `elm-package-origin` needs `elm->package-name`, and it seemed better overall to define the Elm-to-Guix and Guix-to-Elm conversions in the same place. On 5/1/22 18:03, Philip McGrath wrote: > Hi, > > On 5/1/22 16:35, Ludovic Courtès wrote: >> Could you add an entry for the importer under “Invoking guix import”, >> and one for the build system under “Build Systems” in guix.texi? You >> can follow existing entries as a template. >> > > I will give it a try! I haven't written any Texinfo before. > I've added documentation there, and also a section on naming conventions in contributing.texi. I'm not sure all of my Texinfo is idiomatic (well, I didn't find equivalents for all of the Scribble cross-reference functions I'm used to), but it does build and work ok. >> It would be nice to have tests for the importer. One way to do that is >> like ‘tests/cpan.scm’, which spawns an HTTP server that mimics the real >> registry. >> > > I'll take a look at that. > I've added a number of tests. They seem to be producing more "PASS" lines than other tests, though. It seems like nested `test-group`s may be handled differently than I'm used to from RackUnit and (less so) Racket's `srfi/64` implementation, but I'm not sure what the idiomatic way to structure them would be, if this isn't it. >>> +;; COMMENTARY: >> >> Nitpick: You can make that literally “;;; Commentary:”. That’s what >> (ice-9 documentation) expects. >> >>> +;; CODE: >> >> Likewise: “;;; Code:”. >> > > Will do. > Ironically, I couldn't find any documentation for `(ice-9 documentation)` other than the comments in the source file, but I hope I've done this properly now. >> >> The way the importer fiddles with alists isn’t pretty IMO. :-) >> >> How about using ‘define-json-mapping’ (also from Guile-JSON) to “map” >> JSON data structures to records? See how pypi.scm and others do it. >> The resulting code should be clearer. >> > > I had tried that first, but there were some problems: IIRC, there might > have been an issue with potentially-absent fields defaulting to > *unspecified*, some alist manipulation was needed anyway for fields that > use JSON objects as key--value maps, and, with a view toward being able > to process `{"type":"application"}` files some day, there didn't seem to > be enough ability to adapt parsing based on the value for the key. I > found this code less confusing. But I can try again if it seems important! > Most of the problems I'd run into were because I'd gotten the wrong idea from the grammar of 'define-json-mapping`, and `define-json-mapping` didn't check its implicit requirements: I've reported the details and potential improvements at . The remaining, unescapable alist manipulation is for cases when JSON objects are used as key--value maps, rather than records with some finite set of potential keys. >> Also, instead of or in addition to memoizing ‘elm-package-registry’, >> would it make sense to use ‘http-fetch/cached’ to fetch that file? >> > > I'll take a look! > Using `http-fetch/cached` without duplicating `json-fetch` required a few additional patches: - [PATCH v2 06/34] http-client: Accept '#:headers' in 'http-fetched/cached'. - [PATCH v2 07/34] http-client: 'http-fetch/cached' converts strings to URIs. - [PATCH v2 08/34] import: json: Accept '#:http-fetch' in 'json-fetch'. They seemed small enough, and IIUC they don't affect any build-side code or trigger rebuilds, but OTOH the actuall JSON being fetched is quite small, so it wouldn't be a problem to drop them if there are any problems. One other difference is that `elm-virtual-dom` had an upstream release since the first version of this patch series, so that package is now at 1.0.3. -Philip Philip McGrath (34): gnu: elm-compiler: Update to 0.19.1. gnu: elm: Rename package to match the command. guix: Add elm-build-system. gnu: Add elm-core and elm-json. build-system/elm: Add implicit Elm inputs. http-client: Accept '#:headers' in 'http-fetched/cached'. http-client: 'http-fetch/cached' converts strings to URIs. import: json: Accept '#:http-fetch' in 'json-fetch'. import: Add Elm importer. gnu: Add elm-virtual-dom. gnu: Add elm-html. gnu: Add elm-svg. gnu: Add elm-time. gnu: Add elm-url. gnu: Add elm-browser. gnu: Add elm-bytes. gnu: Add elm-file. gnu: Add elm-http. gnu: Add elm-parser. gnu: Add elm-project-metadata-utils. gnu: Add elm-explorations-markdown. gnu: elm: Support 'elm reactor'. gnu: Add elm-todomvc. gnu: Add elm-debois-elm-dom. gnu: Add elm-random. gnu: Add elm-explorations-test. gnu: Add elm-danhandrea-elm-date-format. gnu: Add elm-danhandrea-elm-time-extra. gnu: Add elm-justinmimbs-date. gnu: Add elm-justinmimbs-time-extra. gnu: Add elm-myrho-elm-round. gnu: Add elm-ryannhg-date-format. gnu: Add elm-terezka-intervals. gnu: Add elm-terezka-elm-charts. Makefile.am | 5 + doc/contributing.texi | 82 ++ doc/guix.texi | 80 ++ gnu/local.mk | 4 +- gnu/packages/elm.scm | 749 +++++++++++++++++- .../elm-compiler-disable-reactor.patch | 71 -- .../patches/elm-compiler-fix-map-key.patch | 38 - .../elm-offline-package-registry.patch | 71 ++ .../patches/elm-reactor-static-files.patch | 251 ++++++ guix/build-system/elm.scm | 206 +++++ guix/build/elm-build-system.scm | 380 +++++++++ guix/http-client.scm | 24 +- guix/import/elm.scm | 210 +++++ guix/import/json.scm | 9 +- guix/scripts/import.scm | 3 +- guix/scripts/import/elm.scm | 107 +++ tests/elm.scm | 268 +++++++ 17 files changed, 2414 insertions(+), 144 deletions(-) delete mode 100644 gnu/packages/patches/elm-compiler-disable-reactor.patch delete mode 100644 gnu/packages/patches/elm-compiler-fix-map-key.patch create mode 100644 gnu/packages/patches/elm-offline-package-registry.patch create mode 100644 gnu/packages/patches/elm-reactor-static-files.patch create mode 100644 guix/build-system/elm.scm create mode 100644 guix/build/elm-build-system.scm create mode 100644 guix/import/elm.scm create mode 100644 guix/scripts/import/elm.scm create mode 100644 tests/elm.scm base-commit: 665dd8211cb5c7556f0fb83944d33215accf957a