From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id Tuz0J0pqEGGGIwEAgWs5BA (envelope-from ) for ; Mon, 09 Aug 2021 01:35:38 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id /K7vIkpqEGFgOAAA1q6Kng (envelope-from ) for ; Sun, 08 Aug 2021 23:35:38 +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 0B6D7D1CD for ; Mon, 9 Aug 2021 01:35:38 +0200 (CEST) Received: from localhost ([::1]:42308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCsKO-0000BU-Vj for larch@yhetil.org; Sun, 08 Aug 2021 19:35:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCsJv-0007tM-R8 for guix-patches@gnu.org; Sun, 08 Aug 2021 19:35:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43469) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mCsJv-00065b-Jw for guix-patches@gnu.org; Sun, 08 Aug 2021 19:35:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mCsJv-0000vS-HH for guix-patches@gnu.org; Sun, 08 Aug 2021 19:35:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH 09/31] guix: node-build-system: Support compiling addons with node-gyp. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 08 Aug 2021 23:35:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49946 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49946@debbugs.gnu.org Cc: Pierre Langlois Received: via spool by 49946-submit@debbugs.gnu.org id=B49946.16284656763384 (code B ref 49946); Sun, 08 Aug 2021 23:35:07 +0000 Received: (at 49946) by debbugs.gnu.org; 8 Aug 2021 23:34:36 +0000 Received: from localhost ([127.0.0.1]:54989 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCsJP-0000sO-LM for submit@debbugs.gnu.org; Sun, 08 Aug 2021 19:34:36 -0400 Received: from mout.gmx.net ([212.227.17.22]:37737) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCsJF-0000p0-T7 for 49946@debbugs.gnu.org; Sun, 08 Aug 2021 19:34:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1628465660; bh=1xHFwHs/B9bMJbdZRUu95p2LlUPYOA3r7DmpcaCtJQw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=OmwezAhC7KG+YCwzW7wtEyldGekH3JBCRJLFzgesK6RqH8CZLr9ke4c4MikWajSQA OIBGc6C097Imn7QsHi5I0eH4Y9kAILu9HRhP2a5jWfj/tTuDkHytTt1ypHxybLnSRL eFgpWDdrmEmKJGFjD2iTNiUqx7fi27J6609Ueayo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Mg6dy-1mlft73gru-00haYl; Mon, 09 Aug 2021 01:34:20 +0200 From: Pierre Langlois Date: Mon, 9 Aug 2021 00:33:32 +0100 Message-Id: <20210808233354.6745-9-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210808233354.6745-1-pierre.langlois@gmx.com> References: <87h7fztt60.fsf@gmx.com> <20210808233354.6745-1-pierre.langlois@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:T39g12904tKuBJm22lsb1ZoTAvE4YclYsMGjo3W5opsmB043u09 90M4+6NliZYp8iaxw0qQbJuSYFCYFdlkeknB7KSe87O0kbRPpgNgqJeaAnuZA03XcV4kaVm tMGUn7XNEJ2ogtPRPAdjVi+m7iBMBvc5iKpJo0dihCBRHYku2LEefh3pZ2qF/E9HFIqui4K CYU7qsl+z0p6k5cORda4g== X-UI-Out-Filterresults: notjunk:1;V03:K0:NsV2pfxMuro=:5dBrhS8W7bBFpULhpK1Q1W yR3ukIX6hUo0LDSGhsM8fMcVp0mSw1S8LpCkKeXweBcqmwmxPx1Ao0Pa6xXg/EQQ+XkkBDuK+ XsgVzslvaA1UMeOBK/T0xRiT9sJnB8RoPAAMePpNTm/HxjTQzZ3HF9jXzVr8xM981PATt0FNn edps+taHbTEfGinz28pq7EbM4PDRVR1T5UzEz7axwnKEWffSpAE9WrcDeI6YwPLa0NKhsSK9x GTL78+15hKZ3xuQbWZotPv+C03iFMFuXj/qvEyyh+GsjKOF+6c62zBFN9uRzJPzsKHvWKOY2f lKbHx0xMJtpnFwWZqxX45QU9kSs41Pws3Dwojh0LqHVRwOSkWO334/Z64C4+IH4qLF9fQX9pa J60UO46HMlSgSU/ByASaOsepPUnyXDlQsoX6t+QhMplLRNKHT78N5x5KDlH2bbFzqO0tC2rQf grp43tx95AR05awVCU1jbpq3P2ctDawkBt1+W/P+T+K83jK20eNG+jUqHjd1n0Q7BTcqd7AgP /jMMWe2kxiLKp6uHp5GOiZvcjUGRux/dXr/DB5CCpoPeCN/GFqMFc5hjh/ARiQz63b2Pc1kMX 25dGl9GADDmaXlXtSeSBImaHRj7glCREnLxGvYkm3pay7/i+rkDJEh7gpUyZ6kxwQPsUhfNhf fcWEBvL4qZLZuSSgzPqgie2rlD6Euw9KKxEcWwex4huso+IfwFp8cN5steogY8duvgK/1aGws j3ogBiYQVGXbec14Efx/wvLuQ8VPUGArbi2x/hp/k5Cg8poBi7oCh2bYQ80vypLs6vj9w3joz Ul+PeA5BA8c4IMcfFYvbo/mH0znIe9ghTwtcm9kd/hh+Uv6GeJVlM/dthZXb3u9dHFAaf+3ft 2KKtSZJVOBoTA0Nv1tswHWshTqf7a6boI7/5U+4gF4IE2NWzJ2L6BLnrVx7leErQbLjdyJ1yx 4JpegZdZ8gDIHmeZlGQldFN1LJNmfKmSR7iEWRY+EbqErx/hYcI8uEu0kpmHP4eLe9fqIaQSR Lk4r4QkqM2uD27FGTWkKPEMi21oJOYZUNnSbTOkmHorMfdN5SEMbLzPVHd9M2M3Sy30gn9CEU m0o6tq9QFGyKuDoUbfgogOgt+WfCcjePV12i5mSXfzJHbk5X4abdewXnw== 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=1628465738; 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: 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=owQrWguHM4a4hoFNaVyiCzCubHMF7TQO+BYtQEcjB3o=; b=suPM+O9Aw+Ir1P/HgxkYRMphVErGnmyHdpQIYkGD3d3KpYNjEogPFFSbcPBr+Wo6f1c3DM KFSlrIsiyxSsCD651zUwKZ6Qa0yi8loR9dy7+jFaR159xX8qe4xw73DRJ+VzBnoNuBFaWC xm3Ge643OxrUHfZEhRthzowUzAeZmf5FN2uQPazS1/zEZsfI8rn5wQfWSxhNxj/uSytkix tshyeNc15yRnAkTFyl6JcomtbkVRR+SspPTXo+qHJo7dP88gpwikn+AWdBsS1x7PDv2BcB PzqZPCqWLMP2dd4NB1di9zARpJI2Ilzcc1Rn/8S8yUr5ZEStuVSMcYJgm+7ZjA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628465738; a=rsa-sha256; cv=none; b=KTQGh+J5D35a7iaTWCjhHBmpOYXYPcmUMSmgqtApPLrLPPMPeE0btOoGTtU6evzBdzs0mA yejcHjUxWEjaw+nrlD1F6BPltJVUPUT5fL4r0RiWUFRAgUcPd0VHdQdNirWZTls2/V0jUh gf8kA1OiOd4HYV3U1srkLRdM++V9quczYYcq7j0ezlN+3wshcPvv3UdQZjj6DKaiZlYcvf O5k3GjzeWWtJAzFgvuqiGauK/+9tYfhCQieAX7+JowmHZjPgtcRntz54/f4bWdSkT7wrDE sDTdyZPPa0kEQSYTnUIDSMRL5KHIOc4LszlN9Me016N1383M82NLTHDSykkufQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=OmwezAhC; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.31 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=OmwezAhC; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 0B6D7D1CD X-Spam-Score: -0.31 X-Migadu-Scanner: scn0.migadu.com X-TUID: XJ+kppZ3hUTI * gnu/packages/node.scm (node-headers): New function. * guix/build-system/node.scm (python): New function. (node-headers): New function. (lower): Add node-headers and python to build inputs. * guix/build/node-build-system.scm (configure-gyp): New function. (%standard-phases): Add 'configure-gyp after 'configure. =2D-- gnu/packages/node.scm | 19 ++++++++++++++++++- guix/build-system/node.scm | 16 ++++++++++++++++ guix/build/node-build-system.scm | 15 +++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm index 522d4943d0..d0f7c5cdb7 100644 =2D-- a/gnu/packages/node.scm +++ b/gnu/packages/node.scm @@ -48,7 +48,24 @@ #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) #:use-module (gnu packages tls) - #:use-module (gnu packages web)) + #:use-module (gnu packages web) + #:use-module (ice-9 match) + #:export (node-headers)) + +(define (node-headers node) + "Return an object for a tarball with headers for the given nod= e +package version." + (let* ((version (package-version node)) + (hash (match version + ("10.24.0" + "0h37zjwcpxjdqcxqjfj5zp1n5zjxaa0g8lsy83955afg5cca8p0n") + ("14.16.0" + "1vpdgq7kcw1a0w90lpvbvxbrc0n3pwjrs3sm42pjj7560clvji2b")= ))) + (origin + (method url-fetch) + (uri (string-append "https://nodejs.org/dist/v" version + "/node-v" version "-headers.tar.gz")) + (sha256 (base32 hash))))) (define-public node (package diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm index 98f63f87ef..7828582a9a 100644 =2D-- a/guix/build-system/node.scm +++ b/guix/build-system/node.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2016 Jelle Licht ;;; Copyright =C2=A9 2019 Timothy Sample +;;; Copyright =C2=A9 2021 Pierre Langlois ;;; ;;; This file is part of GNU Guix. ;;; @@ -41,6 +42,19 @@ (let ((node (resolve-interface '(gnu packages node)))) (module-ref node 'node-lts))) +(define (python) + "Return the python package." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((module (resolve-interface '(gnu packages python)))) + (module-ref module 'python-wrapper))) + +(define (node-headers node) + "Return a tarball with headers for the given node, needed for packages = that +need to build native bindings using node-gyp." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((module (resolve-interface '(gnu packages node)))) + ((module-ref module 'node-headers) node))) + (define* (lower name #:key source inputs native-inputs outputs system target (node (default-node)) @@ -62,6 +76,8 @@ ;; Keep the standard inputs of 'gnu-build-system'= . ,@(standard-packages))) (build-inputs `(("node" ,node) + ("node-headers" ,(node-headers node)) + ("python" ,(python)) ,@native-inputs)) (outputs outputs) (build node-build) diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-syst= em.scm index 70a367618e..2993c49b2b 100644 =2D-- a/guix/build/node-build-system.scm +++ b/guix/build/node-build-system.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2015 David Thompson ;;; Copyright =C2=A9 2016, 2020 Jelle Licht ;;; Copyright =C2=A9 2019, 2021 Timothy Sample +;;; Copyright =C2=A9 2021 Pierre Langlois ;;; ;;; This file is part of GNU Guix. ;;; @@ -101,6 +102,19 @@ (invoke npm "--offline" "--ignore-scripts" "install") #t)) +(define* (configure-gyp #:key inputs #:allow-other-keys) + "Run 'node-gyp configure' if we see a 'binding.gyp' file. + +By default, 'node-gyp' will try to download node headers from the interne= t, we +prevent this with the '--tarball' flag." + (let ((node-gyp (string-append (assoc-ref inputs "node") + "/lib/node_modules/npm/node_modules/node= -gyp" + "/bin/node-gyp.js"))) + (if (file-exists? "binding.gyp") + (invoke node-gyp "--tarball" (assoc-ref inputs "node-headers") + "configure")) + #t)) + (define* (build #:key inputs #:allow-other-keys) (let ((package-meta (call-with-input-file "package.json" read-json))) (if (and=3D> (assoc-ref package-meta "scripts") @@ -147,6 +161,7 @@ (add-after 'unpack 'set-home set-home) (add-before 'configure 'patch-dependencies patch-dependencies) (replace 'configure configure) + (add-after 'configure 'configure-gyp configure-gyp) (replace 'build build) (replace 'check check) (add-before 'install 'repack repack) =2D- 2.32.0