From patchwork Thu Nov 9 16:26:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Philip McGrath X-Patchwork-Id: 56138 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 967A427BBE2; Thu, 9 Nov 2023 16:27:55 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4904827BBE9 for ; Thu, 9 Nov 2023 16:27:53 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r17sP-0007HL-9N; Thu, 09 Nov 2023 11:27:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r17sM-0007FR-LK for guix-patches@gnu.org; Thu, 09 Nov 2023 11:27:26 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r17sM-00067E-DN for guix-patches@gnu.org; Thu, 09 Nov 2023 11:27:26 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r17sw-0004as-Ek; Thu, 09 Nov 2023 11:28:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67019] [PATCH 03/16] gnu: Add lessc. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: philip@philipmcgrath.com, julien@lepiller.eu, pukkamustard@posteo.net, guix-patches@gnu.org Resent-Date: Thu, 09 Nov 2023 16:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67019 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67019@debbugs.gnu.org Cc: Philip McGrath , Philip McGrath , Julien Lepiller , pukkamustard X-Debbugs-Original-Xcc: Philip McGrath , Julien Lepiller , pukkamustard Received: via spool by 67019-submit@debbugs.gnu.org id=B67019.169954727917630 (code B ref 67019); Thu, 09 Nov 2023 16:28:02 +0000 Received: (at 67019) by debbugs.gnu.org; 9 Nov 2023 16:27:59 +0000 Received: from localhost ([127.0.0.1]:48475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r17st-0004aH-19 for submit@debbugs.gnu.org; Thu, 09 Nov 2023 11:27:59 -0500 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:49067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r17sq-0004Zl-Uk for 67019@debbugs.gnu.org; Thu, 09 Nov 2023 11:27:58 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id EDC823200A47; Thu, 9 Nov 2023 11:27:11 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 09 Nov 2023 11:27:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= philipmcgrath.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1699547231; x=1699633631; bh=X8 T714oE9ZipKjkX5kE5e32FxrrxamzQp48QtiM0e6g=; b=2eblErYI8SGjrYgUud D9CG72SfcRpcdGQNIRPbLQHn4VqLqPp6bhQqVf8O2U8TcOI5WBdtfWbtL9/6A00x Lodx9OYbs67DiKh1R1ZkSmjIPxq+gyyZpPruJHqRKSvQJI1EQJFXoNtFIMuZLGYn 2inAHiZzOgkt/mOWksKpxWpH6A8Y9Gx4ObFMyXCkCsClDifzbL1JP/0eaCoQNE/A Tdv0xyrmL3SbMWS4RHvjv3YOsOQAPyxSOalY8RR0Ado8c3fr7yZ41s7XZ/uToYUr XcuA6FH1hoTKxTnJIqHgMmfPLBZNxKS4pN418vIP+fIQwzq8sVOavKbXr9XR4j+V 4zhA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1699547231; x=1699633631; bh=X8T714oE9ZipKjkX5kE5e32FxrrxamzQp48 QtiM0e6g=; b=ETpuIjVtnB9lDNnCqQ17SsmUJpEgFjCIrMzdAyGBjYIDVHLhCFI tbI9yy2OW6qJ5mIsG4vN1kairbq2RVIuhi0vrum4Bi04wyP8/zvCIUZZLj8tY2kq pGZrstZPhvwpKzrOQD1TkeNc03SZXyCSX1px8Dd4RdfkZ9lm6HX9LUmxWGdooOqT fauUGFQgz8g95+T7khjPJlMmkQ1dieniIUzMmfk6rIU4+D7Ao60X6cuEPNMK18Mj NQzKr2yxKQJ8+k2Ty0M8M//B+88bVXW13myY0dPqPoz8551MlzEnq4Ss5HXlr8wF k81h/KAiBvPg0/N7H6lkz0LC1j0Uwz5/g2w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddvuddgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfgggtgfesth ekredtredtjeenucfhrhhomheprfhhihhlihhpucfotgfirhgrthhhuceophhhihhlihhp sehphhhilhhiphhmtghgrhgrthhhrdgtohhmqeenucggtffrrghtthgvrhhnpefhgfekhf dtgfeitdetuefhvedvteefvdevuddtkefgvdevhfekveejuefgfeekheenucffohhmrghi nhepghhithhhuhgsrdgtohhmpdhlvghsshgtshhsrdhorhhgnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhhihhlihhpsehphhhilhhiphhm tghgrhgrthhhrdgtohhm X-ME-Proxy: Feedback-ID: i2b1146f3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 9 Nov 2023 11:27:10 -0500 (EST) From: Philip McGrath Date: Thu, 9 Nov 2023 11:26:25 -0500 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/web.scm (lessc): New variable. --- gnu/packages/web.scm | 187 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm index 66d09700db..8e22997957 100644 --- a/gnu/packages/web.scm +++ b/gnu/packages/web.scm @@ -64,6 +64,7 @@ ;;; Copyright © 2023 David Thompson ;;; Copyright © 2023 Christopher Howard ;;; Copyright © 2023 Felix Lechner +;;; Copyright © 2023 Philip McGrath ;;; ;;; This file is part of GNU Guix. ;;; @@ -98,6 +99,7 @@ (define-module (gnu packages web) #:use-module (guix build-system gnu) #:use-module (guix build-system go) #:use-module (guix build-system meson) + #:use-module (guix build-system node) #:use-module (guix build-system perl) #:use-module (guix build-system pyproject) #:use-module (guix build-system python) @@ -168,6 +170,7 @@ (define-module (gnu packages web) #:use-module (gnu packages ncurses) #:use-module (gnu packages networking) #:use-module (gnu packages node) + #:use-module (gnu packages node-xyz) #:use-module (gnu packages nss) #:use-module (gnu packages openldap) #:use-module (gnu packages openstack) @@ -2343,6 +2346,190 @@ (define-public sassc/libsass-3.5 "0830pjcvhzxh6yixj82x5k5r1xnadjqzi16kp53213icbly0r9ma"))))))) (properties '((hidden? . #t))))) +(define-public lessc + (package + (name "lessc") + (version "4.2.0") + (source + (origin (method git-fetch) + (uri (git-reference + (url "https://github.com/less/less.js") + (commit (string-append "v" version)))) + (sha256 + (base32 "1b6anlafk7lnayxy3vhsi474jcdah2ffaw2qyac5s2ibxb1wmr54")) + (snippet + #~(begin + (use-modules (guix build utils)) + (delete-file-recursively "packages/less/dist"))) + (file-name (git-file-name name version)))) + (build-system node-build-system) + (native-inputs (list esbuild)) + (inputs (list node-copy-anything)) + (arguments + (list + #:tests? #f ; many more dependencies + #:modules + `((guix build node-build-system) + (ice-9 match) + (guix build utils)) + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'chdir + (lambda args + (chdir "packages/less"))) + (add-after 'patch-dependencies 'delete-dependencies + (lambda args + (delete-dependencies + '(;; dependencies + "parse-node-version" ; patched out + "tslib" ; probably not needed w/ esbuild + ;; devDependencies + "@less/test-data" + "@less/test-import-module" + "@rollup/plugin-commonjs" + "@rollup/plugin-json" + "@rollup/plugin-node-resolve" + "@typescript-eslint/eslint-plugin" + "@typescript-eslint/parser" + "benny" + "bootstrap-less-port" + "chai" + "cross-env" + "diff" + "eslint" + "fs-extra" + "git-rev" + "globby" + "grunt" + "grunt-cli" + "grunt-contrib-clean" + "grunt-contrib-connect" + "grunt-eslint" + "grunt-saucelabs" + "grunt-shell" + "html-template-tag" + "jit-grunt" + "less-plugin-autoprefix" + "less-plugin-clean-css" + "minimist" + "mocha" + "mocha-headless-chrome" + "mocha-teamcity-reporter" + "nock" + "npm-run-all" + "performance-now" + "phin" + "promise" + "read-glob" + "resolve" + "rollup" + "rollup-plugin-terser" + "rollup-plugin-typescript2" + "semver" + "shx" + "time-grunt" + "ts-node" + "typescript" + "uikit" + ;; optionalDependencies + "errno" + "graceful-fs" + "image-size" + "make-dir" + "mime" + "needle" + "source-map")))) + (add-after 'delete-dependencies 'avoid-parse-node-version + (lambda args + (define version + #$(package-version this-package)) + (substitute* "src/less/index.js" + (("import [{] version [}]" orig) + (string-append "// " orig)) + (("import parseVersion from 'parse-node-version';" orig) + (string-append "// " orig)) + (("const v = parseVersion[(]`v\\$[{]version[}]`[)];" orig) + (string-append "// " orig)) + (("(version: )(\\[v\\.major, v\\.minor, v\\.patch],)" _ lhs rhs) + (string-append + lhs + "[" + (string-join + (list-head (string-split + version (char-set-complement char-set:digit)) + 3) + ", ") + "], // " + rhs))))) + (add-after 'avoid-parse-node-version 'do-not-target-es5 + (lambda args + ;; esbuild can't compile all features to ES5 + (with-atomic-json-file-replacement "tsconfig.json" + (match-lambda + (('@ . alist) + (cons '@ + (map (match-lambda + (("compilerOptions" '@ . alist) + `("scripts" @ ,@(filter (match-lambda + (("target" "ES5") + #f) + (_ + #t)) + alist))) + (other + other)) + alist))))))) + (add-after 'do-not-target-es5 'patch-build-script + (lambda args + (define new-build-script + (string-join + `("esbuild" + "--platform=node" + "--format=cjs" + "--outdir=lib" + ,@(find-files "src/less" "\\.js$") + ,@(find-files "src/less-node" "\\.js$")))) + (with-atomic-json-file-replacement "package.json" + (match-lambda + (('@ . alist) + (cons '@ + (map (match-lambda + (("scripts" @ . alist) + `("scripts" @ ,@(map (match-lambda + (("build" . _) + (cons "build" + new-build-script)) + (other + other)) + alist))) + (other + other)) + alist))))))) + (add-after 'build 'build-browser + (lambda args + (invoke "esbuild" + "--bundle" + "--platform=browser" + "--format=cjs" + "--outfile=dist/less.js" + "src/less-browser/bootstrap.js") + (invoke "esbuild" + "--bundle" + "--minify" + "--sourcemap" + "--platform=browser" + "--format=cjs" + "--outfile=dist/less.min.js" + "src/less-browser/bootstrap.js")))))) + (home-page "https://lesscss.org") + (synopsis "Compiler for @acronym{Less} @acronym{CSS} language extension") + ;; XXX: @abbr{} seems better for Less (which is always capitalized that + ;; way), but it is rejected as invalid Texinfo markup here. + (description "@acronym{Less, Leaner Style Sheets} is a +backwards-compatible language extension for @acronym{CSS}. This package +provides @command{lessc}, which compiles Less files to plain @acronym{CSS}.") + (license license:asl2.0))) + (define-public perl-apache-logformat-compiler (package