Subject: Re: [bug#36599] [PATCH] gnu: Add node-semver.

From: Julien Lepiller <[email-masked]>
Date: Mon, 02 Sep 2019 16:50:28 +0200

Le 2 septembre 2019 14:49:08 GMT+02:00, "Ludovic Courtès" <[email-masked]> a écrit :
>Hi Giacomo,
>
>This patch seems to have been forgotten…
>
>Giacomo Leidi <[email-masked]> 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.