From patchwork Sun Jan 23 12:14:30 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Patchwork-Submitter: Brandon
X-Patchwork-Id: 36764
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 41D6F27BBEA; Sun, 23 Jan 2022 12:15:54 +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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,
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 B6A0227BBE9
for ; Sun, 23 Jan 2022 12:15:53 +0000 (GMT)
Received: from localhost ([::1]:32780 helo=lists1p.gnu.org)
by lists.gnu.org with esmtp (Exim 4.90_1)
(envelope-from )
id 1nBbmi-00013F-R8
for patchwork@mira.cbaines.net; Sun, 23 Jan 2022 07:15:52 -0500
Received: from eggs.gnu.org ([209.51.188.92]:33998)
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from )
id 1nBblu-00012u-4u
for guix-patches@gnu.org; Sun, 23 Jan 2022 07:15:02 -0500
Received: from debbugs.gnu.org ([209.51.188.43]:45790)
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.90_1) (envelope-from )
id 1nBblt-0006gt-Rn
for guix-patches@gnu.org; Sun, 23 Jan 2022 07:15:01 -0500
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
(envelope-from ) id 1nBblt-00079q-No
for guix-patches@gnu.org; Sun, 23 Jan 2022 07:15:01 -0500
X-Loop: help-debbugs@gnu.org
Subject: [bug#53456] [PATCH v3 1/2] gnu: Add fnlfmt.
References: <20220122212723.396566-1-br@ndon.dk>
In-Reply-To: <20220122212723.396566-1-br@ndon.dk>
Resent-From: Brandon Lucas
Original-Sender: "Debbugs-submit"
Resent-CC: guix-patches@gnu.org
Resent-Date: Sun, 23 Jan 2022 12:15:01 +0000
Resent-Message-ID:
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 53456
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 53456@debbugs.gnu.org
Cc: Brandon Lucas
Received: via spool by 53456-submit@debbugs.gnu.org id=B53456.164294009227477
(code B ref 53456); Sun, 23 Jan 2022 12:15:01 +0000
Received: (at 53456) by debbugs.gnu.org; 23 Jan 2022 12:14:52 +0000
Received: from localhost ([127.0.0.1]:38691 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from )
id 1nBblk-000797-9n
for submit@debbugs.gnu.org; Sun, 23 Jan 2022 07:14:52 -0500
Received: from mail-4022.proton.ch ([185.70.40.22]:26225)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from
) id 1nBblf-00078m-2S
for 53456@debbugs.gnu.org; Sun, 23 Jan 2022 07:14:51 -0500
Date: Sun, 23 Jan 2022 12:14:30 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ndon.dk;
s=protonmail; t=1642940079;
bh=Pj0cR4NADSo8KN3Ux1nmLJ55/9Jns80B/Vy+5ZruOkU=;
h=Date:To:From:Cc:Reply-To:Subject:Message-ID:From:To:Cc;
b=XLJ5lmQE2NBwNUmgM+VddytjH9peQwYvytLWCfUomWXxKBluhPrO8GRL52wgOlFv5
XVshDMY90dbGDQlpRkMAKyuAg/GODBfgBx1AoaM7H9wVO8cZ3S9rUQk4t28JJxM9Ld
jYmcig54MWOdx3o91XKiE133QInyX6Yu4oAgpGu40rVs2Pi/U2Y8rXeqlflh7qP3e4
ADDhnpx9k4jnw9nkFKQk1w9JQB0HIqni2yukqR8M7x91Y+FyfttRCAUYvD93tjQcE3
lOKakg/43hwrTnnPNRVYEQD5h6tKSj4KGt9zRnUitZzMmXn0V7Be9LqR168/Z5Pfg+
+xKk48Q/74Dwg==
From: Brandon Lucas
Message-ID: <20220123121405.1123976-1-br@ndon.dk>
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: ,
Reply-To: Brandon Lucas
Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org
Sender: "Guix-patches"
X-getmail-retrieved-from-mailbox: Patches
* gnu/packages/lua.scm (fnlfmt): New variable.
---
You are right, fennel must be a native-input. Lua must be as well.
Thank you for the tip about cross-compiling. :)
I also simplified to delete-file as suggested.
gnu/packages/lua.scm | 66 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
--
2.34.0
diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index 99f09a26f1..2250990af9 100644
--- a/gnu/packages/lua.scm
+++ b/gnu/packages/lua.scm
@@ -15,6 +15,7 @@
;;; Copyright © 2020 Paul A. Patience
;;; Copyright © 2021 Vinícius dos Santos Oliveira
;;; Copyright © 2021 Greg Hogan
+;;; Copyright © 2022 Brandon Lucas
;;;
;;; This file is part of GNU Guix.
;;;
@@ -36,12 +37,14 @@ (define-module (gnu packages lua)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix git-download)
+ #:use-module (guix gexp)
#:use-module (guix utils)
#:use-module (guix build-system gnu)
#:use-module (guix build-system cmake)
#:use-module (guix build-system meson)
#:use-module (guix build-system trivial)
#:use-module (gnu packages)
+ #:use-module (gnu packages bash)
#:use-module (gnu packages boost)
#:use-module (gnu packages build-tools)
#:use-module (gnu packages glib)
@@ -1208,3 +1211,66 @@ (define-public fennel
simplicity, and reach of Lua with the flexibility of a Lisp syntax and macro
system.")
(license license:expat)))
+
+(define-public fnlfmt
+ (package
+ (name "fnlfmt")
+ (version "0.2.2")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.sr.ht/~technomancy/fnlfmt")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1rv0amqhy5ypi3pvxfaadn3k1cy4mjlc49wdzl2psz3i11w9gr36"))
+ (modules '((guix build utils)))
+ (snippet
+ #~(begin
+ ;; Use input fennel instead of bundled fennel.
+ (delete-file "fennel")
+ (delete-file "fennel.lua")
+ (substitute* "Makefile"
+ (("./fennel") "fennel"))))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (ice-9 match))
+ #:test-target "test"
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (add-before 'build 'patch-makefile
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ (substitute* "Makefile"
+ ;; Patch lua shebang that gets inserted to fnlfmt.
+ (("/usr/bin/env lua")
+ (search-input-file (or native-inputs inputs) "/bin/lua")))))
+ (replace 'install
+ ;; There is no install target; manually install the output file.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (bin (string-append out "/bin")))
+ (for-each (lambda (file)
+ (install-file file bin))
+ (find-files "." "fnlfmt")))))
+ (add-after 'install 'wrap
+ (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
+ (let* ((all-inputs (or native-inputs inputs))
+ (fnlfmt (assoc-ref outputs "out"))
+ (lua-version ,(version-major+minor (package-version lua)))
+ (fennel (assoc-ref all-inputs "fennel")))
+ (wrap-program (string-append fnlfmt "/bin/fnlfmt")
+ `("LUA_PATH" ";" suffix
+ (,(format #f "~a/share/lua/~a/?.lua" fennel lua-version))))
+ #t))))))
+ (inputs (list bash-minimal))
+ (native-inputs (list lua fennel))
+ (home-page "https://git.sr.ht/~technomancy/fnlfmt")
+ (synopsis "Automatic formatting of Fennel code")
+ (description
+ "Fnlfmt is a tool for automatically formatting Fennel code in a consistent
+way, following established lisp conventions.")
+ (license license:lgpl3+)))