From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id SAteCMUMI2Qn+QAASxT56A (envelope-from ) for ; Tue, 28 Mar 2023 17:50:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id CF5LCMUMI2RzSgAA9RJhRA (envelope-from ) for ; Tue, 28 Mar 2023 17:50:29 +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 CD9F2733F for ; Tue, 28 Mar 2023 17:50:28 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1phBaG-0002Jn-7U; Tue, 28 Mar 2023 11:50:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phBaE-0002JW-JX for guix-patches@gnu.org; Tue, 28 Mar 2023 11:50:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1phBaE-0000gQ-BR for guix-patches@gnu.org; Tue, 28 Mar 2023 11:50:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1phBaD-0004yB-Ms for guix-patches@gnu.org; Tue, 28 Mar 2023 11:50:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62375] [PATCH] import: Add binary npm importer. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 28 Mar 2023 15:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62375 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: jlicht@fsfe.org Cc: Timothy Sample , Josselin Poiret , Tobias Geerinckx-Rice , Simon Tournier , Mathieu Othacehe , Christopher Baines , Lars-Dominik Braun , 62375@debbugs.gnu.org, Ricardo Wurmus Received: via spool by 62375-submit@debbugs.gnu.org id=B62375.168001858819076 (code B ref 62375); Tue, 28 Mar 2023 15:50:01 +0000 Received: (at 62375) by debbugs.gnu.org; 28 Mar 2023 15:49:48 +0000 Received: from localhost ([127.0.0.1]:50545 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1phBZz-0004xb-Fv for submit@debbugs.gnu.org; Tue, 28 Mar 2023 11:49:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1phBZv-0004xJ-DB for 62375@debbugs.gnu.org; Tue, 28 Mar 2023 11:49:46 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phBZo-0000YO-5k; Tue, 28 Mar 2023 11:49:36 -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=Y7DrnRzb/9ppGjPYdH6NEeWKbHZWIVoRlJrTBs/fx64=; b=PGZCHVKIfx490nGTK5MJ yJ7tnozcP8374GdjYaqdURLHjxU64jwOx6p/hFzfpejf4yZ8NbdTDJUNUZPtLzNKCl9jOw2hllNTW uHpB4kbjg5PlmQpBEiEQo4Nl32gxeXR4+3zZ99P5SlnUrCwv7IpypXd+SyVVs5WTOd3gPuszy4WHi 4H8t8ez2xcvHPc//SkEXlBpFZed1vjC9+vRcZ2g29GKG5ExUGuuzllbGZ/y849QX3NkhWz4arh50q bOQzHjMGGfsNvxmMgoRq0szFLtroGwRJJGZLqZZci+D/rghwJusDKC2zmPPtxZBur1g6joKujkv2/ +D8UWahn7S6vNA==; Received: from [193.50.110.81] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phBZn-0000zv-Nn; Tue, 28 Mar 2023 11:49:35 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Octidi 8 Germinal an 231 de la =?UTF-8?Q?R=C3=A9volution, ?= jour de la Jonquille X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Tue, 28 Mar 2023 17:49:32 +0200 In-Reply-To: (jlicht@fsfe.org's message of "Wed, 22 Mar 2023 12:27:16 +0100") Message-ID: <87tty4g9kj.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680018628; a=rsa-sha256; cv=none; b=tc4sAVObjw6lLLQRIjCM8ZKWH835lVU2PV3n7GVTRRiYk6Rvdpc/VvGu7op11EjyDg2zGu HpEapbdPgT8A7FUL3phOaylUDbF0ggIUi392aHI10zt//Fm62BvfZm6kKs8UmG5pC4GTYw ru9iVTeqNxZgtpo9bJDPHagnC3AsdsOfB3PMNXALcVXMM9ST/mltzNi3FOg811j1IT6W1+ 6vVQVa1Y9XpbaLhPZqBONpAdNY1LRfzPSfk1RBsLfKsE4Z5gNPtnTzBp39dvupNkgQ8Px1 MV6e4HdcOjeg0wvghO8UlUAfO8UUdpzol/W5nqNA7iZZrspgxKM4/aCPj1znfA== 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=PGZCHVKI; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680018628; 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=Y7DrnRzb/9ppGjPYdH6NEeWKbHZWIVoRlJrTBs/fx64=; b=TbjXYxvSkzSLOjrukvrNicCL2xp9juU5OBVe8FRobv4Z/w6aNhuzQABkrKijwxwdDLEhpM V2Y4QWYr0feNOXXlov0J0qMxL8eBoVHQBhAOgD2J0GOjsrTsa4u0x7eoFec+rP0guZ1ni6 7Olbo8TTwP5JZk927hGYYnLWbdaB0VP1LAW/D8mbqdoX74QIVt4b+UtK7wWWP3/pVZPbgS FmixvM1Y8c3qPVn47ZzqsPbf6TPGW2dZkzpTLypBqAG+XbpaNwS7v3JSejfqSrGPrNwxX/ TszAuc5z4xZOcKr6dFmH4wwmdJfdm2Pe/wdop8d9ByqnwY4oFlVs4Dm8pBvaXA== Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=PGZCHVKI; 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-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -1.13 X-Spam-Score: -1.13 X-Migadu-Queue-Id: CD9F2733F X-TUID: OepMQ3sDp8qt Hello Jelle! jlicht@fsfe.org skribis: > From: Jelle Licht > > * guix/scripts/import.scm: (importers): Add "npm-binary". > * guix/import/npm-binary.scm: New file. > * guix/scripts/import/npm-binary.scm: New file. > * Makefile.am: Add them. > > Co-authored-by: Timothy Sample > Co-authored-by: Lars-Dominik Braun Woohoo! I think it=E2=80=99ll be useful to many, even if we know it=E2=80= =99s far from =E2=80=9Cideal=E2=80=9D by our standards. We=E2=80=99ll need doc under =E2=80=9CInvoking guix import=E2=80=9D and tes= ts in =E2=80=98tests/npm-binary.scm=E2=80=99, similar to what=E2=80=99s done for = the other importers. The doc should clarify why it=E2=80=99s called that way and what the limita= tions are. For tests, I=E2=80=99d recommend mocking the npmjs.org HTTP servers using =E2=80=98with-http-server=E2=80=99 as in =E2=80=98tests/cpan.scm=E2=80=99. Also, please add docstrings to top-level procedures. > +;; TODO: Support other registries > +(define *registry* "https://registry.npmjs.org") > +(define *default-page* "https://www.npmjs.com/package") The convention currently is more like =E2=80=98%registry=E2=80=99. > +(define (http-error-code arglist) > + (match arglist > + (('http-error _ _ _ (code)) code) > + (_ #f))) Unused. :-) > +(define (hash-url url) > + "Downloads the resource at URL and computes the base32 hash for it." > + (call-with-temporary-output-file > + (lambda (temp port) > + (begin ((@ (guix import utils) url-fetch) url temp) > + (guix-hash-url temp))))) Maybe something more like: (port-sha256 (http-fetch =E2=80=A6)) ? > +(define (npm-package->package-sexp npm-package) > + "Return the `package' s-expression for an NPM-PACKAGE." > + (define (new-or-existing-inputs resolved-deps) > + (map package-revision->input resolved-deps)) > + > + (match npm-package > + (($ name version home-page dependencies dev-depen= dencies peer-dependencies license description dist) Please use =E2=80=98match-record=E2=80=99 instead and keep lines below 80 c= hars. :-) > + (let* ((name (npm-name->name name)) > + (url (dist-tarball dist)) > + (home-page (if (string? home-page) > + home-page > + (string-append *default-page* "/" (uri-encode= name)))) > + (synopsis description) > + (resolved-deps (map (match-lambda (($ na= me version) > + (resolve-package name (st= ring->semver-range version)))) (append dependencies peer-dependencies))) Likewise. That=E2=80=99s it! Could you send an updated patch? Thanks, Ludo=E2=80=99.