123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- (define-module (guix build-system node)
- #:use-module (guix store)
- #:use-module (guix build json)
- #:use-module (guix build union)
- #:use-module (guix utils)
- #:use-module (guix packages)
- #:use-module (guix derivations)
- #:use-module (guix search-paths)
- #:use-module (guix build-system)
- #:use-module (guix build-system gnu)
- #:use-module (ice-9 match)
- #:export (npm-meta-uri
- %node-build-system-modules
- node-build
- node-build-system))
- (define (npm-meta-uri name)
- "Return a URI string for the metadata of node module NAME found in the npm
- registry."
- (string-append "https://registry.npmjs.org/" name))
- (define %node-build-system-modules
-
- `((guix build node-build-system)
- (guix build json)
- (guix build union)
- ,@%gnu-build-system-modules))
- (define (default-node)
- "Return the default Node package."
-
- (let ((node (resolve-interface '(gnu packages node))))
- (module-ref node 'node)))
- (define* (lower name
- #:key source inputs native-inputs outputs system target
- (node (default-node))
- #:allow-other-keys
- #:rest arguments)
- "Return a bag for NAME."
- (define private-keywords
- '(#:source #:target #:node #:inputs #:native-inputs))
- (and (not target)
- (bag
- (name name)
- (system system)
- (host-inputs `(,@(if source
- `(("source" ,source))
- '())
- ,@inputs
-
- ,@(standard-packages)))
- (build-inputs `(("node" ,node)
- ,@native-inputs))
- (outputs outputs)
- (build node-build)
- (arguments (strip-keyword-arguments private-keywords arguments)))))
- (define* (node-build store name inputs
- #:key
- (npm-flags ''())
- (tests? #t)
- (phases '(@ (guix build node-build-system)
- %standard-phases))
- (outputs '("out"))
- (search-paths '())
- (system (%current-system))
- (guile #f)
- (imported-modules %node-build-system-modules)
- (modules '((guix build node-build-system)
- (guix build json)
- (guix build union)
- (guix build utils))))
- "Build SOURCE using NODE and INPUTS."
- (define builder
- `(begin
- (use-modules ,@modules)
- (node-build #:name ,name
- #:source ,(match (assoc-ref inputs "source")
- (((? derivation? source))
- (derivation->output-path source))
- ((source)
- source)
- (source
- source))
- #:system ,system
- #:npm-flags ,npm-flags
- #:tests? ,tests?
- #:phases ,phases
- #:outputs %outputs
- #:search-paths ',(map search-path-specification->sexp
- search-paths)
- #:inputs %build-inputs)))
- (define guile-for-build
- (match guile
- ((? package?)
- (package-derivation store guile system #:graft? #f))
- (#f
- (let* ((distro (resolve-interface '(gnu packages commencement)))
- (guile (module-ref distro 'guile-final)))
- (package-derivation store guile system #:graft? #f)))))
- (build-expression->derivation store name builder
- #:inputs inputs
- #:system system
- #:modules imported-modules
- #:outputs outputs
- #:guile-for-build guile-for-build))
- (define node-build-system
- (build-system
- (name 'node)
- (description "The standard Node build system")
- (lower lower)))
|