guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

04/14: gnu: Add shfmt.


From: guix-commits
Subject: 04/14: gnu: Add shfmt.
Date: Fri, 23 Aug 2024 13:39:13 -0400 (EDT)

sharlatan pushed a commit to branch master
in repository guix.

commit 064a6e1f907d7c277aee3b6bd848774efdacb111
Author: Brian Kubisiak <brian@kubisiak.com>
AuthorDate: Mon Aug 5 16:05:37 2024 -0700

    gnu: Add shfmt.
    
    * gnu/packages/golang.scm (shfmt): New variable.
    
    Change-Id: I7c8bcb0f0a1d0c45d5f8f2274724188a435f0cd7
    Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
---
 gnu/packages/shellutils.scm | 56 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/gnu/packages/shellutils.scm b/gnu/packages/shellutils.scm
index 1eb77d03d9..077110290f 100644
--- a/gnu/packages/shellutils.scm
+++ b/gnu/packages/shellutils.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2023 Camilo Q.S. (Distopico) <distopico@riseup.net>
 ;;; Copyright © 2023 Zheng Junjie <873216071@qq.com>
 ;;; Copyright © 2024 Artyom V. Poptsov <poptsov.artyom@gmail.com>
+;;; Copyright © 2024 Brian Kubisiak <brian@kubisiak.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -53,6 +54,7 @@
   #:use-module (gnu packages flex)
   #:use-module (gnu packages golang)
   #:use-module (gnu packages golang-build)
+  #:use-module (gnu packages golang-check)
   #:use-module (gnu packages golang-xyz)
   #:use-module (gnu packages libunistring)
   #:use-module (gnu packages ncurses)
@@ -402,6 +404,60 @@ all of the regexes given on the command line in order.")
     (home-page "https://github.com/rupa/z";)
     (license license:expat)))
 
+(define-public shfmt
+  (package
+    (name "shfmt")
+    (version "3.9.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/mvdan/sh";)
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0qqrggliwicmrqzwv9ivg7w1chy1b97w8p7ifpvqfsbal0qcr1xi"))))
+    (build-system go-build-system)
+    (arguments
+     (list
+      #:install-source? #f
+      #:import-path "mvdan.cc/sh/v3/cmd/shfmt"
+      #:unpack-path "mvdan.cc/sh/v3"
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'set-version
+            (lambda* (#:key unpack-path #:allow-other-keys)
+              (with-directory-excursion (string-append "src/" unpack-path)
+                (let ((fixed-version (string-append #$version " (GNU Guix)")))
+                  ;; shfmt uses modules to look up the version at runtime;
+                  ;; since our build system does not yet support modules,
+                  ;; inject the version string here instead
+                  (substitute* "cmd/shfmt/main.go"
+                    (("version = \"\\(devel\\)\"")
+                     (format #f "version = \"~a\"" fixed-version)))
+                  (substitute* "cmd/shfmt/testdata/script/flags.txtar"
+                    (("devel\\|v3") #$version)))))))))
+    (native-inputs
+     (list go-github-com-creack-pty
+           go-github-com-frankban-quicktest
+           go-github-com-google-go-cmp
+           go-github-com-google-renameio-v2
+           go-github-com-pkg-diff
+           go-github-com-rogpeppe-go-internal
+           go-golang-org-x-sync
+           go-golang-org-x-sys
+           go-golang-org-x-term
+           go-mvdan-cc-editorconfig))
+    (home-page "https://github.com/mvdan/sh";)
+    (synopsis "Shell formatter with bash support")
+    (description
+     "This package provides a shell formatter.  Supports
+@url{https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html,POSIX
+Shell}, @url{https://www.gnu.org/software/bash/,Bash}, and
+@url{http://www.mirbsd.org/mksh.htm,mksh}.";)
+    (license license:bsd-3)))
+
+
 (define-public envstore
   (package
     (name "envstore")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]