From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id OGkVDdFmK2GmcAAAgWs5BA (envelope-from ) for ; Sun, 29 Aug 2021 12:52:01 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 4CO3CNFmK2GAIgAAbx9fmQ (envelope-from ) for ; Sun, 29 Aug 2021 10:52:01 +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 BC9B3EB27 for ; Sun, 29 Aug 2021 12:52:00 +0200 (CEST) Received: from localhost ([::1]:40270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKIPv-0007Av-Q3 for larch@yhetil.org; Sun, 29 Aug 2021 06:51:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKILF-000672-8G for guix-patches@gnu.org; Sun, 29 Aug 2021 06:47:11 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44061) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKILE-0001eb-TE for guix-patches@gnu.org; Sun, 29 Aug 2021 06:47:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mKILE-0000Gu-Qy for guix-patches@gnu.org; Sun, 29 Aug 2021 06:47:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH v2 10/33] 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, 29 Aug 2021 10:47:08 +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.1630234022880 (code B ref 49946); Sun, 29 Aug 2021 10:47:08 +0000 Received: (at 49946) by debbugs.gnu.org; 29 Aug 2021 10:47:02 +0000 Received: from localhost ([127.0.0.1]:55572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKIL7-0000Dt-EJ for submit@debbugs.gnu.org; Sun, 29 Aug 2021 06:47:01 -0400 Received: from mout.gmx.net ([212.227.17.21]:56681) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKIKj-0000AG-HM for 49946@debbugs.gnu.org; Sun, 29 Aug 2021 06:46:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1630233991; bh=1nQawcoPpnQ/cWAQJ5aFPxfolfxLxPFqFzBtuzewkyU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=SCJ/ib5tsT93qIoZ3kSD86tWiqGIURASipNhpbfU8hBfBu44212uwCvJnJqtRsdb+ PHlO8U9TdJrtN7stfYFF2DbmbF+93ZWGqcvSh3td+CX/b0aGOmGfddO+4or577TLAs aXGypzxfyD9SVcX4mprliLTkqdirgZo0X+mT6vHA= 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 1MIx3C-1mZ5OX2kyQ-00KRzI; Sun, 29 Aug 2021 12:46:31 +0200 From: Pierre Langlois Date: Sun, 29 Aug 2021 11:45:45 +0100 Message-Id: <20210829104608.3103-10-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210829104608.3103-1-pierre.langlois@gmx.com> References: <87czpwzg9e.fsf@gmx.com> <20210829104608.3103-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:V04dxS/jfa51YI1PGQrLluiANiNiGELvjQAN1xlG3qV87tsV4H1 PvrhPeX6Nq5AkZiZZItprJdVeUX1ywHZnE2smJ9YcfwnACrWiU8iB5dI/gFBglxMjT9eFkP 72RhOi3nYnniLuW0QLvuSvoECEhWUksZ+vmyhKrVkt3nhStOvXbz28B2o5vQfXUHdREc6fF MUMt0g8PiGaAiGXfu7dfQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:qq1IjGjISEE=:IwWl2AzOSrIN+OsstozEx+ zGmdBEKF4ei7wNcAcgp3Fi2fAWnS3icRKmpJhdUG+ypNaOKb/nDDONbi0v5Ot/FYCur/6DxOd JDhh+3TOZxayguXYycXQkWEE9n+oZNBZkQVxhfErtKUT0MAOBdXz/Ps1s1v/9Jpcbq5R668v6 phLzfTDnr9trFNfyuoSDPioyptBINz9hsNELQFcKpDnKF7DhPmVR7W/oQAQldtj38g/F+cjXa +w6I4O9db36VMPVMDUsv9TWFr8k7qQG+/idV6dWDVxugkrWZJV93fAkiyt6aMkkiKwOH8hOlU y7aSZHYF27cXHpu4rCeoQwKVXHaMeXVxLe0j/ZKUbyZRZneztzYzDKNG2s8fslLy7OdPXcmna /4hhKocrKa4zgHd1ScnwNae8idqqD8IfxP/EaHM2uhr10R7C6i0QeLHLRpAR9HxY58Jetd+r/ MU9n8EoaVDJxKl4F+BIK0hexZuRmjbgJ8zUhe45AqgspFEQnn/eCZ6210Ooeng1LHagJY4D/Y qWyL5vNhkZqS1i9U9Nqg752orROJHr1Lnpk6t9H0Bisf13dEN95maObAdh4dj43coj1WsxAv5 EvGApy658XlGA8v2ORE/iXDmzTbT+mh2GRjvF3Ns4R101Pc2YMPHsiNzyN2WgLkuSP9FUt9/s 6NxrY6W0gMciGjcUBgLziyDtCJGyYcnQO+gr6aIyqz+W+/oWI0dQXVzeOrAIyuRd1EaKy8U1F vhqmdgGs/oTh6b2sCB+6clGgupjcsBnM1G9YVZVQn5kIw3J0VcxAUo5k+RcWyC5gbPIy3AmNU e9sPkQs7zlU186MndUffpbl/KmpC/pj/tWEG7rMQoIKSGci4oNvXrTW2dWe7PAr0BI5767YKU Jl/j7JNv84qosThbaa+RcNUVaTQy0TtDf2zNZNSjFvRaU92N+bbAJiC9gAYgWTDo9whFpzwrD fAwNaNe8fhZLZSLmSsulog/6QdKCRLTYJ4QhgGoKYbIy2VfoOFKKZazpLGXZux5CATCcv0GWu dLsMVqnV7xZmj52JuIl6R1k2T4NGraXW6/sjFC8o1nOeh98hZDZCRRbMIhvIKQYP/SbJeJbtF VTFEFW0Jp6Td8ZJXUx7UP6OXh525PgAxnDFpv0L+F5fAx1CDyOW58mU8w== 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=1630234320; 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=7ZiwS+nQ5Lt7AFSYyR9barVbRcu+pycbn/LtabWfF0s=; b=uokBLbLCkTbOzc97W1aIYH1tGm1JASaKjFtF4Mo5IsHhJmG7GoMRHIt2P4+KU3JrPBkxek SWzlk/QgkL+OIGMR6Nvw6et22/MHq4BxgjRMGFqP9qyzeEOtPnkrYM1PKg9w5+ipqDQZ8o o1z+wQZJspFFeQ5IUhMY7rMaTB8o+eFIFnK/ngsJSJyDsbEqB9EiMnT0A5Iapv0BEUh6ff QsGH7weR7HptYoJTYC/kXmxtx9PGPyITMKyLfMHCTH04Epl77S8SBJGDtpL0sohgCdhBr5 NT6/0bLPLtsUKTiXDZgYCQRP3yEIZFzekYLtbu3WZWJ+2/0fheRMHB0ZIgGkYw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630234320; a=rsa-sha256; cv=none; b=LDsylo1n9j4eWl1iu4RtJvmfk6RfbuTwLkUwOtQ7DcM93X0Fz/6OUEnEGrvij+ZwacXAU7 61O1zxZJFAiruZsasTK3aPkIaedOsVJFt2ouFDDnUWZRlKUp/9+frMoJpA40fTlAMVPoe2 koMq+ch69eT3SLs1//hs9kbtL4BMi8mqFFS+wKf6YAQe87QwvGo/mDd1U8DjkZoGDVKolP 7R+orXUyqR1A1cmwLr8XeKf3+rivtard/uI1AlATTCrjdtcuLzoY+OUKifc/8kz+g17J3m yG203qZ2HovLqbeIAdapdx3nigF+UMF+YP9stGRDUNFHF5+yPRK2GMX7/XYfZw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b="SCJ/ib5t"; 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.33 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b="SCJ/ib5t"; 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: BC9B3EB27 X-Spam-Score: -0.33 X-Migadu-Scanner: scn0.migadu.com X-TUID: vnCnC+TEpvL3 * 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 530c04bc68..a6dab75309 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.33.0