From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id QP3mEqdjzWHfxgAAgWs5BA (envelope-from ) for ; Thu, 30 Dec 2021 08:45:43 +0100 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id sK93D6djzWEM8wAAauVa8A (envelope-from ) for ; Thu, 30 Dec 2021 08:45:43 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id E28411EBAA for ; Thu, 30 Dec 2021 08:45:42 +0100 (CET) Received: from localhost ([::1]:57868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2q85-0002PB-EI for larch@yhetil.org; Thu, 30 Dec 2021 02:45:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2q6Y-00018x-GD for guix-patches@gnu.org; Thu, 30 Dec 2021 02:44:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:39541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2q6Y-0001nu-6J for guix-patches@gnu.org; Thu, 30 Dec 2021 02:44:06 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n2q6Y-0006jL-5a for guix-patches@gnu.org; Thu, 30 Dec 2021 02:44:06 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v6 25/41] gnu: Add node-sqlite3. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 Dec 2021 07:44:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51838 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51838@debbugs.gnu.org Cc: Timothy Sample , Pierre Langlois , Jelle Licht , Philip McGrath , Liliana Marie Prikler Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.164085020425637 (code B ref 51838); Thu, 30 Dec 2021 07:44:06 +0000 Received: (at 51838) by debbugs.gnu.org; 30 Dec 2021 07:43:24 +0000 Received: from localhost ([127.0.0.1]:51051 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2q5r-0006fL-Ly for submit@debbugs.gnu.org; Thu, 30 Dec 2021 02:43:24 -0500 Received: from mail-qt1-f174.google.com ([209.85.160.174]:33779) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2q4z-0006bA-BO for 51838@debbugs.gnu.org; Thu, 30 Dec 2021 02:42:29 -0500 Received: by mail-qt1-f174.google.com with SMTP id v4so18422974qtk.0 for <51838@debbugs.gnu.org>; Wed, 29 Dec 2021 23:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HUhERuYOH/9ODG8YjkHcgjIME+Qo6SwEB6Qxm/gigfU=; b=afKG1rXSVKgiNpOFtE6KGBV97ocXtjQbsQquaUeMQ7cHHfqF6qkwwJoCRXy6QMAR76 YyHNb/a+7l6TIjI2BETh3SNBhCxn395pkj28BZKZBNJcHSU3HXPWWdwEzMgEYn4jg8Kl wH4LpKXwibVHDSr/Ebg85WGmIP4xbkUIa8e87oxnufiPUMnfjPDCGIftTju4Bpze2nlQ TIyCoDXuHLTb5ODCDRjfXlYWfDPrcDRksNQMnME8P8Bo6irLas3f+nJi+aURHlzT20rk SY8tMRe2n1/1OMxFtA/QohbZiGCd0fN8IAF+MunkN089KW1kwH3tcpE///08OJxbsWhv Z1VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HUhERuYOH/9ODG8YjkHcgjIME+Qo6SwEB6Qxm/gigfU=; b=BeTTShGbMuduzhIb5PxGVN2tiLS9UHItIjuo39LsPygcK0BCxjo//BG/9ifnBLnCAh NtDALKZJAAfUD7Z9vQAJDgYkBnfOQRjXpPdsB59XY8cZ7u1RUwkOoV3WAPcrXjjDqbaO G6yQEWB4Os9rQ0Q2kbs8JdUxhaNBTl+MW2oEFt0PXR426T5tHHLLt0D+F7jcUN/LP1nP HZqm0Y4KLrImB6MfQFDSyGdSzaLdWGnUkRB13P6NegmROon3XRnFNH9/MXyCq4QlKzvL /KRalGOicQxwCWHNThL2RsYiR77NG64MqzXR2BUxT6iAqmmpkHZUbgHkl15kfEeXUKra KZXA== X-Gm-Message-State: AOAM5319T+KysND/So7CodCB8rGeg7ZSevAWRFQ3Y1UYN7R80bEIQlkQ owAdONvaOQVFjd3OS3dy8QhqxO+z145oeWRW X-Google-Smtp-Source: ABdhPJx/l4mVpElmZYGkf3Jjp3VM6TBKqt5fFVIAjU/YSBsvVrroTAKToctn5E+OM7EdgahvxnG3Aw== X-Received: by 2002:a05:622a:11cc:: with SMTP id n12mr26900842qtk.17.1640850143737; Wed, 29 Dec 2021 23:42:23 -0800 (PST) Received: from localhost (c-73-125-89-242.hsd1.fl.comcast.net. [73.125.89.242]) by smtp.gmail.com with UTF8SMTPSA id j16sm20012447qtx.92.2021.12.29.23.42.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Dec 2021 23:42:23 -0800 (PST) From: Philip McGrath Date: Thu, 30 Dec 2021 02:39:03 -0500 Message-Id: <20211230073919.30327-26-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211230073919.30327-1-philip@philipmcgrath.com> References: <082a81964a43ae5f735ad2ca433d0dfe00859c35.camel@gmail.com> <20211230073919.30327-1-philip@philipmcgrath.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640850343; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=HUhERuYOH/9ODG8YjkHcgjIME+Qo6SwEB6Qxm/gigfU=; b=OGl+SRFyMPOgH/31X3522vaY/55WnWErxRvFD6VP9+ryL3HQSzwovJ7Yub0zhYxtwujdjv o9T6XQ58NALicYIUlAgtgaJwee9ctzvcej9swd0X1nef8YHErQIxE858dFAtgibT2J3A0y H4LFdHhTXome0NZniXFGhwF6xmrqWqprU2Bu5Ww5l8225pK56e2BuXexDUzjnIIk55WcUR Yytw/NpC7GDxJ2Hn21yw8Q4Tkvf//vUsp1N/e51eAQNGsx3YjsEDz2BkSmvqXwNzI/5Rdu w0IXsAxNAIHI8TZnUkZNti6fxspqfbH2PzarMLkN3tvQvAIaTiNyf0QAqSp+AQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640850343; a=rsa-sha256; cv=none; b=XJeSWDGEA+DQn8/t2zqwtXqL6r0WAfIpPwp2WlUiuwRE+b75qGdyflxUYhWGfWoYryLlOO AixozV8Yf0OGGniGuob47+mNyCWYvbduFp5oK00KDQ7g7QSdXFJusfSgd20L+8FYBEFy4B X+QMwxE9Jymj0A/JAB0Mhh0rbuFka9zWPyerkLABv4h9/uTgqZuU5f9t4JU9PF0q1hMQ7S WAuJS7nNRB0XlZkABW5YrJK5Q1ZQAjUKrx/0u3KeXUbnU9s4Hd03kzaJhy3dUZS++Db/66 uh1cmEqwA0puWmL6MWp0FZP4DzzILUq6CLGUaiAXYOWIkZ1wqhdO4iBB7DqkxQ== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=afKG1rXS; dmarc=none; spf=pass (aspmx2.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -0.07 Authentication-Results: aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=afKG1rXS; dmarc=none; spf=pass (aspmx2.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E28411EBAA X-Spam-Score: -0.07 X-Migadu-Scanner: scn0.migadu.com X-TUID: Gcxat1/f00go * gnu/packages/node-xyz.scm (node-sqlite3): New variable. --- gnu/packages/node-xyz.scm | 133 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm index 656642eb43..23ed209fd1 100644 --- a/gnu/packages/node-xyz.scm +++ b/gnu/packages/node-xyz.scm @@ -729,3 +729,136 @@ (define new-test-script @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 + (list node-addon-api python sqlite)) + (build-system node-build-system) + (arguments + `(#:modules + ((guix build node-build-system) + (srfi srfi-1) + (ice-9 match) + (guix build utils)) + #:tests? #f ; FIXME: tests depend on node-mocha + #:phases + (modify-phases %standard-phases + (add-after 'patch-dependencies 'delete-dependencies + (lambda args + (with-atomic-json-file-replacement "package.json" + (lambda (pkg-meta) + (delete-dependencies + pkg-meta + `(;; 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 might 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 because 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")))))) + (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 + ;; We replace a file that dynamic searches for the addon using + ;; node-pre-gyp (which we don't have) with a version that + ;; simply uses the path to the addon we built directly. + ;; The exact path is supposed to depend on things like the + ;; architecture and napi_build_version, so, to avoid having + ;; hard-code the details accurately, we do this after the addon + ;; has been built so we can just find where it ended up. + (lambda* (#:key outputs #:allow-other-keys) + (with-directory-excursion + (search-input-directory outputs + "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 + ;; We need to patch .npmignore before the 'repack phase + ;; so that the built addon is installed with in the package. + ;; (Upstream assumes node-pre-gyp will download a pre-built + ;; version when this package is installed.) + (substitute* ".npmignore" + (("lib/binding") + "#lib/binding # <- patched for Guix")) + (with-atomic-json-file-replacement "package.json" + (match-lambda + (('@ . pkg-meta-alist) + (match (assoc-ref pkg-meta-alist "binary") + (('@ . binary-alist) + ;; When it builds from source, node-pre-gyp supplies + ;; module_name and module_path based on the entries under + ;; "binary" from "package.json", so this package's + ;; "binding.gyp" doesn't define them. Thus, we also need + ;; to supply them. The GYP_DEFINES environment variable + ;; turns out to be the easiest way to make sure they are + ;; propagated from npm to node-gyp to gyp. + (setenv "GYP_DEFINES" + (string-append + "module_name=" + (assoc-ref binary-alist "module_name") + " " + "module_path=" + (assoc-ref binary-alist "module_path"))))) + ;; We need to remove the install script from "package.json", + ;; as it would try to use node-pre-gyp and would block the + ;; automatic building performed by `npm install`. + (cons '@ (map (match-lambda + (("scripts" @ . scripts-alist) + `("scripts" @ ,@(filter (match-lambda + (("install" . _) + #f) + (_ + #t)) + scripts-alist))) + (other + other)) + pkg-meta-alist)))))))))) + (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