[bug#68941,01/44] guix: build-system: node: Add node-trivial-package helper.
Commit Message
* 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(-)
Comments
Am Dienstag, dem 06.02.2024 um 00:18 +0100 schrieb Nicolas Graves:
> * guix/build-system/node.scm (node-trivial-package): Add function.
>
> Change-Id: I618750ebb3a9f9c4ec4f22256541cfbdfbf4388a
> ---
I'd name that "trivial-node-package" instead.
Cheers
On 2024-02-06 20:30, Liliana Marie Prikler wrote:
> Am Dienstag, dem 06.02.2024 um 00:18 +0100 schrieb Nicolas Graves:
>> * guix/build-system/node.scm (node-trivial-package): Add function.
>>
>> Change-Id: I618750ebb3a9f9c4ec4f22256541cfbdfbf4388a
>> ---
> I'd name that "trivial-node-package" instead.
Thanks, I'll change this. WDYT otherwise? Is it a good solution?
Note that this is dependent on 66180 in debuggs ;)
>
> Cheers
Am Mittwoch, dem 07.02.2024 um 01:19 +0100 schrieb Nicolas Graves:
> On 2024-02-06 20:30, Liliana Marie Prikler wrote:
>
> > Am Dienstag, dem 06.02.2024 um 00:18 +0100 schrieb Nicolas Graves:
> > > * guix/build-system/node.scm (node-trivial-package): Add
> > > function.
> > >
> > > Change-Id: I618750ebb3a9f9c4ec4f22256541cfbdfbf4388a
> > > ---
> > I'd name that "trivial-node-package" instead.
>
> Thanks, I'll change this. WDYT otherwise? Is it a good solution?
>
> Note that this is dependent on 66180 in debuggs ;)
I haven't looked at the entire series, but I agree with any efforts
that make the node ecosystem easier to manage. Packaging trivial JS in
this manner seems fair game to me.
Cheers
On 2024-02-07 06:11, Liliana Marie Prikler wrote:
> Am Mittwoch, dem 07.02.2024 um 01:19 +0100 schrieb Nicolas Graves:
>> On 2024-02-06 20:30, Liliana Marie Prikler wrote:
>>
>> > Am Dienstag, dem 06.02.2024 um 00:18 +0100 schrieb Nicolas Graves:
>> > > * guix/build-system/node.scm (node-trivial-package): Add
>> > > function.
>> > >
>> > > Change-Id: I618750ebb3a9f9c4ec4f22256541cfbdfbf4388a
>> > > ---
>> > I'd name that "trivial-node-package" instead.
>>
>> Thanks, I'll change this. WDYT otherwise? Is it a good solution?
>>
>> Note that this is dependent on 66180 in debuggs ;)
> I haven't looked at the entire series, but I agree with any efforts
> that make the node ecosystem easier to manage. Packaging trivial JS in
> this manner seems fair game to me.
Hi Liliana,
Nothing has happened here since, could you take a deeper look? My goal
in the end was to package a zotero extension for the browser, and I have
a lot of other patches I worked on, but they are in fact dependent on
this series.
Thanks!
Nicolas
>
> Cheers
>
>
>
Am Samstag, dem 01.06.2024 um 18:12 +0200 schrieb Nicolas Graves:
> On 2024-02-07 06:11, Liliana Marie Prikler wrote:
>
> > Am Mittwoch, dem 07.02.2024 um 01:19 +0100 schrieb Nicolas Graves:
> > > On 2024-02-06 20:30, Liliana Marie Prikler wrote:
> > >
> > > > Am Dienstag, dem 06.02.2024 um 00:18 +0100 schrieb Nicolas
> > > > Graves:
> > > > > * guix/build-system/node.scm (node-trivial-package): Add
> > > > > function.
> > > > >
> > > > > Change-Id: I618750ebb3a9f9c4ec4f22256541cfbdfbf4388a
> > > > > ---
> > > > I'd name that "trivial-node-package" instead.
> > >
> > > Thanks, I'll change this. WDYT otherwise? Is it a good solution?
> > >
> > > Note that this is dependent on 66180 in debuggs ;)
> > I haven't looked at the entire series, but I agree with any efforts
> > that make the node ecosystem easier to manage. Packaging trivial
> > JS in this manner seems fair game to me.
>
> Hi Liliana,
>
> Nothing has happened here since, could you take a deeper look? My
> goal in the end was to package a zotero extension for the browser,
> and I have a lot of other patches I worked on, but they are in fact
> dependent on this series.
Oh, sorry for inadvertently blocking this. I think since no one else
took their time to complain, you can push this. Small nitpick, though,
you should probably M-x untabify the new regions, because tabs and
spaces appear mixed.
Cheers
@@ -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.
@@ -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.