From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 08 15:29:52 2021 Received: (at 51838) by debbugs.gnu.org; 8 Dec 2021 20:29:53 +0000 Received: from localhost ([127.0.0.1]:41633 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mv3ZY-0005wI-By for submit@debbugs.gnu.org; Wed, 08 Dec 2021 15:29:52 -0500 Received: from mail-vk1-f173.google.com ([209.85.221.173]:47003) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mv3Yy-0005rE-NG for 51838@debbugs.gnu.org; Wed, 08 Dec 2021 15:29:18 -0500 Received: by mail-vk1-f173.google.com with SMTP id m16so2302168vkl.13 for <51838@debbugs.gnu.org>; Wed, 08 Dec 2021 12:29:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HwHKjvqPi/qexahkWysEoNyVq/q9nvVYXJGGLFS5Zi8=; b=IGMAdZaqWuFoKQ3yzWDf4aWZ34FozJPDexdATGRs7/DlnN+na/UuyhSJBqtI/AmPNn w+B3qCaDVd+hHryv6S6NGl9M41yMN/nVK5MRaITRUYcs5OdznMGVDXb2h4GSFZPHXZh2 8rKW9Gu2E/Se+Q6eOSpW3N1qOhufl4QKOUNu3bvLMiszWB6UiDowqiJta6EcHbTPmMpA d0c9JM1y4UJ5JMsGiJJKFjgIr1dlTNieT364jFdYAVzzjhzBw38ybJg2+O2Y4Fcotz7z eaAckV0MfSwKqMbx4lx8YBpWvsBCucNTtIsmHUft4dFnXNmuwObXGZ6vZLyanHyYfGz/ n7PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HwHKjvqPi/qexahkWysEoNyVq/q9nvVYXJGGLFS5Zi8=; b=xH3yLTYHORPLIRPJmlqgZDmvmjrb26VOar2fpdi7OcJSHKcoIljyvUlQOM3x972aGq h7YL+wUDccv1i7VKMmDwbE4SNT7iddIE43j+ann2sWjkzVr8n77mOi+qCyC8wWCesKUK PFxPDw6vI/ksLf3zW/GvckCKRJ8Uc+9mKKXBFwS6zVL8AWlLQfLg7Yv8ja24ONXY8NVZ FY19E2ZuEyjRWbFzCQY5/lMAA0UvFd7o8qC0piKnvkI0Cx2QypP+mYDlG2RVmHd+PIWy JFmmEKoxURXpjWS9mVLifjGfUfB0s+gg7FJf2dIN4NYOazt4rxVjvS0e2He4aanHPABx 0Jug== X-Gm-Message-State: AOAM532DTlHbqyOsEhW7XIVRx9MEqE/qC/FubjBkb6OzfUrhXXudRP25 wuGSBoHRHGrJEAFokE6J6BKqeuh8EVtnh407hzE= X-Google-Smtp-Source: ABdhPJyTBgMlfBJVc8JfnlmzbyPzmyBvY/Fo/iz6l38744e+u6osDzEnnC/6kUvdktf/fzEhLfWglg== X-Received: by 2002:a05:6122:1812:: with SMTP id ay18mr1295277vkb.18.1638995351055; Wed, 08 Dec 2021 12:29:11 -0800 (PST) Received: from localhost (c-73-125-89-242.hsd1.fl.comcast.net. [73.125.89.242]) by smtp.gmail.com with ESMTPSA id w22sm2636177vsk.11.2021.12.08.12.29.10 for <51838@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Dec 2021 12:29:10 -0800 (PST) From: Philip McGrath To: 51838@debbugs.gnu.org Subject: [PATCH v3 29/43] gnu: Add node-sqlite3. Date: Wed, 8 Dec 2021 15:28:24 -0500 Message-Id: <20211208202838.752542-30-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211208202838.752542-1-philip@philipmcgrath.com> References: <46a042bc08eb72a068b1e8c69bfe28cf2d4b2e53.camel@gmail.com> <20211208202838.752542-1-philip@philipmcgrath.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 51838 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) * gnu/packages/node-xyz.scm (node-sqlite3): New variable. --- gnu/packages/node-xyz.scm | 118 +++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 3 deletions(-) diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm index 60dbfc163c..b979d0cd53 100644 --- a/gnu/packages/node-xyz.scm +++ b/gnu/packages/node-xyz.scm @@ -615,7 +615,8 @@ (define-public node-addon-api (sha256 (base32 "1bhvfi2m9nxfz418s619914vmidcnrzbjv6l9nid476c3zlpazch")))) (inputs - `(("python" ,python))) + `(("python" ,python) + ("node-safe-buffer" ,node-safe-buffer))) (build-system node-build-system) (arguments `(#:absent-dependencies @@ -630,8 +631,7 @@ (define-public node-addon-api "eslint-plugin-promise" "fs-extra" "path" - "pre-commit" - "safe-buffer") + "pre-commit") #:phases (modify-phases %standard-phases (add-after 'unpack 'skip-js-tests @@ -660,3 +660,115 @@ (define-public node-addon-api @code{libuv} (included in a project via @code{#include }) 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" + (lambda (pth stat) + (gzip-file? pth))))))))) + (inputs + `(("node-addon-api" ,node-addon-api) + ("python" ,python) + ("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)) + #:absent-dependencies + `(;; 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, as Debian does, + ;; but there are a number of dependencies that need + ;; to be packaged or removed. + "@mapbox/node-pre-gyp" + "node-pre-gyp" ;; deprecated name still used in some places + "aws-sdk" + "@mapbox/cloudfriend" + ;; Confusingly, this is only a dependency beceuse of + ;; @mapbox/node-pre-gyp: with that removed, + ;; npm will use its own copy: + "node-gyp" + ;; These we'd like, we just don't have them yet: + "eslint" + "mocha") + #:phases + (modify-phases %standard-phases + (add-before 'configure 'npm-config-sqlite + ;; We need this step even if we do replace @mapbox/node-pre-gyp + ;; because the package expects to build its bundled sqlite + (lambda* (#:key inputs #:allow-other-keys) + (setenv "npm_config_sqlite" (assoc-ref inputs "sqlite")))) + (add-after 'install 'patch-binding-path + (lambda* (#:key outputs #:allow-other-keys) + (with-directory-excursion + (string-append (assoc-ref outputs "out") + "/lib/node_modules/sqlite3/lib") + (match (find-files "binding" "\\.node$") + ((rel-path) + (with-atomic-file-replacement "sqlite3-binding.js" + (lambda (in out) + (format out "var binding = require('./~a');\n" rel-path) + (display "module.exports = exports = binding;\n" out)))))))) + (add-after 'patch-dependencies 'avoid-node-pre-gyp + (lambda args + (substitute* ".npmignore" + (("lib/binding") + "#lib/binding # <- patched for Guix")) + (with-atomic-file-replacement "package.json" + (lambda (in out) + (let* ((js (read-json in)) + (alist (match js + (('@ . alist) alist))) + (scripts-alist (match (assoc-ref alist "scripts") + (('@ . alist) alist))) + (scripts-alist + ;; install script would use node-pre-gyp + (assoc-remove! scripts-alist "install")) + (alist + (assoc-set! alist "scripts" (cons '@ scripts-alist))) + (binary-alist (match (assoc-ref alist "binary") + (('@ . alist) alist))) + (js (cons '@ alist))) + ;; compensate for lack of @mapbox/node-pre-gyp + (setenv "GYP_DEFINES" + (string-append + "module_name=" + (assoc-ref binary-alist "module_name") + " " + "module_path=" + (assoc-ref binary-alist "module_path"))) + (write-json js + 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