From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id yCJWAGgetmHgDgEAgWs5BA (envelope-from ) for ; Sun, 12 Dec 2021 17:08:08 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id YKt2N2cetmH6HQAAbx9fmQ (envelope-from ) for ; Sun, 12 Dec 2021 16:08:07 +0000 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 aspmx1.migadu.com (Postfix) with ESMTPS id 3C80998E2 for ; Sun, 12 Dec 2021 17:08:07 +0100 (CET) Received: from localhost ([::1]:56694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwROQ-0006Wn-E5 for larch@yhetil.org; Sun, 12 Dec 2021 11:08:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwROM-0006WC-QO for guix-patches@gnu.org; Sun, 12 Dec 2021 11:08:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:41387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwROM-0005jK-If for guix-patches@gnu.org; Sun, 12 Dec 2021 11:08:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mwROM-0000CZ-Ez for guix-patches@gnu.org; Sun, 12 Dec 2021 11:08:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v3 29/43] gnu: Add node-sqlite3. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 12 Dec 2021 16:08:02 +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: Philip McGrath Cc: 51838@debbugs.gnu.org X-Debbugs-Original-Cc: 51838@debbugs.gnu.org, guix-patches@gnu.org Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.1639325242704 (code B ref 51838); Sun, 12 Dec 2021 16:08:02 +0000 Received: (at 51838) by debbugs.gnu.org; 12 Dec 2021 16:07:22 +0000 Received: from localhost ([127.0.0.1]:52929 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwRNh-0000BI-Ly for submit@debbugs.gnu.org; Sun, 12 Dec 2021 11:07:22 -0500 Received: from mout.gmx.net ([212.227.17.20]:59061) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwRNg-0000B4-7r for 51838@debbugs.gnu.org; Sun, 12 Dec 2021 11:07:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1639325234; bh=YkAHgk5+Q1WYHVZ+jM30XEps9acmiRb36/uzLpNnUDk=; h=X-UI-Sender-Class:References:From:To:Cc:Subject:Date:In-reply-to; b=UwzJOv+Yfvf1KKO5OZeaMM8ndtRycmvHs0mNLXgE0fWzQIKzd7KM9R03zeLBa1Any OUTPhEqGhoHS6ZJ+nm67fm/85S5uMuxyeIoFwD1TBP7ifpaiJXAM3UeppYpArvX0sl T+8qbV9MyaxFQfxRHtYtIqEM+lKRP22g1u+GfttU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from labiere ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MBDnC-1moD6d3y9e-00CfNN; Sun, 12 Dec 2021 17:07:14 +0100 References: <46a042bc08eb72a068b1e8c69bfe28cf2d4b2e53.camel@gmail.com> <20211208202838.752542-1-philip@philipmcgrath.com> <20211208202838.752542-30-philip@philipmcgrath.com> User-agent: mu4e 1.6.10; emacs 27.2 From: Pierre Langlois Date: Sun, 12 Dec 2021 15:42:47 +0000 In-reply-to: <20211208202838.752542-30-philip@philipmcgrath.com> Message-ID: <87v8ztzu1a.fsf@gmx.com> MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:hPqPJcQQ+AFf6YFQQDyNI72/s1vey0NjnfZP94hOlhKfZje5VQ4 oWyojXPsgL+Tnp05bXxvRTvGAEnjvF024nTGthzutmww1EmFlOfW+oLBn4qssgz8mh8gNYB xN80cNvnHckxeFUW3X7bmko1qtBapNxtwmbbtgPIaNHLv1Utu5qNjr8VZB6T7e1IMuIp14x wde0cZpY7NhYBOmPGEDRA== X-UI-Out-Filterresults: notjunk:1;V03:K0:XmqaF2+fIWM=:8WHp6dOibCikSEmKbEdqop CVgxCLoNUHonGegScLt9ogL0MAP1f8zM990EA42ZBCRCrZjN6V/6n2y1EDkVyijKpr6HaD589 qCM8ysFK9Rkw5GfMGNq1EZZ2+t8sA+JswZbj9KAiZiaB8K/FMU8VpYOYBke90gEpzqcHKpjiB +qSu/IzpFZve6kbov6pfaDfEeKmRLJz76FBDxOjp8T7HeuDTVFZEkUgfl68WRvXdB2DtDa66D XuOHZ/Of8PhboHOqghMg7bMb/aDJKGe9bPfWkvLJOVlxgFenv7RDFz0U98Jyg1gQ/N130EIKt UgsLdnG84dHcabk1JpjTG3Vefla3XameUaOkLeV9K5tJHJNmLsHlQMaRwc+LOVY1OgAkVTGvP QFdyx4SzFhFyTeV1s11BxRvezY1dACEjimCCKtkLm59rdUihaiejOLNzrTMgGaDH4JQawKUHS PSgfPFdLYQPOVg+0NRQRYIPJ3qdaTUMjtkH/4Ppr/aQqFVtCnJwPSw+A8kxqiLrbNEXFl7ZAQ jsv0z+aX2/IfnC0sQz8tygtYDDwseJodL6YQex2XTyxLon3Pz/3rMj1173Qww+Da97DkxlfqZ ZlK97c5t3L/CvoGFFGnXiM8isQcjihn6ezSH/r0yvFR/HU9CWU7ZN/XvoLUL4wHLMqRwLeKN/ Hr08yB+RdmdPgGsEilslkV+faXcQERS0d2rZdnhwAzkn7J25uxJSz3sX/61YNX9KS+pYIm1b2 kw9IQew0BeVCtym4DJYs0LD+JVi2ARR+wJ6FeJB+2ZzknJcD1a7A9zM8plPc0619VEIBWTeiK FyvEsawuVdyEv00pXK3aOUMar7pFLfDduBOxZQRBRkcAiEOBpOq7WdjXVdGPwfMB3JnEq9erG L+XijVW0HXU3PgNi5A9OQnwNURiWSiWmfetZU3g79CvXkYVKTjz74Te6L7fDxrw4PkJffXJKx /gRN2KIPFOjoL8lMjUVqofd5agdfSGVMI6immgYrBYhEV7sA6mG/JzcuxkY2lXijbF+HSidQy srzS5h0nxvknf23KPzU55HCSLIWsIOG2d3YAOErjwLCWpy9llZSbRuUmqO/rPy3/SrLKACdLD bPAZEeJMj6krXY= 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639325287; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: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=oyCqpN7N9Ixxa3QORedzVACmkrJgLJF3xgT04ZkPAgk=; b=KwkGg/Qlki9P8iTe3q59nF1O+gAT6ehWKC0ecMhTuGBGFYs1qVRS/PGoM0Q/AIuj21Oy+n frPRadzyovQ0nDJ9kL2VkfAvLKwKQ3Re9rxW+hmQnFUVPcU85Wz2Gu+mQEPq67q2iMmy8L osmlRBDx2BZeRMdEOGIKe2xXZK9t4UZ2I86BjQ25avx2NScLWh8LQuepyQoiirPCzNMnx8 /0lOqt96wAfv8mSQN9UQCdKK/+utn+S+cIe0pcHKspdZYXcM/B8B/dqYB4sXSST79awo/C 0m1M67HD3UfkYiA6Lnq4PHWWydpNuv8NAykKThTByEGcwqnL0ddyxzz+zYkmgg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639325287; a=rsa-sha256; cv=none; b=gLNr8fI9lS69s/9gsKoYqHijyM3DXFUzEnpa3Oihg8Wi8Ug7jf0BstaM59bO+P+7VjXON5 N8wiGpyafQ5DdAsxTuBLX8ShMntOjyuS+DXB3vBNrv2E/bI2B41uX1NmHP0BLXXtehbE+q 68KucaoTVazj/2r6mg7dgQuQV26AMQE3PrUdqKUfhGuaNgcLGY94Efr34JEpF5vpUPIx/c 32HHRU+NrpEm2cG2KdB7v5nBooZhJOf5FkkKSf4e8d87Qum6tH1vbdVEcBy2ZeI4ThYXhS FdCHG5p78/ExzuPAzMqA4etF6pgiJsjZOJ7CIMCZX3b3qTdcUQ16ylB3JpeVLA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=UwzJOv+Y; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.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: -1.87 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=UwzJOv+Y; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.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: 3C80998E2 X-Spam-Score: -1.87 X-Migadu-Scanner: scn1.migadu.com X-TUID: WB6P6zKFkcUl Philip McGrath writes: > * 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 nit: Did you mean to include these changes in this patch? It seems they should be part of the node-addon-api patch. > @@ -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 typo: beceuse -> because > + ;; @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")) Would this substitute* be more suited to live in the 'patch-binding-path phase? > + (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))))))))) I was having a bit of a hard time understand this phase, let me know if I have this right. We have this JSON input: --8<---------------cut here---------------start------------->8--- "binary": { "module_name": "node_sqlite3", "module_path": "./lib/binding/napi-v{napi_build_version}-{platform}-{arch}", "host": "https://mapbox-node-binary.s3.amazonaws.com", "remote_path": "./{name}/v{version}/{toolset}/", "package_name": "napi-v{napi_build_version}-{platform}-{arch}.tar.gz", "napi_versions": [ 3 ] }, "scripts": { "install": "node-pre-gyp install --fallback-to-build", "pretest": "node test/support/createdb.js", "test": "mocha -R spec --timeout 480000", "pack": "node-pre-gyp package" }, --8<---------------cut here---------------end--------------->8--- And we: - Read the "binary" entry to find the module_name and module_path to give to node-gyp, so we can use our own GYP instead of a bundled one. - Delete the "scripts.install" phase, it's not using the correct GYP. Maybe a couple of comments would be helpful here :-). > + (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))) Otherwise this looks good to me! Thanks, Pierre