[bug#36599] gnu: Add node-semver.
diff mbox series

Message ID 20190711121221.16123-1-goodoldpaul@autistici.org
State New
Headers show
Series
  • [bug#36599] gnu: Add node-semver.
Related show

Commit Message

Giacomo Leidi July 11, 2019, 12:12 p.m. UTC
* gnu/packages/node.scm (node-semver): New variable.
---
 gnu/packages/node.scm | 48 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

Comments

Ludovic Courtès Sept. 2, 2019, 12:49 p.m. UTC | #1
Hi Giacomo,

This patch seems to have been forgotten…

Giacomo Leidi <goodoldpaul@autistici.org> skribis:

> * gnu/packages/node.scm (node-semver): New variable.

[...]

> +(define-public node-semver
> +  (package
> +    (name "node-semver")
> +    (version "6.2.0")
> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url "https://github.com/npm/node-semver.git")
> +                    (commit (string-append "v" version))))
> +              (file-name (git-file-name name version))
> +              (sha256
> +               (base32
> +                "0lqb0v7frrdr7yvxy8b2yg6rp1jilninzk76qnx5qnswxnr4gj5m"))))

The nice thing is that the source doesn’t contain any binaries (or
“minified” code),.

> +    (build-system trivial-build-system)
> +    (propagated-inputs
> +     `(("node" ,node)))
> +    (arguments
> +     '(#:modules ((guix build utils))
> +       #:builder
> +       (begin
> +         (use-modules (guix build utils))
> +         (let* ((source (assoc-ref %build-inputs "source"))
> +                (out (assoc-ref %outputs "out"))
> +                (semver-js "semver.js")
> +                (entry-point (string-append "bin/" semver-js)))
> +           (mkdir-p (string-append out "/bin"))
> +           (setenv "PATH" (string-append (assoc-ref %build-inputs
> +                                                    "node")
> +                                         "/bin:" (getenv "PATH")))
> +           (map (lambda (file)
> +                  (install-file (string-append source "/" file) out))
> +                (list semver-js "LICENSE" "package.json" "package-lock.json" "range.bnf"))
> +           (install-file (string-append source "/" entry-point)
> +                         (string-append out "/bin"))
> +           (patch-shebang (string-append out "/" entry-point))
> +           #t))))

This installs files in non-standard locations:

--8<---------------cut here---------------start------------->8---
$ find $(./pre-inst-env guix build node-semver)
/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0
/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/package-lock.json
/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/bin
/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/bin/semver.js
/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/package.json
/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/semver.js
/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/range.bnf
/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/LICENSE
--8<---------------cut here---------------end--------------->8---

bin/ is fine, though should the binary be called ‘semver’ instead of
‘semver.js’?

Could you arrange so that ‘LICENSE’ goes to ‘share/doc/node-semver’?

As for the other files, I don’t know.   Are they needed?  Should they go
to share/node-semver?

Thanks in advance, and apologies for the loooong delay!

Ludo’.
Julien Lepiller Sept. 2, 2019, 2:50 p.m. UTC | #2
Le 2 septembre 2019 14:49:08 GMT+02:00, "Ludovic Courtès" <ludo@gnu.org> a écrit :
>Hi Giacomo,
>
>This patch seems to have been forgotten…
>
>Giacomo Leidi <goodoldpaul@autistici.org> skribis:
>
>> * gnu/packages/node.scm (node-semver): New variable.
>
>[...]
>
>> +(define-public node-semver
>> +  (package
>> +    (name "node-semver")
>> +    (version "6.2.0")
>> +    (source (origin
>> +              (method git-fetch)
>> +              (uri (git-reference
>> +                    (url "https://github.com/npm/node-semver.git")
>> +                    (commit (string-append "v" version))))
>> +              (file-name (git-file-name name version))
>> +              (sha256
>> +               (base32
>> +               
>"0lqb0v7frrdr7yvxy8b2yg6rp1jilninzk76qnx5qnswxnr4gj5m"))))
>
>The nice thing is that the source doesn’t contain any binaries (or
>“minified” code),.
>
>> +    (build-system trivial-build-system)
>> +    (propagated-inputs
>> +     `(("node" ,node)))
>> +    (arguments
>> +     '(#:modules ((guix build utils))
>> +       #:builder
>> +       (begin
>> +         (use-modules (guix build utils))
>> +         (let* ((source (assoc-ref %build-inputs "source"))
>> +                (out (assoc-ref %outputs "out"))
>> +                (semver-js "semver.js")
>> +                (entry-point (string-append "bin/" semver-js)))
>> +           (mkdir-p (string-append out "/bin"))
>> +           (setenv "PATH" (string-append (assoc-ref %build-inputs
>> +                                                    "node")
>> +                                         "/bin:" (getenv "PATH")))
>> +           (map (lambda (file)
>> +                  (install-file (string-append source "/" file)
>out))
>> +                (list semver-js "LICENSE" "package.json"
>"package-lock.json" "range.bnf"))
>> +           (install-file (string-append source "/" entry-point)
>> +                         (string-append out "/bin"))
>> +           (patch-shebang (string-append out "/" entry-point))
>> +           #t))))
>
>This installs files in non-standard locations:
>
>--8<---------------cut here---------------start------------->8---
>$ find $(./pre-inst-env guix build node-semver)
>/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0
>/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/package-lock.json
>/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/bin
>/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/bin/semver.js
>/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/package.json
>/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/semver.js
>/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/range.bnf
>/gnu/store/dmclr4h1jwqp02j9bpp9xsr5pzacdmnl-node-semver-6.2.0/LICENSE
>--8<---------------cut here---------------end--------------->8---
>
>bin/ is fine, though should the binary be called ‘semver’ instead of
>‘semver.js’?
>
>Could you arrange so that ‘LICENSE’ goes to ‘share/doc/node-semver’?
>
>As for the other files, I don’t know.   Are they needed?  Should they
>go
>to share/node-semver?
>
>Thanks in advance, and apologies for the loooong delay!
>
>Ludo’.

Actually we have a node-build-system now which woull work much better than the trivial-build-system.

Patch
diff mbox series

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index fc43fcb04c..2f3fe17334 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -6,6 +6,7 @@ 
 ;;; Copyright © 2017 Mike Gerwitz <mtg@gnu.org>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
+;;; Copyright © 2019 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -23,10 +24,12 @@ 
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages node)
-  #:use-module ((guix licenses) #:select (expat))
+  #:use-module ((guix licenses) #:select (expat isc))
   #:use-module (guix packages)
   #:use-module (guix derivations)
   #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system trivial)
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages)
   #:use-module (gnu packages adns)
@@ -184,3 +187,46 @@  devices.")
     (home-page "https://nodejs.org/")
     (license expat)
     (properties '((timeout . 3600))))) ; 1 h
+
+(define-public node-semver
+  (package
+    (name "node-semver")
+    (version "6.2.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/npm/node-semver.git")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0lqb0v7frrdr7yvxy8b2yg6rp1jilninzk76qnx5qnswxnr4gj5m"))))
+    (build-system trivial-build-system)
+    (propagated-inputs
+     `(("node" ,node)))
+    (arguments
+     '(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (let* ((source (assoc-ref %build-inputs "source"))
+                (out (assoc-ref %outputs "out"))
+                (semver-js "semver.js")
+                (entry-point (string-append "bin/" semver-js)))
+           (mkdir-p (string-append out "/bin"))
+           (setenv "PATH" (string-append (assoc-ref %build-inputs
+                                                    "node")
+                                         "/bin:" (getenv "PATH")))
+           (map (lambda (file)
+                  (install-file (string-append source "/" file) out))
+                (list semver-js "LICENSE" "package.json" "package-lock.json" "range.bnf"))
+           (install-file (string-append source "/" entry-point)
+                         (string-append out "/bin"))
+           (patch-shebang (string-append out "/" entry-point))
+           #t))))
+    (home-page "https://github.com/npm/node-semver")
+    (synopsis "Parses semantic versions strings")
+    (description
+     "node-semver is a JavaScript implementation of the
+@uref{https://semver.org/, SemVer.org} specification.")
+    (license isc)))