[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#68941] [PATCH v2 01/44] guix: build-system: node: Add trivial-node-
From: |
Nicolas Graves |
Subject: |
[bug#68941] [PATCH v2 01/44] guix: build-system: node: Add trivial-node-package helper. |
Date: |
Thu, 8 Feb 2024 01:24:24 +0100 |
* 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 <charles.b.jackson@protonmail.com>
;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;; Copyright © 2021 Dhruvin Gandhi <contact@dhruvin.dev>
-;;; Copyright © 2022 Nicolas Graves <ngraves@ngraves.fr>
+;;; Copyright © 2022, 2023, 2024 Nicolas Graves <ngraves@ngraves.fr>
;;; Copyright © 2023 Jelle Licht <jlicht@fsfe.org>
;;;
;;; 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.
--
2.41.0
- [bug#68941] [PATCH 33/44] gnu: Add node-is-bigint., (continued)
- [bug#68941] [PATCH 33/44] gnu: Add node-is-bigint., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 34/44] gnu: Add node-is-boolean-object., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 37/44] gnu: Add node-which-boxed-primitive., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 38/44] gnu: Add node-which-collection., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 40/44] gnu: Add node-is-date-object., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 42/44] gnu: Add node-object-keys., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 43/44] gnu: Add node-regexp-prototype-flags., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 01/44] guix: build-system: node: Add node-trivial-package helper., Liliana Marie Prikler, 2024/02/06
[bug#68941] [PATCH v2 01/44] guix: build-system: node: Add trivial-node-package helper.,
Nicolas Graves <=
- [bug#68941] [PATCH v2 03/44] gnu: Add node-function-bind., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 02/44] guix: build-system: node: Add node-is-type-object helper., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 04/44] gnu: Add node-has-proto., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 05/44] gnu: Add node-has., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 06/44] gnu: Add node-has-symbols., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 07/44] gnu: Add node-has-tostringtag., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 08/44] gnu: Add node-is-callable., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 09/44] gnu: Add node-get-intrinsic., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 19/44] gnu: Add node-is-weakmap., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 10/44] gnu: Add node-is-symbol., Nicolas Graves, 2024/02/07