From patchwork Sun Jan 23 00:16:07 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Patchwork-Submitter: Brandon
X-Patchwork-Id: 36756
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 B050D27BBEA; Sun, 23 Jan 2022 00:17:35 +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=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID,
DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,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 1EC0827BBE9
for ; Sun, 23 Jan 2022 00:17:35 +0000 (GMT)
Received: from localhost ([::1]:50180 helo=lists1p.gnu.org)
by lists.gnu.org with esmtp (Exim 4.90_1)
(envelope-from )
id 1nBQZa-0000iC-6R
for patchwork@mira.cbaines.net; Sat, 22 Jan 2022 19:17:34 -0500
Received: from eggs.gnu.org ([209.51.188.92]:59406)
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from )
id 1nBQZ4-0000hp-Tb
for guix-patches@gnu.org; Sat, 22 Jan 2022 19:17:03 -0500
Received: from debbugs.gnu.org ([209.51.188.43]:45301)
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.90_1) (envelope-from )
id 1nBQZ4-0008DH-KD
for guix-patches@gnu.org; Sat, 22 Jan 2022 19:17:02 -0500
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
(envelope-from ) id 1nBQZ4-000361-FK
for guix-patches@gnu.org; Sat, 22 Jan 2022 19:17:02 -0500
X-Loop: help-debbugs@gnu.org
Subject: [bug#53456] [PATCH v2 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 00:17:02 +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.164289698511854
(code B ref 53456); Sun, 23 Jan 2022 00:17:02 +0000
Received: (at 53456) by debbugs.gnu.org; 23 Jan 2022 00:16:25 +0000
Received: from localhost ([127.0.0.1]:38204 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from )
id 1nBQYT-000357-13
for submit@debbugs.gnu.org; Sat, 22 Jan 2022 19:16:25 -0500
Received: from mail-4018.proton.ch ([185.70.40.18]:16965)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from
) id 1nBQYP-00034q-24
for 53456@debbugs.gnu.org; Sat, 22 Jan 2022 19:16:23 -0500
Date: Sun, 23 Jan 2022 00:16:07 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ndon.dk;
s=protonmail; t=1642896973;
bh=L5ubtRpUtvTvTqV5TRPXD8UWvxEbNXlzUkrQMKoePOY=;
h=Date:To:From:Cc:Reply-To:Subject:Message-ID:From:To:Cc;
b=wm8TDiDRQJDNlP+nFfICD8kOtKG7lxlRa7wqThpBCTjPu0FeJM9L6OHZPvVA+jPt+
d+YPWX7S1y4NmYSRsmxOVo9DSRXFg7mb2rpyixG7/bh8USmkMWaR4YL/1Yh2w+9ICQ
r6r2H6lSxg6Z3QA1WLz9Xbm97eQdiNQj9gWSaDBkZcwvd1rSOuEyXt+LxeXNAU7lCb
TDWT7vh6AFD37WC6sPJjk6rYGdhu//tH193Zpy4E2sv2012dN7aZSTE1CQU7NF8u5M
xLz5C8UVB818JaagfaofaM4WgBS8l2b2cstN58Mte6qPMHbNeBDUaYsplWnYZqV2f5
U4rRPUETDz+9Q==
From: Brandon Lucas
Message-ID: <20220123001509.484504-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.
---
Thank you for the review. I learned a lot. :)
I also realized that if I truly unbundle fennel from fnlfmt, I also need
to wrap it, so that it can load fennel at runtime. It only worked before
because I had failed to remove the fennel.lua file from the checkout.
I have tried to apply your other suggestions here as well.
I will also write to upstream and attempt to get the licensing
clarified.
gnu/packages/lua.scm | 65 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
--
2.34.0
diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index 99f09a26f1..1543d7bd11 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,65 @@ (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-recursively "fennel")
+ (delete-file-recursively "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 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+)))