From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id GMhPAoVtzWHS9AAAgWs5BA (envelope-from ) for ; Thu, 30 Dec 2021 09:27:49 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id gJ9zOoRtzWEuMwAAauVa8A (envelope-from ) for ; Thu, 30 Dec 2021 09:27:48 +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 aspmx1.migadu.com (Postfix) with ESMTPS id 59E6BFDAA for ; Thu, 30 Dec 2021 09:27:48 +0100 (CET) Received: from localhost ([::1]:38892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2qEK-0000to-4d for larch@yhetil.org; Thu, 30 Dec 2021 02:52:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2qEE-0000t7-HW for guix-patches@gnu.org; Thu, 30 Dec 2021 02:52:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:39721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2qEE-0007C2-6y for guix-patches@gnu.org; Thu, 30 Dec 2021 02:52:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n2qEE-0007E9-6k for guix-patches@gnu.org; Thu, 30 Dec 2021 02:52:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v7 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:52: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: 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.164085068427618 (code B ref 51838); Thu, 30 Dec 2021 07:52:02 +0000 Received: (at 51838) by debbugs.gnu.org; 30 Dec 2021 07:51:24 +0000 Received: from localhost ([127.0.0.1]:51238 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2qDb-0007BF-Jo for submit@debbugs.gnu.org; Thu, 30 Dec 2021 02:51:24 -0500 Received: from mail-ua1-f45.google.com ([209.85.222.45]:34751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2q9n-0006w3-TX for 51838@debbugs.gnu.org; Thu, 30 Dec 2021 02:47:28 -0500 Received: by mail-ua1-f45.google.com with SMTP id t18so33705002uaj.1 for <51838@debbugs.gnu.org>; Wed, 29 Dec 2021 23:47:27 -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=n1J9/0PeIs+JWcGNuDLZsva9xUmY255cKQQSVLijebU=; b=aw5esgwVW9voW1qEx6NCzdUK4qJAHhX+M5YssbOAyucwvNHFYAcyFgpOQSow7Kk9xQ LIN8djQXkAu7mvSzahqByW0NeCnAvaDElTC2SX8xKv/t/l8zWbU+xxxFzQ9E8yJX/ToK mj6/ZweIXVqb7sdEods/plt5b/VAAEG3kymeVIJjSbhLZQD/RUSvJi8U2z5IGYlVrbB9 tfkE2khcSBH/ttvbVZtENRC1MXbpLdlggh6C2CqQVEBUlMdLJhixoMRaYn0DpKTdMA1B ny5Yo0ky9ZGXAmYk8brSlMq8+JYdhRoVGJ+B+eV/ArXGALhg3d/L06XQLcS64d70NCbf RrtA== 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=n1J9/0PeIs+JWcGNuDLZsva9xUmY255cKQQSVLijebU=; b=6UPVdBQoH8OmLWBWcemopn2J2C6vsBSuoI0SNazOIeoQndkdKVUC3Anj8BZKduaoGB rLKfWgD3HK+x4mFkuY5ZsQiCr+bbQoTLkwcwQ/a7Eg48tNTInu9TfBgipH7M3wYviJuE z8LCOVeKFmaQDhu4JtNI943m6eOizOmxmeLEF739jBey/cGrAM91rBFgZ3gE+1pWqmA4 h44cZtOO7cvcheaaVi5nspYn2scLUh6qLT0+ZJ+OoXshlOLmhZodBV2mJNgAvRfakB7Q pH4bbkH3+f/uf3rQU5qgdMCkdMNMPLBL6DMN2vh6LDRhXYVzk5pFMJBN/TFxUajL5DLy oSlg== X-Gm-Message-State: AOAM530E+vqcXLsZumKhQf6iuHtg0M+7UkSOTBhmXpDlVpxm6AJ8A1Zu 53WUVUeeKMiRZuomc00f8hqMUZNW6KsQn54N X-Google-Smtp-Source: ABdhPJzgXIPbI0tRQvY5AwGRnnXElM5Ac/vWXYZjaVUKIfpoOaJwOdwedJq1Cik9vbid68yUT+iRxg== X-Received: by 2002:a9f:2f1a:: with SMTP id x26mr9565099uaj.109.1640850442356; Wed, 29 Dec 2021 23:47:22 -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 o5sm4896256vsa.4.2021.12.29.23.47.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Dec 2021 23:47:22 -0800 (PST) From: Philip McGrath Date: Thu, 30 Dec 2021 02:44:40 -0500 Message-Id: <20211230074456.33433-26-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211230074456.33433-1-philip@philipmcgrath.com> References: <20211230073919.30327-1-philip@philipmcgrath.com> <20211230074456.33433-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=1640852868; 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=n1J9/0PeIs+JWcGNuDLZsva9xUmY255cKQQSVLijebU=; b=thrL6RLWYBOAgvBBm0d3EKOMc5uu4iTN1JFTbTiokDYvQQqtU/m53kS4fTjM2g7N9oiCcn PK/EdoW8SgMqVFY4CngWWUKVvb7/clOIbtTgXHt9iKFig7QGCFxYoAneHR0tRjCBGSElKE YPkAIzDvfnQyo7FxDbLPZbvmCTtRV3TthXtS76IGjcxWNIpyFKUxVqHu9GV3w/O2QfRKx1 ko+MlaKln3Ook0B/v+ytdurAC/VQOlkPKS8Xv0VzPvX/ykjuHX1V57yPYfN9g1Zra4qcVH M0QKkMlfFe9mCSyZpG45pmJ9x9Q8be46F5ocG5wyoP12UW7YhuNKP1AhNPxA+A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640852868; a=rsa-sha256; cv=none; b=Kx2dr/qRiO5RAvsLrugJ5M6zb9lblO204lKAX7tQO7VwWOY8sfXwYKLiVQCkSvGT5hvcDn FIr617TB8FYyW04doBNnEvzeHIjGlaW3ehF94oHCzu5i8AvYf7cqgK7dK9+IdWn5zC0sOg EHtFHso+bYaC46qi7lUnlKMSVXQPEPpuaJrcaZbifkhtWHOYHqdLruNiJyQWrcU/3Ac7RH badJR2BRkzQqL37nvbYhaoQ3EA0ctOh0EkuLyvbk0wA9Aer4lXdhtLe5qTJr8glAlTS+pk xckmJI+T7Ax6ZyZD2dcrA0Gc+mkqcKvQrBQtEOo6Louo7KXT8CPbSBcl3E6S5Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=aw5esgwV; dmarc=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: 0.93 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=aw5esgwV; dmarc=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: 59E6BFDAA X-Spam-Score: 0.93 X-Migadu-Scanner: scn1.migadu.com X-TUID: 91be1cNVvDTR * gnu/packages/node-xyz.scm (node-sqlite3): New variable. --- gnu/packages/node-xyz.scm | 128 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm index 91a007b55c..d525da8dc3 100644 --- a/gnu/packages/node-xyz.scm +++ b/gnu/packages/node-xyz.scm @@ -671,3 +671,131 @@ (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 + #: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 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") + #: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 + ;; 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