From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 YCKpGthR2WE/XgAAgWs5BA (envelope-from ) for ; Sat, 08 Jan 2022 09:56:56 +0100 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id SCP6F9hR2WGqggEA9RJhRA (envelope-from ) for ; Sat, 08 Jan 2022 09:56:56 +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 0BA98331C6 for ; Sat, 8 Jan 2022 09:56:52 +0100 (CET) Received: from localhost ([::1]:36142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n67Wt-0004gi-RL for larch@yhetil.org; Sat, 08 Jan 2022 03:56:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n67MT-0003o7-8i for guix-patches@gnu.org; Sat, 08 Jan 2022 03:46:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:53500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n67MT-0004cx-0f for guix-patches@gnu.org; Sat, 08 Jan 2022 03:46:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n67MS-0000va-Vl for guix-patches@gnu.org; Sat, 08 Jan 2022 03:46:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v9 25/41] gnu: Add node-sqlite3. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 08 Jan 2022 08:46:04 +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 , Philip McGrath , Pierre Langlois , Liliana Marie Prikler , Leo Famulari , Jelle Licht Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.16416315373380 (code B ref 51838); Sat, 08 Jan 2022 08:46:04 +0000 Received: (at 51838) by debbugs.gnu.org; 8 Jan 2022 08:45:37 +0000 Received: from localhost ([127.0.0.1]:46376 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n67M1-0000sM-02 for submit@debbugs.gnu.org; Sat, 08 Jan 2022 03:45:37 -0500 Received: from mail-qk1-f175.google.com ([209.85.222.175]:42796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n67Lx-0000rh-KI for 51838@debbugs.gnu.org; Sat, 08 Jan 2022 03:45:34 -0500 Received: by mail-qk1-f175.google.com with SMTP id r139so8484860qke.9 for <51838@debbugs.gnu.org>; Sat, 08 Jan 2022 00:45:33 -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=cG5PqsfnBe+H8QVwTVVAWsQovwu0SROgeiqV1NFnRHk=; b=jCmJ5jfa5VsCMnXIxZ+jg2vhL3YMLLFNuFImmm1X2TpUYEOZfO/BWSy+hJG3N/ux/G ttYZWrvVYsjIJSvLdsllKOsD2Zrmfj/Y6sIm9lu2oe9w1qAFbb0FUvv/6qX2P1eGHLsj oODRpl3K1eMr6CX3nv3h85ow2HDkyt5O54orX9t+4pJ2XUDFdqJusHkGJqYGNf7jjnV6 xNxy8WvwToY3jz8O5oOwPTcw243gpb21J++VS3xpqExsQ+kVrCjhImkDls/Ca1Xl36B3 M6x/merRWo+qFmm5Sh3cJIYFIH/m4pZg+AuCaol842RorNhou7qA7MUbL1OlAfg6NMJp Pp6g== 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=cG5PqsfnBe+H8QVwTVVAWsQovwu0SROgeiqV1NFnRHk=; b=dFmColvWM7LDSLIGvicwRCGBrMn0nNZfdAT7mYJFEh7RqMfO3MOJE8Gbaa1McpwNSv vPmuKQvhUQveYU+Xc+hFpEbuB4WZwu3gP1uBynKhGGvOLDEgONEu1//EXK9OTj5Nt8np e3ijmTwbDDoaDbGIqfFAVu1KmgN0FJT8fC+NL7TcVSSA2E6KFvI4Qngqnui533HtxkAU YFTWv46uZq0Ce5d/9dI0g/SS/8LYSd5LN5EnC83OY3u5U4tT0TAriLdc26vD1lNQcdNO z4BgVqzupykEpjoWem+WSxpoa+R/vn2lNc61DEpnmVEZx4Bw4LvJblbPNzzLVs+a1mpu uQUQ== X-Gm-Message-State: AOAM533yFFlMbvXf/4SdzkHYtUlWCiaA3xQD6UORsnxSxYpYhRGVPC2d fU8zH/CciJLudO2AeS4sUCwEKA0eL7JsD8IP X-Google-Smtp-Source: ABdhPJygFH34+ka/Jmf7MoxgAWwzDTArWgNlAotx7pxFC8Uwsxf1oxGL8mT3ILz68Pxcjvvapqfr8A== X-Received: by 2002:ae9:f810:: with SMTP id x16mr11032764qkh.346.1641631527934; Sat, 08 Jan 2022 00:45:27 -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 ay39sm701041qkb.63.2022.01.08.00.45.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 08 Jan 2022 00:45:27 -0800 (PST) From: Philip McGrath Date: Sat, 8 Jan 2022 03:42:13 -0500 Message-Id: <20220108084229.362642-26-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220108084229.362642-1-philip@philipmcgrath.com> References: <64e08d3a1838ed8507f33fae895545372960522f.camel@gmail.com> <7b04af28bbd57c67093ce8f33a648efec89693bd.camel@gmail.com> <441bfeb0-eb6e-81f6-488b-cdf1b09a78ef@philipmcgrath.com> <20220108084229.362642-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=1641632216; 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=cG5PqsfnBe+H8QVwTVVAWsQovwu0SROgeiqV1NFnRHk=; b=lNXCl6BT6LM4dd1W9JaDJ+uxAMzkDz1Gc0GvDKN1usMNBtH4HRLHqbCroyIDmFpnT88DDH V+eQ4Y7kYwIuLAzYSfF4nZ7UT0aCrXFQl6TPqaFLvFBnSw3YpWearwl+9RyiiGXK+H30Nf pn/PACtx7Y6acrjelg1hT2jdON1wtFuG/YgqLofTRJpxZLOV2U/noqeIV1KvA/xNyfKRpm Rk5V9HBHQCEGJCj7249CERVtg7owiMVi4FkAYEXOsaaWeZ2yZb/UMFbzbwz2h5LkLNB1ZT sM/N1oziYaTUD2shLZNgpPwu9ve1GGfgnzVL9eUep3sW88+tk6HU6IsJoaF9sA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641632216; a=rsa-sha256; cv=none; b=APAZzt5G3qvj6Q3KehQUwQuVVeVRfuFhP6vRbWM9UrNAT+eOxuAShVRAd3fDb2BKT4hkEq 4ijie0XqtNoi4Xr7h5Fx2uQH/DGcDEUotenXeK8dD4MAIfqwxmWO33ficBHjFZceWYtccE VwsjnPIkby3uRq++hMuxrw1u6KKob43JAbEL5ElzAEaQJotnDNJ3HtybSiUcEA/gslVbti /30spT/kpzz79+S+DLs/IR0sl5gbnGbyBKJkAtE+mg64uswSPUDZ8dvlM5TMltyx/HqLG8 WIELVtiNy0fD8SeOrp+gQ51Ks1EQ5GLJgLq6CUBuTJLqw/paJKmVuuYrYO18lQ== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=jCmJ5jfa; 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.90 Authentication-Results: aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=jCmJ5jfa; 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: 0BA98331C6 X-Spam-Score: 0.90 X-Migadu-Scanner: scn1.migadu.com X-TUID: LhdaxpPkeLwZ * gnu/packages/node-xyz.scm (node-sqlite3): New variable. --- gnu/packages/node-xyz.scm | 130 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm index 637f116c3d..9682582eec 100644 --- a/gnu/packages/node-xyz.scm +++ b/gnu/packages/node-xyz.scm @@ -699,3 +699,133 @@ (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 + (delete-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 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