From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cGXDB191kWHcRQEAgWs5BA (envelope-from ) for ; Sun, 14 Nov 2021 21:45:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 2L5vA191kWEwXgAAB5/wlQ (envelope-from ) for ; Sun, 14 Nov 2021 20:45:19 +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 7A4869ECC for ; Sun, 14 Nov 2021 21:45:18 +0100 (CET) Received: from localhost ([::1]:53442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmMNI-0008Ro-Ut for larch@yhetil.org; Sun, 14 Nov 2021 15:45:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmMN4-0008Rf-Ap for guix-patches@gnu.org; Sun, 14 Nov 2021 15:45:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:40291) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmMN4-0002Zu-2G for guix-patches@gnu.org; Sun, 14 Nov 2021 15:45:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mmMN3-0007Xi-VV for guix-patches@gnu.org; Sun, 14 Nov 2021 15:45:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH 03/11] guix: node-build-system: Support compiling add-ons with node-gyp. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 14 Nov 2021 20:45:01 +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 , 51838@debbugs.gnu.org Cc: Pierre Langlois Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.163692266728932 (code B ref 51838); Sun, 14 Nov 2021 20:45:01 +0000 Received: (at 51838) by debbugs.gnu.org; 14 Nov 2021 20:44:27 +0000 Received: from localhost ([127.0.0.1]:51837 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmMMR-0007WU-BB for submit@debbugs.gnu.org; Sun, 14 Nov 2021 15:44:26 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmMMO-0007WE-8v for 51838@debbugs.gnu.org; Sun, 14 Nov 2021 15:44:21 -0500 Received: by mail-wr1-f67.google.com with SMTP id b12so26567841wrh.4 for <51838@debbugs.gnu.org>; Sun, 14 Nov 2021 12:44:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=UwClZr4hyl5pH/iS3pEuOMGgq4vG7OlSKei5DkFZuFU=; b=pGWCUoAM6jbI4UYJKFoZ6WzznU0RuRS+0Jfum61jlkirkCgw3oA/bAeOL/OKEwMImx cwZeT+cXaR1lPiHL+sh8U9M2pt2+SwSXhadlVSJkKZ0ryrILl9gXzUSib5aB1L/k9olI Dclo/DDQv6JSGgxdmFV9WhUQsD80tCP4ox26hJVzoUxODhqSSJRBevYpVVsoXoeoXV9W 5T3NNNOnra2mTgk8f4A3V9Yh1fg72KYiB7VdEA4rACN7owvNLkbuMUC1gJoE47sNN5xa 2KXOd0vyfQ76bVbaOlEvym45lj8oC9dd58qopp3e2fP57yJt1ppmWqC7BkiZcKldInb2 3Nzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=UwClZr4hyl5pH/iS3pEuOMGgq4vG7OlSKei5DkFZuFU=; b=7fbCPOeSYglJ5HjvBKoFrw2QbZfkyCsLcR1NI+U5M+QS0bE6gPcYPhkbkyeAM1zZnJ jv3OAEtKwuLffatl8v8F/OdUUfM/1dyXDmXxQ5q8yJNrcTeM/ruS8Vx2aZr97/Dhnf9R KjSYabLY0eBSZoPLtYdV3UK0s2FW/hbzwh/W5iK2Yn8B3s+4pclO0fNRomtDS3LuQLC2 XYV5QFqkXbT1GA7wisHGW4E7jDAGIdeqJA60CbQvhnSljnvWxhyEEE8JYu5GndFwTnsh ZP+fC+N9JAhsYorGb6NyRTUf6RGO4Awym/XU1lpRNebaMCcujmuyCq5zAp6/Ut+F+H8e hRGw== X-Gm-Message-State: AOAM53227x6PPoIr4tuVhS7Itme4iODL9l0SMU7vspiWIq78mAY8Pl76 /36B5Ea28aKch+qcpbpaGkQ= X-Google-Smtp-Source: ABdhPJz/1KviqTBRdN/i5UkhkmvBZcT/WLY0X946jW+qeuJ5XzPMKystUxYRygTOw/VWf03P2lmxzg== X-Received: by 2002:adf:cf05:: with SMTP id o5mr41843863wrj.325.1636922654132; Sun, 14 Nov 2021 12:44:14 -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 i17sm13339707wmq.48.2021.11.14.12.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Nov 2021 12:44:13 -0800 (PST) Message-ID: <48018e12484d19466d9c6f253a8d7ebeae93e947.camel@gmail.com> From: Liliana Marie Prikler Date: Sun, 14 Nov 2021 21:44:11 +0100 In-Reply-To: <20211114130409.49241-2-philip@philipmcgrath.com> References: <20211114125830.45427-1-philip@philipmcgrath.com> <20211114130409.49241-1-philip@philipmcgrath.com> <20211114130409.49241-2-philip@philipmcgrath.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 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=1636922718; 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=UwClZr4hyl5pH/iS3pEuOMGgq4vG7OlSKei5DkFZuFU=; b=rGe18mx5cp9n2XTkOUEubVSkpT2lNSmcUBS7THvJy4pa7vA9EY9PZhALWqGr9osCeoCPFC 8p2mf6yBKjBH//IEo0S21ijZDBCJQHREXnBlGMNlfUa/LH9uQPAnNshQKbuAw7/Z9hj0O6 uhzCyy4OVNPChB+pxO2rdhFiLRdx7RRUbsVdr/zR/zuufTQuTqWRH5DTMggYnjfQDJ0uRS Z6C2PCHRsdhchdqRxdDvbAxkzbQttsK+J2xhY7kgtMpRRNY4Ff7Pdeot8GQJUeiZ7boSy/ LfFUWrHLqjet5xJH5o5uvIojp46FMfA5pYI/6sfSgWOLIYpR5eHEEIvIWmJR9Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1636922718; a=rsa-sha256; cv=none; b=WX690/TiGvVH6p+ukUVUbZP7AGFwBOd/d82VPmWD6SzAZtFUtN8shHY5yFTT23ava+k0ZY I/dPZKyUBVwqU0Bm5XJOrH4prFR24JMrf+kkQdvcbM+RZb+i48uoI8PvA15HTPsdOocgAF PC1/hVTNa8qXFamJ55EwA8GFineddLCisUgCn/yCGmP6EkgNBNiovQgwjZjZPSo7HoUrEK v1jCzB0T3hcdglVXl/AckFRyEhPpXtLsrJjsxUohgo5hwHdXsIPjTr8cAZy7N3/oc4Sxxj MO/ewHsNcOzI9Rpmp0VX/gmCua1oNZkzfsBquQOYRWqr2iBxi5YrbRJypJGK6g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=pGWCUoAM; 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.34 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=pGWCUoAM; 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: 7A4869ECC X-Spam-Score: -0.34 X-Migadu-Scanner: scn0.migadu.com X-TUID: iNKAI5MHlcRR Hi Philip Am Sonntag, den 14.11.2021, 08:04 -0500 schrieb Philip McGrath: > * gnu/packages/node.scm (node)[arguments]: Replace 'patch-npm-shebang > and 'patch-node-shebang with a new 'patch-nested-shebangs that also > handles node-gyp and other shebangs under "/lib/node_modules". > [inputs]: Add Python for node-gyp as "python-for-target". > (node-lts)[inputs]: Likewise. > (libnode)[arguments]: Adjust to delete 'patch-nested-shebangs rather > than 'patch-npm-shebang and 'patch-node-shebang. > * guix/build-system/node.scm (lower): Add optional #:python argument > and corresponding implicit input. Add the version of libuv used > as an input to the #:node package as a new implicit input. > * guix/build/node-build-system.scm (set-node-gyp-paths): New > function. Sets the "npm_config_nodedir" and "npm_config_python" > environment variables. Adds the "node-gyp-bin" directory to "PATH". > (configure-gyp): New function. Run `node-gyp configure` if we see > a `binding.gyp` file. > (%standard-phases): Add 'set-node-gyp-paths after 'set-paths. > Add 'configure-gyp after 'configure. > > Co-authored-by: Pierre Langlois Looking at this patch, it does *a lot* at once and could probably be separated into more than one. Particularly, I'd suggest providing capabilities in node-build-system first, then switching over to the new thing in node. > [...] > --- a/guix/build-system/node.scm > +++ b/guix/build-system/node.scm > @@ -1,6 +1,8 @@ > ;;; GNU Guix --- Functional package management for GNU > ;;; Copyright © 2016 Jelle Licht > ;;; Copyright © 2019 Timothy Sample > +;;; Copyright © 2021 Pierre Langlois > +;;; Copyright © 2021 Philip McGrath > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -24,6 +26,7 @@ (define-module (guix build-system node) > #:use-module (guix search-paths) > #:use-module (guix build-system) > #:use-module (guix build-system gnu) > + #:use-module (guix build-system python) > #:use-module (ice-9 match) > #:export (%node-build-system-modules > node-build > @@ -44,11 +47,12 @@ (define (default-node) > (define* (lower name > #:key source inputs native-inputs outputs system > target > (node (default-node)) > + (python (default-python)) ;; for node-gyp > #:allow-other-keys > #:rest arguments) > "Return a bag for NAME." > (define private-keywords > - '(#:source #:target #:node #:inputs #:native-inputs)) > + '(#:source #:target #:node #:python #:inputs #:native-inputs)) > > (and (not target) ;XXX: no cross-compilation > (bag > @@ -58,10 +62,13 @@ (define private-keywords > `(("source" ,source)) > '()) > ,@inputs > - > ;; Keep the standard inputs of 'gnu-build- > system'. > ,@(standard-packages))) > (build-inputs `(("node" ,node) > + ("python" ,python) > + ;; We don't always need libuv, but the libuv > and > + ;; node versions need to match: > + ("libuv" ,@(assoc-ref (package-inputs node) > "libuv")) > ,@native-inputs)) > (outputs outputs) > (build node-build) Will this python input always or often enough be needed? What's the build system ratio on node like, gyp vs. anything else, particularly with packages close to the node core? > diff --git a/guix/build/node-build-system.scm b/guix/build/node- > build-system.scm > index 70a367618e..6aeb0149dd 100644 > --- a/guix/build/node-build-system.scm > +++ b/guix/build/node-build-system.scm > @@ -2,6 +2,8 @@ > ;;; Copyright © 2015 David Thompson > ;;; Copyright © 2016, 2020 Jelle Licht > ;;; Copyright © 2019, 2021 Timothy Sample > +;;; Copyright © 2021 Pierre Langlois > +;;; Copyright © 2021 Philip McGrath > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -46,6 +48,19 @@ (define (set-home . _) > (format #t "set HOME to ~s~%" (getenv "HOME"))))))) > #t) > > +(define* (set-node-gyp-paths #:key inputs #:allow-other-keys) > + "Initialize environment variables needed for building native > addons." > + (setenv "npm_config_nodedir" (assoc-ref inputs "node")) > + (setenv "npm_config_python" (assoc-ref inputs "python")) > + (setenv "PATH" > + (string-append (getenv "PATH") > + ":" > + ;; Put this at the end to make it easier to > override, > + ;; just in case that should ever be > necessary: > + (assoc-ref inputs "node") > + "/lib/node_modules/npm/bin/node-gyp-bin")) > + #t) > + Is this a necessary step to build node modules? If not can we skip this step when packages don't need gyp? > (define (module-name module) > (let* ((package.json (string-append module "/package.json")) > (package-meta (call-with-input-file package.json read- > json))) > @@ -101,6 +116,12 @@ (define* (configure #:key outputs inputs > #:allow-other-keys) > (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." > + (if (file-exists? "binding.gyp") > + (invoke (which "node-gyp") "configure") > + #t)) > + You might want to make this part of configure itself, though I'm not sure what the consensus is there when mixing different build system styles. (invoke (which ...) ) is also a pretty rare pattern, used in only four locations so far. Also, while better than the previous thing in that it actually checks whether we have something gyp-esque at hand, I'd still prefer users being able to not run this portion through some flag. See e.g. #:use- setuptools? in python or #:glib-or-gtk? in meson. Cheers