From patchwork Mon Feb 5 23:18:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 59838 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 0208427BBEE; Mon, 5 Feb 2024 23:22: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 10FA427BBEA for ; Mon, 5 Feb 2024 23:22:53 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rX8Gh-0006Gp-SN; Mon, 05 Feb 2024 18:20: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 1rX8Gg-0006GM-Bm for guix-patches@gnu.org; Mon, 05 Feb 2024 18:20:50 -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 1rX8Gg-0001p3-3Y for guix-patches@gnu.org; Mon, 05 Feb 2024 18:20:50 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rX8Gs-0003wr-S9 for guix-patches@gnu.org; Mon, 05 Feb 2024 18:21:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68941] [PATCH 01/44] guix: build-system: node: Add node-trivial-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: Mon, 05 Feb 2024 23:21: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.170717521814614 (code B ref 68941); Mon, 05 Feb 2024 23:21:02 +0000 Received: (at 68941) by debbugs.gnu.org; 5 Feb 2024 23:20:18 +0000 Received: from localhost ([127.0.0.1]:52613 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rX8G9-0003nd-Lz for submit@debbugs.gnu.org; Mon, 05 Feb 2024 18:20:18 -0500 Received: from 7.mo560.mail-out.ovh.net ([188.165.48.182]:40729) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rX8G4-0003n1-KB for 68941@debbugs.gnu.org; Mon, 05 Feb 2024 18:20:14 -0500 Received: from director7.ghost.mail-out.ovh.net (unknown [10.109.148.110]) by mo560.mail-out.ovh.net (Postfix) with ESMTP id 23C5F2532F for <68941@debbugs.gnu.org>; Mon, 5 Feb 2024 23:19:57 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-4tws9 (unknown [10.110.178.134]) by director7.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 6FB3C1FD23; Mon, 5 Feb 2024 23:19:57 +0000 (UTC) Received: from ngraves.fr ([37.59.142.108]) by ghost-submission-6684bf9d7b-4tws9 with ESMTPSA id A3CzFR1twWX4TQIAkrM3og (envelope-from ); Mon, 05 Feb 2024 23:19:57 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-108S002626b4952-1d4a-41f6-aff4-55ad0f47e314, 9F372080060396D88D3FD19D164346DC319AC2A4) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 87.88.184.255 Date: Tue, 6 Feb 2024 00:18:49 +0100 Message-ID: <20240205231952.26410-1-ngraves@ngraves.fr> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Ovh-Tracer-Id: 7862440527001936610 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrfedvvddgtdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffogggtgfesthekredtredtjeenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeekgfetleeukeelfeffueeijeeikeevffeuveeuffeigfeiteeijeehffegfeelhfenucffohhmrghinhepmhhoiihilhhlrgdrohhrghenucfkphepuddvjedrtddrtddruddpkeejrdekkedrudekgedrvdehhedpfeejrdehledrudegvddruddtkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqpdhnsggprhgtphhtthhopedupdhrtghpthhtohepieekleegudesuggvsggsuhhgshdrghhnuhdrohhrghdpoffvtefjohhsthepmhhoheeitddpmhhouggvpehsmhhtphhouhht 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 (node-trivial-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..8a903b4fe5 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 + + node-trivial-package)) + +(define* (node-trivial-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.