diff mbox series

[bug#64840,12/12] gnu: Add elm-format.

Message ID 20230724202532.8993-12-distopico@riseup.net
State New
Headers show
Series Add elm-format. | expand

Commit Message

Distopico July 24, 2023, 8:23 p.m. UTC
* gnu/packages/elm.scm (elm-format): New variable.
---
 gnu/packages/elm.scm | 197 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 197 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/elm.scm b/gnu/packages/elm.scm
index a74d294ae5..5361634abb 100644
--- a/gnu/packages/elm.scm
+++ b/gnu/packages/elm.scm
@@ -2,6 +2,7 @@ 
 ;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
 ;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com>
 ;;; Copyright © 2022 jgart <jgart@dismail.de>
+;;; Copyright © 2023 Camilo Q.S. (Distopico) <distopico@riseup.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -384,6 +385,202 @@  (define-public elm-bytes
 and @code{DataView}.")
     (license license:bsd-3)))
 
+(define elm-format-avh4-lib
+  (let ((commit "b5cca4c26b473dab06e5d73b98148637e4770d45"))
+    (package
+      (name "elm-format-avh4-lib")
+      (version "0.0.0.1")
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/avh4/elm-format")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "04l1bn4w8q3ifd6mc4mfrqxfbihmqnpfjdn6gr0x2jqcasjbk0bi"))))
+      (build-system haskell-build-system)
+      (properties '((upstream-name . "avh4-lib") (hidden? #t)))
+      (arguments
+       ;; Require and use ghc-text but ghc doesn't detect it
+       `(#:configure-flags (list "--ghc-option=-Wno-error=unused-packages")
+         #:tests? #f
+         #:phases (modify-phases %standard-phases
+                    (add-after 'unpack 'enter-lib-subdirectory
+                      (lambda _
+                        (chdir "avh4-lib"))))))
+      (inputs (list ghc-pooled-io ghc-text ghc-relude))
+      (native-inputs (list ghc-tasty ghc-tasty-hunit ghc-tasty-hspec))
+      (home-page "https://github.com/avh4/elm-format/tree/main/avh4-lib")
+      (synopsis "Common code for elm-format packages")
+      (description
+       "This packages provides common code for @command{elm-format} haskell projects.")
+      (license license:bsd-3))))
+
+(define elm-format-test-lib
+  (let ((commit "b5cca4c26b473dab06e5d73b98148637e4770d45"))
+    (package
+      (name "elm-format-test-lib")
+      (version "0.0.0.1")
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/avh4/elm-format")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "04l1bn4w8q3ifd6mc4mfrqxfbihmqnpfjdn6gr0x2jqcasjbk0bi"))))
+      (build-system haskell-build-system)
+      (properties '((upstream-name . "elm-format-test-lib") (hidden? #t)))
+      (arguments
+       `(#:tests? #f
+         #:phases (modify-phases %standard-phases
+                    (add-after 'unpack 'enter-lib-subdirectory
+                      (lambda _
+                        (chdir "elm-format-test-lib"))))))
+      (inputs (list elm-format-avh4-lib ghc-split ghc-text))
+      (native-inputs (list ghc-hspec-golden ghc-hspec ghc-tasty-hspec
+                           ghc-tasty-hunit))
+      (home-page
+       "https://github.com/avh4/elm-format/tree/main/elm-format-test-lib")
+      (synopsis "Test helpers used by elm-format")
+      (description "This package provides elf-format helpers for test used by
+@command{elm-format}, elm-format-tests and elm-refactor-tests.")
+      (license license:bsd-3))))
+
+(define elm-format-markdown
+  (let ((commit "b5cca4c26b473dab06e5d73b98148637e4770d45"))
+    (package
+      (name "elm-format-markdown")
+      (version "0.0.0.1")
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/avh4/elm-format")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "04l1bn4w8q3ifd6mc4mfrqxfbihmqnpfjdn6gr0x2jqcasjbk0bi"))))
+      (build-system haskell-build-system)
+      (properties '((upstream-name . "elm-format-markdown") (hidden? #t)))
+      (arguments
+       `(#:tests? #f
+         #:phases (modify-phases %standard-phases
+                    (add-after 'unpack 'enter-lib-subdirectory
+                      (lambda _
+                        (chdir "elm-format-markdown"))))))
+      (inputs (list elm-format-avh4-lib ghc-split ghc-text))
+      (native-inputs (list ghc-hspec-golden ghc-tasty ghc-tasty-hunit
+                           ghc-tasty-hspec))
+      (home-page
+       "https://github.com/avh4/elm-format/blob/main/elm-format-markdown")
+      (synopsis "Markdown parsing for Elm documentation comments")
+      (description "This package provides an markdown parsing for Elm
+documentation comments used by @command{elm-format}.")
+      (license license:bsd-3))))
+
+(define elm-format-lib
+  (let ((commit "b5cca4c26b473dab06e5d73b98148637e4770d45"))
+    (package
+      (name "elm-format-lib")
+      (version "0.0.0.1")
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/avh4/elm-format")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "04l1bn4w8q3ifd6mc4mfrqxfbihmqnpfjdn6gr0x2jqcasjbk0bi"))))
+      (build-system haskell-build-system)
+      (properties '((upstream-name . "elm-format-lib") (hidden? #t)))
+      (arguments
+       `(#:tests? #f
+         #:phases (modify-phases %standard-phases
+                    (add-after 'unpack 'enter-lib-subdirectory
+                      (lambda _
+                        (chdir "elm-format-lib"))))))
+      (inputs
+       (list elm-format-avh4-lib
+             elm-format-markdown
+             ghc-optparse-applicative
+             ghc-aeson-2.1
+             ghc-bimap
+             ghc-relude
+             ghc-text))
+      (native-inputs
+       (list elm-format-test-lib
+             ghc-split
+             ghc-hspec
+             ghc-tasty
+             ghc-tasty-hspec
+             ghc-tasty-hunit))
+      (home-page "https://github.com/avh4/elm-format/blob/main/elm-format-lib")
+      (synopsis "Common code used by elm-format")
+      (description "This package provides elm-format library with common code
+used by @command{elm-format} and elm-refactor.")
+      (license license:bsd-3))))
+
+(define-public elm-format
+  (package
+    (name "elm-format")
+    (version "0.8.7")
+    (source (origin
+              (method git-fetch)
+              (file-name (git-file-name name version))
+              (uri (git-reference
+                    (url "https://github.com/avh4/elm-format")
+                    (commit version)))
+              (sha256
+               (base32
+                "04l1bn4w8q3ifd6mc4mfrqxfbihmqnpfjdn6gr0x2jqcasjbk0bi"))
+              (modules '((guix build utils)))
+              (snippet
+               '(begin
+                  ;; We don't build these library in this packages.
+                  (delete-file-recursively "avh4-lib")
+                  (delete-file-recursively "elm-format-lib")
+                  (delete-file-recursively "elm-format-test-lib")
+                  (delete-file-recursively "elm-format-markdown")))))
+    (build-system haskell-build-system)
+    (arguments
+     `(#:phases (modify-phases %standard-phases
+                  (add-before 'configure 'ganerate-build-file
+                    (lambda _
+                      ;; We need crate manually this build file
+                      ;; because elm-format use `hpack`.
+                      (mkdir "generated")
+                      (let ((f (open-file "generated/Build_elm_format.hs" "a")))
+                        (display "module Build_elm_format where\n" f)
+                        (display "gitDescribe :: String\n" f)
+                        (display (string-append "gitDescribe = \""
+                                                ,(package-version elm-format)
+                                                "\"") f)
+                        (close-port f)))))))
+    (inputs
+     (list elm-format-avh4-lib
+           elm-format-lib
+           ghc-aeson
+           ghc-text
+           ghc-relude
+           ghc-aeson-2.1
+           ghc-ansi-wl-pprint
+           ghc-quickcheck
+           ghc-hspec))
+    (native-inputs
+     (list elm-format-test-lib ghc-tasty ghc-tasty-quickcheck
+           ghc-tasty-hunit ghc-tasty-hspec))
+    (home-page "https://github.com/avh4/elm-format")
+    (synopsis "Source code formatter for Elm programming language")
+    (description
+     "Formats @url{https://elm-lang.org/, Elm} programming language
+source code according to a standard set of rules based on the
+@url{https://elm-lang.org/docs/style-guide, official Elm Style Guide}.")
+    (license license:bsd-3)))
+
 (define-public elm-file
   (package
     (name "elm-file")