From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 cH13E4c012G1IwAAgWs5BA (envelope-from ) for ; Thu, 06 Jan 2022 19:27:19 +0100 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id yKk2DIc012EBIAEAG6o9tA (envelope-from ) for ; Thu, 06 Jan 2022 19:27:19 +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 B77F860AE for ; Thu, 6 Jan 2022 19:27:18 +0100 (CET) Received: from localhost ([::1]:44268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5XTp-0000og-Tu for larch@yhetil.org; Thu, 06 Jan 2022 13:27:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5XSm-0007Tv-L6 for guix-patches@gnu.org; Thu, 06 Jan 2022 13:26:15 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:49383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n5XSl-00013Z-3L for guix-patches@gnu.org; Thu, 06 Jan 2022 13:26:12 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n5XSk-00057M-Vj for guix-patches@gnu.org; Thu, 06 Jan 2022 13:26:10 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v8 25/41] gnu: Add node-sqlite3. References: <20211114124151.36743-1-philip@philipmcgrath.com> In-Reply-To: <20211114124151.36743-1-philip@philipmcgrath.com> Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 06 Jan 2022 18:26:10 +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, Timothy Sample , Pierre Langlois , Jelle Licht , Leo Famulari Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.164149351819302 (code B ref 51838); Thu, 06 Jan 2022 18:26:10 +0000 Received: (at 51838) by debbugs.gnu.org; 6 Jan 2022 18:25:18 +0000 Received: from localhost ([127.0.0.1]:42241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5XRt-000518-NU for submit@debbugs.gnu.org; Thu, 06 Jan 2022 13:25:18 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35585) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5XRK-0004uX-5F for 51838@debbugs.gnu.org; Thu, 06 Jan 2022 13:24:43 -0500 Received: by mail-wr1-f65.google.com with SMTP id e9so4973817wra.2 for <51838@debbugs.gnu.org>; Thu, 06 Jan 2022 10:24:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:subject:to:cc:content-transfer-encoding:message-id :mime-version; bh=cJXypJ2ZP6BF1vGQBSFaThqniDAoor2NhMeFupIaqG0=; b=OCLOmvj1SZwTG+hON8Zbg2q8+3vixNFLbViymfaY1rpMUA8WSHMGy0vZYOUrXw/6ve xVn+jOK34zuH09gwAiKsc8499ObCuQJurfwODtxlP4SIim1ksa1aTCqjTLoU6TGxT0x/ q0owA1bP+NhpNsRXGO3+J0Zf6MfzseWDLsm4LlvfLwwHz2Yz0CuWa6S2AR3FUqtMncUF fXo5ZkcBxoNdjw50Ss3UXqyLZKdbMaSy+hOsSvI9FiosCF2pnYjsJnsgXxnTOjDn1EZq QUd4IVYmW5FeR4AdSP4uDcgSst3qIK8OvRihsHEQ5xhh+L6l3l8kF/EOY2X9NTE6bWza JS0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:subject:to:cc :content-transfer-encoding:message-id:mime-version; bh=cJXypJ2ZP6BF1vGQBSFaThqniDAoor2NhMeFupIaqG0=; b=MZqYJomQ7jjtKqNvEgoLRxVYB3+piKFh32cmVi3ZN60Mk8pkm4uA3EYOUMQKoY8oB8 qsLXm53Fo3gsjOlmYnFj1I+8kFNjXIbvvA0HC7QXMsrzeTTH6bhucbYLQbpd0TKehWWI Ox/Gy4t/5vpBu++OaMKrMtsggUYluHVjQhgsJCMUi0eHePbLzCQQDwowtWuFzN0XN8W5 msM3ivrwX28Qw/CB+Ur4fJaLGYSB6wgir9idG3CTcAvhb7dRfHP2YqjUNHNZDNr3cOkK WFnvZvP/yGJ0+WiMOG0MLJrXX5xnQFioOJheGiFzEvt5VgatUgnK3eigIwcHHW3a0cNn KIXA== X-Gm-Message-State: AOAM533x4UFiak5dM+1f0PzZErkuqL4p/Jb9B3NPp+8T6ar8pWxpK6Gh kFgjAY3UDBx1qUBYx24eETk= X-Google-Smtp-Source: ABdhPJyTAWyJvqx0yHStLOGTxVm0E5C17JoP74P0HCxTfG1c3nmY1ej3FGjl6auSlht61fxGN430uQ== X-Received: by 2002:a5d:6803:: with SMTP id w3mr28617352wru.673.1641493476603; Thu, 06 Jan 2022 10:24:36 -0800 (PST) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id b17sm2693311wrq.91.2022.01.06.10.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 10:24:36 -0800 (PST) From: Liliana Marie Prikler Date: Thu, 30 Dec 2021 02:39:03 -0500 Content-Transfer-Encoding: 7bit Message-ID: <2e34122a1cfab3fcc15229bfc613613dc34f2070.camel@gmail.com> MIME-Version: 1.0 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=1641493638; 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=cJXypJ2ZP6BF1vGQBSFaThqniDAoor2NhMeFupIaqG0=; b=DLPmDGMYi2PrHpCGo0lEiRKBtVbuilIV89vP1WOnGXSuyhoDmAt5iv4YnjzOIsiphJm7l5 U4eRhwf7z09KSDjUIIo3QaqlEQgkbPAVhzPmTkMlX+UlONvb+ATdcc1J0yhT/DCnZOPdKm uMLVRfd17R3AYjHaWIT3WE2VUeOCD5IZx90W/ItqL9U0LamR90+0kFRzv6EcwKDWE+uBgi zu7VprGsGDQZ5Kpr0RDePOGb/DhPOK+PyBoEErhOC3k3OCrpcOj8Pa97ILqF9Mwcb+2mPx ZCBMuOqzxIe3w8wAyHO5d2Pw1PL5AkFrdpewt26I6RoZ8Sqrj88RzlGIyE9o7A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641493638; a=rsa-sha256; cv=none; b=hXsDadhQ8ziL7jsbLpeYFbonmzapNv19B6OPyQ9ZkW21CWz+X+3vNbQRVWhVSEmCPg9536 gurdWxSm4Ws7oYPeM9fgaQkw358zahE2u+AOmgX6U6XoPR8avWB4j8ShpbeRiOJDo7+7sh 9NW0mVLDlztRudaw3wR1kX7JkMDJXPu/3xukO2SuhmhmZ+EnOecqLtR9LVCY+iR5pMuEfo 5v4apyTR2Oop482pRU7WLapUwq3aTglT6yeH9WxYSCX/QdYRenulY2EgU66pjTVOrmzdtz GCTpJoOVDcafUkugjR0kbfiDIzVuWo5g8XgLJuODDeFcVsg/TmmLXF2NypcBFQ== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=OCLOmvj1; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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: -2.30 Authentication-Results: aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=OCLOmvj1; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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: B77F860AE X-Spam-Score: -2.30 X-Migadu-Scanner: scn0.migadu.com X-TUID: nssqQLYLklQF * gnu/packages/node-xyz.scm (node-sqlite3): New variable. Signed-off-by: Liliana Marie Prikler --- 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 325424f8ca..c22291f66a 100644 --- a/gnu/packages/node-xyz.scm +++ b/gnu/packages/node-xyz.scm @@ -687,3 +687,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.34.0