diff mbox series

[bug#53456] gnu: Add fnlfmt.

Message ID 20220122212723.396566-1-br@ndon.dk
State Accepted
Headers show
Series [bug#53456] gnu: Add fnlfmt. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Brandon Jan. 22, 2022, 9:28 p.m. UTC
* gnu/packages/lua.scm (fnlfmt): New variable.
---
 gnu/packages/lua.scm | 46 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

--
2.34.0

Comments

M Jan. 22, 2022, 9:33 p.m. UTC | #1
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
> +         (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
M Jan. 22, 2022, 9:39 p.m. UTC | #2
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
> +           ;; 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")))))
M Jan. 22, 2022, 9:41 p.m. UTC | #3
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
> +         (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 Jan. 22, 2022, 9:43 p.m. UTC | #4
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
> +    (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 Jan. 22, 2022, 9:46 p.m. UTC | #5
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
> +                    (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.
M Jan. 22, 2022, 9:53 p.m. UTC | #6
Brandon Lucas schreef op za 22-01-2022 om 21:28 [+0000]:
> +    (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:

https://git.sr.ht/~technomancy/fnlfmt/tree/main/item/LICENSE#L91

   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.
Brandon Jan. 23, 2022, 8:50 p.m. UTC | #7
<maximedevos@telenet.be> wrote:

> 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.
diff mbox series

Patch

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+)))