[PATCH] gnu: Add fnlfmt.

  • Done
  • quality assurance status badge
Details
3 participants
  • Brandon Lucas
  • Ludovic Courtès
  • Maxime Devos
Owner
unassigned
Submitted by
Brandon Lucas
Severity
normal
B
B
Brandon Lucas wrote on 22 Jan 2022 22:28
(address . guix-patches@gnu.org)(name . Brandon Lucas)(address . br@ndon.dk)
20220122212723.396566-1-br@ndon.dk
* gnu/packages/lua.scm (fnlfmt): New variable.
---
gnu/packages/lua.scm | 46 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)

Toggle diff (61 lines)
diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index 99f09a26f1..50f97c3912 100644
--- a/gnu/packages/lua.scm
+++ b/gnu/packages/lua.scm
@@ -15,6 +15,7 @@
;;; Copyright © 2020 Paul A. Patience <paul@apatience.com>
;;; Copyright © 2021 Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com>
;;; Copyright © 2021 Greg Hogan <code@greghogan.com>
+;;; Copyright © 2022 Brandon Lucas <br@ndon.dk>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1208,3 +1209,48 @@ (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"))))
+ (build-system gnu-build-system)
+ (arguments
+ '(#:test-target "test"
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (add-before 'build 'patch-makefile
+ ;; Use input fennel instead of bundled fennel.
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "Makefile"
+ (("./fennel") (search-input-file inputs "/bin/fennel")))))
+ (add-after 'build 'patch-fnlfmt
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "fnlfmt"
+ (("/usr/bin/env .*lua") (search-input-file 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"))))))))
+ (inputs (list fennel))
+ (propagated-inputs (list lua))
+ (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+)))
--
2.34.0
M
M
Maxime Devos wrote on 22 Jan 2022 22:33
eb1843655122fc92a16e55b95ef3330a2adb42e7.camel@telenet.be
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
Toggle quote (8 lines)
> + (add-after 'build 'patch-fnlfmt
> + (lambda* (#:key inputs #:allow-other-keys)
> + (substitute* "fnlfmt"
> + (("/usr/bin/env .*lua") (search-input-file inputs
> "/bin/lua")))))
> + (inputs (list fennel))
> + (propagated-inputs (list lua))

Given that the shebang in 'fnlfmt' has been patched appropriately, what
is the point of propagating here? Can lua be moved to 'inputs'?

Greetings,
Maxime
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYex4PBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7lMpAP99cEItetY+UwUP6MoNYFPfDLzS
cfRPs+ddim0SWGsRtgD/SKmoGbKQk1uvmqAEtCtD+Qv3sEODetj3ENtfC5OtmAI=
=13Dy
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 22 Jan 2022 22:39
e544e9bbab3302a531536a87642786a9caefa7cc.camel@telenet.be
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
Toggle quote (5 lines)
> +           ;; Use input fennel instead of bundled fennel.
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (substitute* "Makefile"
> +               (("./fennel") (search-input-file inputs "/bin/fennel")))))

'fennel' is in native-inputs, not inputs. For historical reasons,
the 'inputs' in the phase contains both the native-inputs and native-
inputs in the phase is #false when compiling natively, which can be
confusing (maybe that can be addressed someday).

I suggest:

(lambda* (#:key native-inputs inputs #:allow-other-keys)
(substitute* "Makefile"
(("./fennel")
(search-input-file (or native-inputs inputs) "/bin/fennel")))))
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYex5qhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7tbNAQDsWoCHjOTGaKCNE7Wpb48QGmjg
OJGNZ8+AMxiESuwb4QEAiqlXpHVcjYxxQ54jQ35S4qMeQMOopUIa/G5QEFkShQE=
=+EyK
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 22 Jan 2022 22:41
34a56a4c15309189884b660d737d10f4898e8200.camel@telenet.be
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
Toggle quote (5 lines)
> +         (add-after 'build 'patch-fnlfmt
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (substitute* "fnlfmt"
> +               (("/usr/bin/env .*lua") (search-input-file inputs "/bin/lua")))))

I think modifying the Makefile (in patch-makefile) to replace the
/usr/bin/env lua there would be a little simpler.
M
M
Maxime Devos wrote on 22 Jan 2022 22:43
4a5b129ce0c76476160d540261d0cd1307a63362.camel@telenet.be
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
Toggle quote (21 lines)
> +    (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"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     '(#:test-target "test"
> +       #:phases
> +       (modify-phases %standard-phases
> +         (delete 'configure)
> +         (add-before 'build 'patch-makefile
> +           ;; Use input fennel instead of bundled fennel.
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (substitute* "Makefile"
> +               (("./fennel") (search-input-file inputs "/bin/fennel")))))

Unbundling is conventionally done using an origin snippet.
See ‘17.4.5 Snippets versus Phases’ in the manual.
M
M
Maxime Devos wrote on 22 Jan 2022 22:46
c7b62fb3512064f5d72712e936bc07460e3b5078.camel@telenet.be
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
Toggle quote (3 lines)
> +                    (url "https://git.sr.ht/~technomancy/fnlfmt")
> +                    (commit version)))

Upstream appears to be violating the Expat license of the bundled
'fennel' by not including a copy of the Expat license:

[...], subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies of substantial portions of the Software.

[...]

Can this be adddressed (upstream)?

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYex7IxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7qdlAQCa1MBxDJjDTX44/CY25wOxGWQ2
pYSFSpECToYlJU+b3gD+PUcw13dp9cD5zGHO8wkTlSMh/Tvzir57ONXaogUp+gY=
=TVQk
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 22 Jan 2022 22:53
617c5d3165f9c1693809c2ab3b0c49843f083369.camel@telenet.be
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
Toggle quote (2 lines)
> +    (license license:lgpl3+)))

The lgpl3+ is by itself not a complete license, it is structured as a
few exceptions under conditions to the gpl. The lgpl3 even asks you to
include both a copy of the GPL3 and the LGPL3 license text:


b) Accompany the Combined Work with a copy of the GNU GPL and this
license document.

Strictly speaking that's only for ‘Combined works’, and I don't expect
any trouble in practice. However, it would be nice to do things
properly. Would you be up to asking upstream to include a copy of the
GPL as well (which upstream isn't doing currently)?

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYex82RccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7lL0AP9Io5uVr/Ae+ILtAasJDSgw6wU6
CB9ei8O/GFLHq0dBOwEApIXW0XL7aSGFEyhk5C3jYRpfKn/LrSLhu0v/gpnYFQc=
=OE+O
-----END PGP SIGNATURE-----


B
B
Brandon Lucas wrote on 23 Jan 2022 01:16
[PATCH v2 1/2] gnu: Add fnlfmt.
(address . 53456@debbugs.gnu.org)(name . Brandon Lucas)(address . br@ndon.dk)
20220123001509.484504-1-br@ndon.dk
* 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(+)

Toggle diff (93 lines)
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 <paul@apatience.com>
;;; Copyright © 2021 Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com>
;;; Copyright © 2021 Greg Hogan <code@greghogan.com>
+;;; Copyright © 2022 Brandon Lucas <br@ndon.dk>
;;;
;;; 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+)))
--
2.34.0
B
B
Brandon Lucas wrote on 23 Jan 2022 01:19
[PATCH v2 2/2] gnu: fennel: Update to 03c1c95.
(address . 53456@debbugs.gnu.org)(name . Brandon Lucas)(address . br@ndon.dk)
20220123001509.484504-2-br@ndon.dk
* gnu/packages/lua.scm (fennel): Update to 03c1c95.
---
In order to properly wrap fnlfmt with LUA_PATH to fennel, we need to
know which /share/lua/x.x dir fennel got installed under.

The 1.0.0 release had a bug where fennel installed under 5.4 no matter
what lua was used to compile it. There has since been an update that
corrects this issue, so we can rely on the version of the lua input to
determine where the fennel.lua file got installed to.

gnu/packages/lua.scm | 66 +++++++++++++++++++++++---------------------
1 file changed, 34 insertions(+), 32 deletions(-)

Toggle diff (81 lines)
diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index 1543d7bd11..568505a457 100644
--- a/gnu/packages/lua.scm
+++ b/gnu/packages/lua.scm
@@ -1175,42 +1175,44 @@ (define-public emilua
(license license:boost1.0)))

(define-public fennel
- (package
- (name "fennel")
- (version "1.0.0")
- (source (origin
- (method git-fetch)
- (uri (git-reference
- (url "https://git.sr.ht/~technomancy/fennel")
- (commit version)))
- (file-name (git-file-name name version))
- (sha256
- (base32
- "0d4rpf0f2aqxlca3kxrbhjjhf1knhiz8ccwlx8xid05mc16la70y"))))
- (build-system gnu-build-system)
- (arguments
- '(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
- #:tests? #t ; even on cross-build
- #:test-target "test"
- #:phases
- (modify-phases %standard-phases
- (delete 'configure)
- (add-after 'build 'patch-fennel
+ (let ((commit "03c1c95f2a79e45a9baf607f96a74c693b8b70f4")
+ (revision "0"))
+ (package
+ (name "fennel")
+ (version (git-version "1.0.0" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.sr.ht/~technomancy/fennel")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1znp38h5q819gvcyl248zwvjsljfxdxdk8n82fnj6lyibiiqzgvx"))))
+ (build-system gnu-build-system)
+ (arguments
+ '(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
+ #:tests? #t ; even on cross-build
+ #:test-target "test"
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (add-after 'build 'patch-fennel
(lambda* (#:key inputs #:allow-other-keys)
- (substitute* "fennel"
- (("/usr/bin/env .*lua")
- (search-input-file inputs "/bin/lua")))))
- (delete 'check)
- (add-after 'install 'check
+ (substitute* "fennel"
+ (("/usr/bin/env .*lua")
+ (search-input-file inputs "/bin/lua")))))
+ (delete 'check)
+ (add-after 'install 'check
(assoc-ref %standard-phases 'check)))))
- (inputs (list lua))
- (home-page "https://fennel-lang.org/")
- (synopsis "Lisp that compiles to Lua")
- (description
- "Fennel is a programming language that brings together the speed,
+ (inputs (list lua))
+ (home-page "https://fennel-lang.org/")
+ (synopsis "Lisp that compiles to Lua")
+ (description
+ "Fennel is a programming language that brings together the speed,
simplicity, and reach of Lua with the flexibility of a Lisp syntax and macro
system.")
- (license license:expat)))
+ (license license:expat))))

(define-public fnlfmt
(package
--
2.34.0
M
M
Maxime Devos wrote on 23 Jan 2022 12:05
Re: [bug#53456] [PATCH v2 1/2] gnu: Add fnlfmt.
10b95bc32c2b1d34bd6fa487f745ff6ef5660863.camel@telenet.be
Brandon Lucas schreef op zo 23-01-2022 om 00:16 [+0000]:
Toggle quote (3 lines)
> +                   (delete-file-recursively "fennel")
> +                   (delete-file-recursively "fennel.lua")

This is not wrong, but 'fennel' and 'fennel.lua' are regular files and
not directories, so (delete-file "fennel") (delete-file "fennel.lua")
would be sufficient.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYe02aRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7vbZAP9OTfzqdr0noM/5PVkltPZ1AFIZ
6Q0SXQoNeyfIqGD9QgD/WcT4H6sFGu3sg9HeaDQOeoOWulftJ4NURpCtyistOwg=
=f7hb
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 23 Jan 2022 12:11
bc3856d2ea3a5116bbb747afc0b32c67e341e8da.camel@telenet.be
Brandon Lucas schreef op zo 23-01-2022 om 00:16 [+0000]:
Toggle quote (2 lines)
> +    (inputs (list bash-minimal lua fennel))

'fennel' is used as a tool run during building
so it needs to be in native-inputs. It is also used as a kind of
library (see LUA_PATH in 'wrap' phase), so it needs to be in
native-inputs as well.

Summarised: 'fennel' needs to be in both inputs and native-inputs.

As a test, you can try to cross-compile fnlfmt:

# warning: this will first build a cross-compiler wich will take a lot
# of time
$ ./pre-inst-env guix build fnlfmt --target=aarch64-linux-gnu

It is not guaranteed that if it builds, it will work, but it is a
useful test.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYe038RccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7mZTAPwO4rx6MYFlL6MAAT5VnxB97gjs
3ssfFCp08bDYx0MdTAD+KcQ/jNBeu32oVBXDRZ+fcGrcWELbI/8N3wplNaDutgA=
=c5jS
-----END PGP SIGNATURE-----


B
B
Brandon Lucas wrote on 23 Jan 2022 13:14
[PATCH v3 1/2] gnu: Add fnlfmt.
(address . 53456@debbugs.gnu.org)(name . Brandon Lucas)(address . br@ndon.dk)
20220123121405.1123976-1-br@ndon.dk
* 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(+)

Toggle diff (94 lines)
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 <paul@apatience.com>
;;; Copyright © 2021 Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com>
;;; Copyright © 2021 Greg Hogan <code@greghogan.com>
+;;; Copyright © 2022 Brandon Lucas <br@ndon.dk>
;;;
;;; 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+)))
--
2.34.0
B
B
Brandon Lucas wrote on 23 Jan 2022 13:14
[PATCH v3 2/2] gnu: fennel: Update to 03c1c95.
(address . 53456@debbugs.gnu.org)(name . Brandon Lucas)(address . br@ndon.dk)
20220123121405.1123976-2-br@ndon.dk
* gnu/packages/lua.scm (fennel): Update to 03c1c95.
---
gnu/packages/lua.scm | 66 +++++++++++++++++++++++---------------------
1 file changed, 34 insertions(+), 32 deletions(-)

Toggle diff (81 lines)
diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index 2250990af9..4286475a2c 100644
--- a/gnu/packages/lua.scm
+++ b/gnu/packages/lua.scm
@@ -1175,42 +1175,44 @@ (define-public emilua
(license license:boost1.0)))

(define-public fennel
- (package
- (name "fennel")
- (version "1.0.0")
- (source (origin
- (method git-fetch)
- (uri (git-reference
- (url "https://git.sr.ht/~technomancy/fennel")
- (commit version)))
- (file-name (git-file-name name version))
- (sha256
- (base32
- "0d4rpf0f2aqxlca3kxrbhjjhf1knhiz8ccwlx8xid05mc16la70y"))))
- (build-system gnu-build-system)
- (arguments
- '(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
- #:tests? #t ; even on cross-build
- #:test-target "test"
- #:phases
- (modify-phases %standard-phases
- (delete 'configure)
- (add-after 'build 'patch-fennel
+ (let ((commit "03c1c95f2a79e45a9baf607f96a74c693b8b70f4")
+ (revision "0"))
+ (package
+ (name "fennel")
+ (version (git-version "1.0.0" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.sr.ht/~technomancy/fennel")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1znp38h5q819gvcyl248zwvjsljfxdxdk8n82fnj6lyibiiqzgvx"))))
+ (build-system gnu-build-system)
+ (arguments
+ '(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
+ #:tests? #t ; even on cross-build
+ #:test-target "test"
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (add-after 'build 'patch-fennel
(lambda* (#:key inputs #:allow-other-keys)
- (substitute* "fennel"
- (("/usr/bin/env .*lua")
- (search-input-file inputs "/bin/lua")))))
- (delete 'check)
- (add-after 'install 'check
+ (substitute* "fennel"
+ (("/usr/bin/env .*lua")
+ (search-input-file inputs "/bin/lua")))))
+ (delete 'check)
+ (add-after 'install 'check
(assoc-ref %standard-phases 'check)))))
- (inputs (list lua))
- (home-page "https://fennel-lang.org/")
- (synopsis "Lisp that compiles to Lua")
- (description
- "Fennel is a programming language that brings together the speed,
+ (inputs (list lua))
+ (home-page "https://fennel-lang.org/")
+ (synopsis "Lisp that compiles to Lua")
+ (description
+ "Fennel is a programming language that brings together the speed,
simplicity, and reach of Lua with the flexibility of a Lisp syntax and macro
system.")
- (license license:expat)))
+ (license license:expat))))

(define-public fnlfmt
(package
--
2.34.0
B
B
Brandon wrote on 23 Jan 2022 21:50
Re: [bug#53456] [PATCH] gnu: Add fnlfmt.
(name . Maxime Devos)(address . maximedevos@telenet.be)(address . 53456@debbugs.gnu.org)
G7KhmNJ5hHTGaUveZFN2rHr1mSzcK30G9vQ-4egU2p9bmAFGHrlPmZF3QGeJBND-BIhPf0iAGf0sYYd3qZykg1mEt5U3uXxwO5gbhMekq6E=@ndon.dk
<maximedevos@telenet.be> wrote:

Toggle quote (3 lines)
> Would you be up to asking upstream to include a copy of the
> GPL as well (which upstream isn't doing currently)?

Hi Maxime,

I wrote to upstream about this and the inclusion of the expat
license, and the author has updated the repo to include both
the full GPL text as well as the Expat license.

Kind regards,
Brandon.
L
L
Ludovic Courtès wrote on 26 Jan 2022 16:52
Re: bug#53456: [PATCH] gnu: Add fnlfmt.
(name . Brandon Lucas)(address . br@ndon.dk)
87a6fih4v2.fsf_-_@gnu.org
Hi,

Brandon Lucas <br@ndon.dk> skribis:

Toggle quote (2 lines)
> * gnu/packages/lua.scm (fnlfmt): New variable.

[...]

Toggle quote (2 lines)
> * gnu/packages/lua.scm (fennel): Update to 03c1c95.

Applied.

Since we normally don’t package snapshots, I took the liberty to add the
justification you gave as a comment in next to the commit definition.

Thank you, and thanks Maxime for the thorough review!

Ludo’.
Closed
?