[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#51838] [PATCH 11/11] gnu: Add node-sqlite3.
From: |
Philip McGrath |
Subject: |
[bug#51838] [PATCH 11/11] gnu: Add node-sqlite3. |
Date: |
Sun, 14 Nov 2021 08:04:09 -0500 |
* gnu/packages/node-xyz.scm (node-sqlite3): New variable.
---
gnu/packages/node-xyz.scm | 114 ++++++++++++++++++++++++++++++++++++++
1 file changed, 114 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 8aa93122df..d30b6f6e04 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -22,6 +22,8 @@
(define-module (gnu packages node-xyz)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (gnu packages sqlite)
+ #:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
#:use-module (guix build-system node))
@@ -636,3 +638,115 @@ (define-public node-addon-api
@code{libuv} (included in a project via @code{#include <uv.h>}) are not
ABI-stable across Node.js major versions.")
(license license:expat)))
+
+(define-public node-sqlite3
+ (package
+ (name "node-sqlite3")
+ (version "5.0.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/mapbox/node-sqlite3")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0sbbzzli282nxyfha10zx0k5m8hdp0sf3ipl59khjb7wm449j86h"))
+ (snippet
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+ ;; unbundle sqlite
+ '(for-each delete-file-recursively
+ (find-files "deps" gzip-file?)))))))
+ (inputs
+ `(("node-addon-api" ,node-addon-api)
+ ("sqlite" ,sqlite)))
+ (build-system node-build-system)
+ (arguments
+ `(#:tests?
+ #f ; FIXME: tests depend on node-mocha
+ #:modules
+ ((guix build node-build-system)
+ (guix build json)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:phases
+ (modify-phases %standard-phases
+ (add-before 'configure 'npm-config-sqlite
+ (lambda* (#:key inputs #:allow-other-keys)
+ (setenv "npm_config_sqlite" (assoc-ref inputs "sqlite"))))
+ (add-after 'unpack 'un-cloud-ify
+ ;; Normally, this is "built" using @mapbox/node-pre-gyp,
+ ;; which publishes or downloads pre-built binaries
+ ;; or falls back to building from source.
+ ;; Here, we patch out all of that and just build directly.
+ ;; It would be better to patch a version of @mapbox/node-pre-gyp
+ ;; that always builds from source, but there are a number
+ ;; of dependencies that need to be packaged or removed.
+ (lambda args
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (let ((js (read-json in)))
+ (match (assoc-ref js "binary")
+ (('@ . alist)
+ (setenv "GYP_DEFINES"
+ (string-append
+ "module_name="
+ (assoc-ref alist "module_name")
+ " "
+ "module_path="
+ (assoc-ref alist "module_path")))))
+ (write-json
+ (fold (match-lambda*
+ (((key update) js)
+ (assoc-set! js
+ key
+ (match (assoc-ref js key)
+ (('@ . alist)
+ (cons '@ (update alist)))
+ (other
+ (update other))))))
+ js
+ `(("dependencies"
+ ,(lambda (deps)
+ (assoc-remove!
+ (assoc-remove! deps "@mapbox/node-pre-gyp")
+ "node-pre-gyp")))
+ ("devDependencies"
+ ,(lambda (deps)
+ (assoc-remove!
+ (assoc-remove! deps "aws-sdk")
+ "@mapbox/cloudfriend")))
+ ("scripts"
+ ,(lambda (scripts)
+ ;; install script would use node-pre-gyp
+ (assoc-remove! scripts "install")))))
+ out))))))
+ (add-after 'un-cloud-ify 'remove-missing-dev-deps
+ ;; Remove some missing testing/linting dependencies
+ ;; so we don't have to skip the configure phase entirely.
+ (lambda args
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (write-json
+ (let ((js (read-json in)))
+ (assoc-set!
+ (assoc-remove!
+ (assoc-remove! (assoc-remove! js "peerDependencies")
+ "peerDependenciesMeta")
+ "optionalDependencies")
+ "devDependencies"
+ (match (assoc-ref js "devDependencies")
+ (('@ . deps)
+ (cons '@ (assoc-remove! (assoc-remove! deps "eslint")
+ "mocha"))))))
+ out))))))))
+ (home-page "https://github.com/mapbox/node-sqlite3")
+ (synopsis "Asynchronous, non-blocking SQLite3 bindings for Node.js")
+ (description
+ "The Node.js add-on @code{node-sqlite3} provides a set of a asynchronous,
+non-blocking bindings for SQLite3, written in modern C++ and tested for memory
+leaks.")
+ (license license:bsd-3)))
--
2.32.0
- [bug#51838] [PATCH v2 23/26] gnu: Add node-nan., (continued)
- [bug#51838] [PATCH 05/11] gnu: Add node-safe-buffer., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 07/11] gnu: Add node-readable-stream., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 04/11] gnu: Add node-inherits., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 09/11] gnu: Add node-openzwave-shared., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 06/11] gnu: Add node-string-decoder., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 08/11] gnu: Add node-nan., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 10/11] gnu: Add node-addon-api., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 11/11] gnu: Add node-sqlite3.,
Philip McGrath <=
[bug#51838] [PATCH 00/11] guix: node-build-system: Support compiling add-ons with node-gyp., Timothy Sample, 2021/11/20
[bug#51838] [PATCH 00/11] guix: node-build-system: Support compiling add-ons with node-gyp., Timothy Sample, 2021/11/20
[bug#51838] [PATCH 00/11] guix: node-build-system: Support compiling add-ons with node-gyp., Timothy Sample, 2021/11/20
[bug#51838] [PATCH v2 04/26] gnu: node: Add an npmrc file to set nodedir., Timothy Sample, 2021/11/20