From patchwork Thu Feb 8 00:24:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 59890 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 4A3A127BBF0; Thu, 8 Feb 2024 00:26:57 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham 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 AF57327BBEB for ; Thu, 8 Feb 2024 00:26:49 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXsEh-0000g4-3m; Wed, 07 Feb 2024 19:25:51 -0500 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 1rXsEf-0000dn-2P for guix-patches@gnu.org; Wed, 07 Feb 2024 19:25:49 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXsEe-0000lO-K4 for guix-patches@gnu.org; Wed, 07 Feb 2024 19:25:48 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rXsEs-00073L-JY for guix-patches@gnu.org; Wed, 07 Feb 2024 19:26:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68941] [PATCH v2 01/44] guix: build-system: node: Add trivial-node-package helper. References: <20240205231557.22629-1-ngraves@ngraves.fr> In-Reply-To: <20240205231557.22629-1-ngraves@ngraves.fr> Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 08 Feb 2024 00:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68941 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68941@debbugs.gnu.org Cc: ngraves@ngraves.fr Received: via spool by 68941-submit@debbugs.gnu.org id=B68941.170735195427022 (code B ref 68941); Thu, 08 Feb 2024 00:26:02 +0000 Received: (at 68941) by debbugs.gnu.org; 8 Feb 2024 00:25:54 +0000 Received: from localhost ([127.0.0.1]:58324 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXsEk-00071j-7t for submit@debbugs.gnu.org; Wed, 07 Feb 2024 19:25:54 -0500 Received: from 15.mo581.mail-out.ovh.net ([87.98.180.21]:45447) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXsEg-00071I-LE for 68941@debbugs.gnu.org; Wed, 07 Feb 2024 19:25:52 -0500 Received: from director10.ghost.mail-out.ovh.net (unknown [10.109.139.225]) by mo581.mail-out.ovh.net (Postfix) with ESMTP id 3F3C2270F6 for <68941@debbugs.gnu.org>; Thu, 8 Feb 2024 00:25:33 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-ltz77 (unknown [10.110.168.40]) by director10.ghost.mail-out.ovh.net (Postfix) with ESMTPS id EC56E1FE39; Thu, 8 Feb 2024 00:25:32 +0000 (UTC) Received: from ngraves.fr ([37.59.142.108]) by ghost-submission-6684bf9d7b-ltz77 with ESMTPSA id E13ONXwfxGUQbwIA49HlTA (envelope-from ); Thu, 08 Feb 2024 00:25:32 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-108S002d748d0eb-9003-4558-9de3-a75e8afdb57d, 1F816C6F1D534EC93874C2C90F666022E64E63F2) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 81.67.146.208 Date: Thu, 8 Feb 2024 01:24:24 +0100 Message-ID: <20240208002527.27165-1-ngraves@ngraves.fr> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Ovh-Tracer-Id: 2268969788741706466 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrtdefgddvvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvvefufffkofggtgfgsehtkeertdertdejnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepkefgteelueekleefffeuieejieekveffueevueffiefgieetieejheffgeeflefhnecuffhomhgrihhnpehmohiiihhllhgrrdhorhhgnecukfhppeduvdejrddtrddtrddupdekuddrieejrddugeeirddvtdekpdefjedrheelrddugedvrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqedpnhgspghrtghpthhtohepuddprhgtphhtthhopeeikeelgeduseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehkedupdhmohguvgepshhmthhpohhuth 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: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/build-system/node.scm (trivial-node-package): Add function. Change-Id: I618750ebb3a9f9c4ec4f22256541cfbdfbf4388a --- gnu/packages/node-xyz.scm | 2 +- guix/build-system/node.scm | 52 +++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm index d68f730b77..36fa575049 100644 --- a/gnu/packages/node-xyz.scm +++ b/gnu/packages/node-xyz.scm @@ -5,7 +5,7 @@ ;;; Copyright © 2021 Charles ;;; Copyright © 2021 Philip McGrath ;;; Copyright © 2021 Dhruvin Gandhi -;;; Copyright © 2022 Nicolas Graves +;;; Copyright © 2022, 2023, 2024 Nicolas Graves ;;; Copyright © 2023 Jelle Licht ;;; ;;; This file is part of GNU Guix. diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm index 3f73390809..a16627e68c 100644 --- a/guix/build-system/node.scm +++ b/guix/build-system/node.scm @@ -29,9 +29,59 @@ (define-module (guix build-system node) #:use-module (guix search-paths) #:use-module (guix build-system) #:use-module (guix build-system gnu) + #:use-module (guix build-system trivial) + #:use-module ((guix licenses) #:prefix license:) #:export (%node-build-system-modules node-build - node-build-system)) + node-build-system + + trivial-node-package)) + +(define* (trivial-node-package node-name version replacement description + #:key (propagated-inputs '()) + (mozilla-doclink #f) ;maybe-string + (shams #f)) + "This helper makes it easy to replace a cumbersome npm package by the +underlying javascript code. This is also useful to cut down the Node +dependency tree for some cumbersome polyfills that all current web browsers +already support." + (package + (name (string-append "node-" + (string-join (string-split node-name #\.) "-"))) + (version (format #f "~a" version)) + (source #f) + (build-system trivial-build-system) + (arguments + (list + #:builder + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (let ((dir (string-append #$output "/lib/node_modules/" #$node-name))) + (mkdir-p dir) + (with-output-to-file (string-append dir "/index.js") + (lambda _ + (format #t "module.exports = ~a\n" #$replacement))) + (when #$shams + (copy-file (string-append dir "/index.js") + (string-append dir "/shams.js"))) + (with-output-to-file (string-append dir "/package.json") + (lambda _ + (format #t "{\"name\":~s~a}\n" #$node-name + (if #$shams + "\ +,\"exports\":{\".\":\"./index.js\",\"./shams\":\"./shams.js\"}" + ""))))))))) + (propagated-inputs propagated-inputs) + (home-page + (if mozilla-doclink + (string-append + "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/" + mozilla-doclink "#browser_compatibility") + "")) + (synopsis (string-append "Replacement for npm package " name)) + (description description) + (license license:gpl3+))) (define %node-build-system-modules ;; Build-side modules imported by default.