;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2013 Cyril Roelandt ;;; Copyright © 2014, 2015, 2016, 2018, 2019 Mark H Weaver ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2020 Eric Bavier ;;; Copyright © 2015, 2016 Taylan Ulrich Bayırlı/Kammer ;;; Copyright © 2015 Alex Sassmannshausen ;;; Copyright © 2015 Eric Dvorsak ;;; Copyright © 2016, 2017 Leo Famulari ;;; Copyright © 2016 Pjotr Prins ;;; Copyright © 2016, 2017 Ricardo Wurmus ;;; Copyright © 2016, 2017, 2018, 2019 Efraim Flashner ;;; Copyright © 2016 Peter Feigl ;;; Copyright © 2016 John J. Foerch ;;; Copyright © 2016, 2017 Nikita ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2016 John Darrington ;;; Copyright © 2017 Ben Sturmfels ;;; Copyright © 2017 Ethan R. Jones ;;; Copyright © 2017 Christopher Allan Webber ;;; Copyright © 2017, 2018, 2020 Marius Bakke ;;; Copyright © 2018, 2019 Arun Isaac ;;; Copyright © 2018 Pierre-Antoine Rouby ;;; Copyright © 2018 Rutger Helling ;;; Copyright © 2018 Pierre Neidhardt ;;; Copyright © 2019 Brett Gilio ;;; Copyright © 2019,2020 Björn Höfling ;;; Copyright © 2019 Jakob L. Kreuze ;;; Copyright © 2019 Hartmut Goebel ;;; Copyright © 2019
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2016 Federico Beffa <beffa@fbengineering.ch>
;;; Copyright © 2015 Siniša Biđin <sinisa@bidin.eu>
;;; Copyright © 2015 Paul van der Walt <paul@denknerd.org>
;;; Copyright © 2015, 2019 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2016, 2018, 2019, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
;;; Copyright © 2016, 2022, 2024 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2022 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
;;; Copyright © 2017 Danny Milosavljevic <dannym@scratchpost.org>
;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
;;; Copyright © 2017, 2018 Alex Vong <alexvong1995@gmail.com>
;;; Copyright © 2017 rsiddharth <s@ricketyspace.net>
;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Tonton <tonton@riseup.net>
;;; Copyright © 2018, 2019, 2020 Timothy Sample <samplet@ngyro.com>
;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2018, 2019 Gabriel Hondet <gabrielhondet@gmail.com>
;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
;;; Copyright © 2019 Jacob MacDonald <jaccarmac@gmail.com>
;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2021 Matthew James Kraai <kraai@ftbfs.org>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages haskell)
  #:use-module (gnu packages)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages base)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages bootstrap)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages elf)
  #:use-module (gnu packages file)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages gawk)
  #:use-module (gnu packages gcc)
  #:use-module (gnu packages ghostscript)
  #:use-module (gnu packages libffi)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages lisp)
  #:use-module (gnu packages m4)
  #:use-module (gnu packages multiprecision)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages python)
  #:use-module (gnu packages version-control)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system haskell)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix gexp)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (ice-9 match)
  #:use-module (ice-9 regex))

(define-public cl-yale-haskell
  (let ((commit "85f94c72a16c5f70301dd8db04cde9de2d7dd270")
        (revision "1"))
    (package
      (name "cl-yale-haskell")
      (version (string-append "2.0.5-" revision "." (string-take commit 9)))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://git.elephly.net/software/yale-haskell.git")
                      (commit commit)))
                (file-name (string-append "yale-haskell-" commit "-checkout"))
                (sha256
                 (base32
                  "0bal3m6ryrjamz5p93bhs9rp5msk8k7lpcqr44wd7xs9b9k8w74g"))))
      (build-system gnu-build-system)
      (arguments
       `(#:tests? #f                    ; no tests
         ;; Stripping binaries leads to a broken executable lisp system image.
         #:strip-binaries? #f
         #:make-flags
         (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
         #:phases
         (modify-phases %standard-phases
           (replace 'configure
             (lambda _
               (setenv "PRELUDE" "./progs/prelude")
               (setenv "HASKELL_LIBRARY" "./progs/lib")
               (setenv "PRELUDEBIN" "./progs/prelude/clisp")
               (setenv "HASKELLPROG" "./bin/clisp-haskell")
               #t)))))
      (inputs
       (list clisp))
      (home-page "https://git.elephly.net/software/yale-haskell.git")
      (synopsis "Port of the Yale Haskell system to CLISP")
      (description "This package provides the Yale Haskell system running on
top of CLISP.")
      (license license:bsd-4))))

;; This package contains lots of generated .hc files containing C code to
;; bootstrap the compiler without a Haskell compiler.  The included .hc files
;; cover not just the compiler sources but also all Haskell libraries.
(define-public nhc98
  (package
    (name "nhc98")
    (version "1.22")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://www.haskell.org/nhc98/nhc98src-"
                           version ".tar.gz"))
       (sha256
        (base32
         "0fkgxgsd2iqxvwcgnad1702kradwlbcal6rxdrgb22vd6dnc3i8l"))
       (patches (search-patches "nhc98-c-update.patch"))))
    (build-system gnu-build-system)
    (supported-systems '("i686-linux" "x86_64-linux"))
    (arguments
     (list
      #:tests? #false                   ;there is no test target
      #:system "i686-linux"
      #:parallel-build? #false          ;not supported
      #:strip-binaries? #false          ;doesn't work
      #:make-flags '(list "all-gcc")
      #:phases
      #~(modify-phases %standard-phases
          (replace 'configure
            (lambda _
              (setenv "SHELL" (which "sh"))
              (setenv "CPATH" (string-append
                               (getcwd) "/src/runtime/Kernel:"
                               (or (getenv "C_INCLUDE_PATH") "")))
              (substitute* "configure"
                (("echo '#!/bin/sh'")
                 (string-append "echo '#!" (which "sh") "'")))
              (with-fluids ((%default-port-encoding #f))
                (substitute* '("script/greencard.inst"
                               "script/harch.inst"
                               "script/hi.inst"
                               "script/hmake-config.inst"
                               ;; TODO: can't fix this with substitute*
                                        ;"script/hmake.inst"
                               "script/hood.inst"
                               "script/hsc2hs.inst"
                               "script/nhc98-pkg.inst"
                               "script/nhc98.inst")
                  (("^MACHINE=.*") "MACHINE=ix86-Linux\n")))
              (invoke "sh" "configure"
                      (string-append "--prefix=" #$output)
                      ;; Remove -m32 from compiler/linker invocation
                      "--ccoption="
                      "--ldoption=")))
          (replace 'install
            (lambda _
              (invoke "sh" "configure"
                      (string-append "--prefix=" #$output)
                      ;; Remove -m32 from compiler/linker invocation
                      "--ccoption="
                      "--ldoption="
                      "--install"))))))
    (home-page "https://www.haskell.org/nhc98")
    (synopsis "Nearly a Haskell Compiler")
    (description
     "nhc98 is a small, standards-compliant compiler for Haskell 98, the lazy
functional programming language.  It aims to produce small executables that
run in small amounts of memory.  It produces medium-fast code, and compilation
is itself quite fast.")
    (license
     (license:non-copyleft
      "https://www.haskell.org/nhc98/copyright.html"))))

(define-public ghc-4
  (package
    (name "ghc")
    (version "4.08.2")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://www.haskell.org/ghc/dist/"
                           version "/" name "-" version "-src.tar.bz2"))
       (sha256
        (base32
         "0ar4nxy4cr5vwvfj71gmc174vx0n3lg9ka05sa1k60c8z0g3xp1q"))))
    (build-system gnu-build-system)
    (supported-systems '("i686-linux" "x86_64-linux"))
    (arguments
     (list
      #:system "i686-linux"
      #:strip-binaries? #f
      #:parallel-build? #f
      #:implicit-inputs? #f
      #:modules '((guix build gnu-build-system)
                  (guix build utils)
                  (srfi srfi-1)
                  (ice-9 match))
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'unpack-generated-c-code
            (lambda* (#:key inputs #:allow-other-keys)
              (let ((tarball
                     (match inputs
                       (((_ . locations) ...)
                        (let ((suffix (string-append "ghc-"
                                                     #$(package-version this-package)
                                                     "-x86-hc.tar.bz2")))
                          (find (lambda (location)
                                  (string-suffix? suffix location))
                                locations))))))
                (invoke "tar" "-xvf" tarball
                        "--strip-components=1"))))
          (replace 'bootstrap
            (lambda* (#:key inputs #:allow-other-keys)
              (delete-file "configure")
              (delete-file "config.sub")
              (install-file (search-input-file inputs
                                               "/bin/config.sub")
                            ".")

              ;; Avoid dependency on "happy"
              (substitute* "configure.in"
                (("FPTOOLS_HAPPY") "echo sure\n"))

              (let ((bash (which "bash")))
                (substitute* '("configure.in"
                               "ghc/configure.in"
                               "ghc/rts/gmp/mpn/configure.in"
                               "ghc/rts/gmp/mpz/configure.in"
                               "ghc/rts/gmp/configure.in"
                               "distrib/configure-bin.in")
                  (("`/bin/sh") (string-append "`" bash))
                  (("SHELL=/bin/sh") (string-append "SHELL=" bash))
                  (("^#! /bin/sh") (string-append "#! " bash)))

                (substitute* '("mk/config.mk.in"
                               "ghc/rts/gmp/mpz/Makefile.in"
                               "ghc/rts/gmp/Makefile.in")
                  (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
                (substitute* "aclocal.m4"
                  (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
                (substitute* '("ghc/lib/std/cbits/system.c"
                               "hslibs/posix/cbits/execvpe.c")
                  (("/bin/sh") bash)
                  (("\"sh\"") (string-append "\"" bash "\"")))

                (setenv "CONFIG_SHELL" bash)
                (setenv "SHELL" bash))

              ;; The 'hscpp' script invokes GCC 2.95's 'cpp' (RAWCPP), which
              ;; segfaults unless passed '-x c'.
              (substitute* "mk/config.mk.in"
                (("-traditional")
                 "-traditional -x c"))

              (setenv "CPP" (which "cpp"))
              (invoke "autoreconf" "--verbose" "--force")))
          (add-before 'configure 'configure-gmp
            (lambda _
              (with-directory-excursion "ghc/rts/gmp"
                (invoke "./configure"))))
          (replace 'configure
            (lambda* (#:key build #:allow-other-keys)
              (call-with-output-file "config.cache"
                (lambda (port)
                  ;; GCC 2.95 fails to deal with anonymous unions in glibc's
                  ;; 'struct_rusage.h', so skip that.
                  (display "ac_cv_func_getrusage=no\n" port)))

              ;; CLK_TCK has been removed from recent libc.
              (substitute* "ghc/interpreter/nHandle.c"
                (("CLK_TCK") "sysconf (_SC_CLK_TCK)"))
              ;; Avoid duplicate definitions of execvpe
              (substitute* "ghc/lib/std/cbits/stgio.h"
                (("^int.*execvpe.*") ""))
              ;; gid_t is an undefined type
              (substitute* "hslibs/posix/PosixProcEnv.lhs"
                (("gid_t") "int"))

              ;; This is needed so that ghc/includes/Stg.h can see config.h,
              ;; which defines values that are important for
              ;; ghc/includes/StgTypes.h and others.
              (setenv "CPATH"
                      (string-append (getcwd) "/ghc/includes:"
                                     (getcwd) "/ghc/rts/gmp:"
                                     (getcwd) "/mk:"
                                     (or (getenv "CPATH") "")))

              (with-output-to-file "mk/build.mk"
                (lambda ()
                  (display "
ProjectsToBuild = glafp-utils hslibs ghc
GhcLibWays=
GhcHcOpts=-DDEBUG
GhcLibHcOpts= -O
GhcRtsHcOpts=-optc-D_GNU_SOURCE=1 -optc-DDEBUG
GhcRtsCcOpts=-optc-D_GNU_SOURCE=1 -optc-DDEBUG
SplitObjs=YES
GhcWithHscBuiltViaC=YES
")))
              (invoke "./configure"
                      "--enable-hc-boot" ; boot from C "source" files
                      ;; Embed the absolute file name of GCC 2.95 in the GHC
                      ;; driver script.
                      (string-append "--with-gcc=" (which "gcc"))
                      (string-append "--prefix=" #$output)
                      (string-append "--build=" build)
                      (string-append "--host=" build))))
          ;; Build hsc
          (add-before 'build 'make-boot
            (lambda _
              ;; Avoid calling happy
              (invoke "touch" "ghc/compiler/rename/ParseIface.hs")
              (invoke "touch" "ghc/compiler/parser/Parser.hs")
              (invoke "make" "boot" "all")))
          ;; Build libraries
          (replace 'build
            (lambda _
              ;; Build these from their Haskell sources.
              (invoke "sh" "-c" "echo GhcWithHscBuiltViaC=NO >>mk/build.mk")
              (with-directory-excursion "ghc/lib"
                (invoke "make" "clean" "boot" "all"))
              (with-directory-excursion "hslibs"
                (invoke "make" "clean" "boot" "all"))))
          (add-before 'install 'do-not-strip
            (lambda _
              (substitute* '("install-sh"
                             "ghc/rts/gmp/install.sh")
                (("^stripprog=.*") "stripprog=echo\n"))
              (substitute* "mk/opts.mk"
                (("^SRC_INSTALL_BIN_OPTS.*") "")))))))
    (native-inputs
     (modify-inputs (%final-inputs)
       (delete "binutils" "gcc")
       (prepend
           autoconf-2.13
           bison                        ;for parser.y
           config

           ;; Use an older assembler to work around this error in GMP:
           ;;   Error: `%edx' not allowed with `testb'
           binutils-2.33

           ;; Needed to support lvalue casts.
           gcc-2.95

           ;; Perl used to allow setting $* to enable multi-line matching.  If
           ;; we want to use a more recent Perl we need to patch all
           ;; expressions that require multi-line matching.  Hard to tell.
           perl-5.6

           ;; This is the secret sauce.  These files are macro-heavy C
           ;; "source" files that are used to build hsc from C.  They are
           ;; presumably the output of previous versions of GHC.  Note that
           ;; this is the "registerized" variant for x86.  An "unreg" variant
           ;; of the *.hc files also exists for building GHC for other
           ;; architectures.  The default "way" (see GhcLibWays above) to
           ;; build and link the GHC binaries, however, is not the
           ;; unregisterized variant.  Using the unregisterized *.hc files
           ;; with a standard build will result in segfaults.
           (origin
             (method url-fetch)
             (uri (string-append "http://downloads.haskell.org/~ghc/"
                                 version "/ghc-" version "-x86-hc.tar.bz2"))
             (sha256
              (base32
               "0fi60bj0ak391x31cq5wp1ffwavl5w9jffyf62yv9rhxa915596b"))))))
    (home-page "https://www.haskell.org/ghc")
    (synopsis "The Glasgow Haskell Compiler")
    (description
     "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
interactive environment for the functional language Haskell.")
    (license license:bsd-3)))

(define-public ghc-6.0
  (package
    (name "ghc")
    (version "6.0")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://downloads.haskell.org/~ghc/"
                           version "/" name "-" version "-src.tar.bz2"))
       (sha256
        (base32
         "06hpl8wyhhs1vz9dcdf0vbybwyzb5ifh27d59rx42q1vjs0m8zdv"))))
    (build-system gnu-build-system)
    (supported-systems '("i686-linux" "x86_64-linux"))
    (arguments
     (list
      #:system "i686-linux"
      #:tests? #false ;no check target
      #:implicit-inputs? #false
      #:parallel-build? #false ;not supported
      #:modules '((guix build gnu-build-system)
                  (guix build utils)
                  (srfi srfi-26)
                  (srfi srfi-1))
      #:phases
      #~(modify-phases %standard-phases
          (replace 'bootstrap
            (lambda* (#:key inputs #:allow-other-keys)
              (delete-file "configure")
              (delete-file "config.sub")
              (install-file (search-input-file inputs
                                               "/bin/config.sub")
                            ".")
              (let ((bash (which "bash")))
                (substitute* '("configure.in"
                               "ghc/configure.in"
                               "ghc/rts/gmp/configure.in"
                               "distrib/configure-bin.in")
                  (("`/bin/sh") (string-append "`" bash))
                  (("SHELL=/bin/sh") (string-append "SHELL=" bash))
                  (("^#! /bin/sh") (string-append "#! " bash)))
                (substitute* "glafp-utils/runstdtest/runstdtest.prl"
                  (("^#! /bin/sh") (string-append "#! " bash))
                  (("TimeCmd /bin/sh")
                   (string-append "TimeCmd " bash)))
                (substitute* '("mk/config.mk.in"
                               "ghc/rts/gmp/Makefile.in")
                  (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
                (substitute* "aclocal.m4"
                  (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
                (substitute* '"ghc/compiler/Makefile"
                  (("#!/bin/sh") (string-append "#!" bash)))
                (substitute* '("libraries/base/cbits/system.c"
                               "libraries/unix/cbits/execvpe.c")
                  (("/bin/sh") bash)
                  (("\"sh\"") (string-append "\"" bash "\"")))

                (setenv "CONFIG_SHELL" bash)
                (setenv "SHELL" bash))
              (invoke "autoreconf" "--verbose" "--force")))
          (replace 'configure
            (lambda* (#:key build #:allow-other-keys)
              (setenv "CPATH"
                      (string-append (getcwd) "/ghc/includes:"
                                     (getcwd) "/ghc/rts/gmp:"
                                     (getcwd) "/mk:"
                                     (or (getenv "CPATH") "")))
              (call-with-output-file "config.cache"
                (lambda (port)
                  ;; GCC 2.95 fails to deal with anonymous unions in glibc's
                  ;; 'struct_rusage.h':
                  ;; Stats.c: In function `pageFaults':
                  ;; Stats.c:270: structure has no member named `ru_majflt'
                  ;; Stats.c:272: warning: control reaches end of non-void function
                  (display "ac_cv_func_getrusage=no\n" port)))

              ;; Socket.hsc:887: sizeof applied to an incomplete type
              ;; Socket.hsc:893: dereferencing pointer to incomplete type
              (substitute* "libraries/network/Network/Socket.hsc"
                (("ifdef SO_PEERCRED")
                 "ifdef SO_PEERCRED_NEVER"))
              (invoke "./configure"
                      "--enable-src-tree-happy"
                      (string-append "--with-gcc=" (which "gcc"))
                      (string-append "--prefix=" #$output)
                      (string-append "--build=" build)
                      (string-append "--host=" build)))))))
    (native-search-paths (list (search-path-specification
                                (variable "GHC_PACKAGE_PATH")
                                (files (list
                                        (string-append "lib/ghc-" version)))
                                (file-pattern ".*\\.conf\\.d$")
                                (file-type 'directory))))
    (native-inputs
     (modify-inputs (%final-inputs)
       (delete "gcc")
       (prepend autoconf-2.13
                config
                flex
                ;; Perl used to allow setting $* to enable multi-line matching.  If
                ;; we want to use a more recent Perl we need to patch all
                ;; expressions that require multi-line matching.  Hard to tell.
                perl-5.6
                ghc-4
                gcc-2.95)))
    (home-page "https://www.haskell.org/ghc")
    (synopsis "The Glasgow Haskell Compiler")
    (description
     "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
interactive environment for the functional language Haskell.")
    (license license:bsd-3)))

(define-public ghc-6.6
  (package
    (name "ghc")
    (version "6.6")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://downloads.haskell.org/~ghc/"
                           version "/" name "-" version "-src.tar.bz2"))
       (sha256
        (base32
         "0znc9myxyfg9zmvdlg09sf0dq11kc2bq4616llh82v6m6s8s5ckr"))))
    (build-system gnu-build-system)
    (supported-systems '("i686-linux" "x86_64-linux"))
    (arguments
     (list
      #:system "i686-linux"
      #:tests? #false ;no check target
      #:modules '((guix build gnu-build-system)
                  (guix build utils)
                  (srfi srfi-26)
                  (srfi srfi-1))
      #:phases
      #~(modify-phases %standard-phases
          (replace 'bootstrap
            (lambda* (#:key inputs #:allow-other-keys)
              (let ((bash (which "bash")))
                (substitute* '("configure"
                               "rts/gmp/configure"
                               "distrib/configure-bin.ac")
                  (("`/bin/sh") (string-append "`" bash))
                  (("SHELL=/bin/sh") (string-append "SHELL=" bash))
                  (("^#! /bin/sh") (string-append "#! " bash)))
                (substitute* "utils/runstdtest/runstdtest.prl"
                  (("^#! /bin/sh") (string-append "#! " bash))
                  (("TimeCmd /bin/sh")
                   (string-append "TimeCmd " bash)))
                (substitute* '("mk/config.mk.in"
                               "rts/gmp/Makefile.in")
                  (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
                (substitute* "aclocal.m4"
                  (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
                (substitute* "compiler/Makefile"
                  (("#!/bin/sh") (string-append "#!" bash)))
                (substitute* '("libraries/base/cbits/execvpe.c"
                               "libraries/Cabal/Distribution/attic"
                               "libraries/Cabal/Distribution/Simple/Register.hs"
                               "libraries/base/System/Process/Internals.hs")
                  (("/bin/sh") bash)
                  (("\"sh\"") (string-append "\"" bash "\"")))

                (setenv "CONFIG_SHELL" bash)
                (setenv "SHELL" bash))))
          (replace 'configure
            (lambda* (#:key build #:allow-other-keys)
              (setenv "CPATH"
                      (string-append (getcwd) "/includes:"
                                     (getcwd) "/rts/gmp:"
                                     (getcwd) "/mk:"
                                     (or (getenv "CPATH") "")))
              (invoke "./configure"
                      (string-append "--with-hc=" (which "ghc"))
                      (string-append "--with-gcc=" (which "gcc"))
                      (string-append "--prefix=" #$output)
                      (string-append "--build=" build)
                      (string-append "--host=" build)))))))
    (native-search-paths (list (search-path-specification
                                (variable "GHC_PACKAGE_PATH")
                                (files (list
                                        (string-append "lib/ghc-" version)))
                                (file-pattern ".*\\.conf\\.d$")
                                (file-type 'directory))))
    (native-inputs
     (modify-inputs (%final-inputs)
       (delete "gcc")
       (prepend m4
                ;; Perl used to allow setting $* to enable multi-line matching.  If
                ;; we want to use a more recent Perl we need to patch all
                ;; expressions that require multi-line matching.  Hard to tell.
                perl-5.6
                ghc-6.0
                gcc-4.9)))
    (home-page "https://www.haskell.org/ghc")
    (synopsis "The Glasgow Haskell Compiler")
    (description
     "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
interactive environment for the functional language Haskell.")
    (license license:bsd-3)))

(define-public ghc-6.10
  (package
    (name "ghc")
    (version "6.10.4")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://downloads.haskell.org/~ghc/"
                           version "/" name "-" version "-src.tar.bz2"))
       (sha256
        (base32
         "0kakv05kqi92qbfgmhr57rvag10yvp338kjwzqczhkrgax98wsnn"))
       (modules '((guix build utils)))
       (snippet
        '(delete-file-recursively "libffi"))))
    (build-system gnu-build-system)
    (supported-systems '("i686-linux" "x86_64-linux"))
    (arguments
     (list
      #:system "i686-linux"
      #:tests? #false ;no check target
      #:parallel-build? #false ;fails when building libraries/*
      #:modules '((guix build gnu-build-system)
                  (guix build utils)
                  (srfi srfi-26)
                  (srfi srfi-1))
      #:configure-flags
      #~(list
         (string-append "--with-gmp-libraries="
                        (assoc-ref %build-inputs "gmp") "/lib")
         (string-append "--with-gmp-includes="
                        (assoc-ref %build-inputs "gmp") "/include"))
      #:phases
      #~(modify-phases %standard-phases
          (replace 'bootstrap
            (lambda* (#:key inputs #:allow-other-keys)
              (let ((bash (which "bash")))
                ;; Use our libffi package
                (substitute* "rts/Makefile"
                  (("-I../libffi/build/include")
                   (string-append "-I"#$(this-package-input "libffi") "/include"))
                  (("-L../libffi/build/include")
                   (string-append "-L"#$(this-package-input "libffi") "/lib")))
                (substitute* '("Makefile"
                               "distrib/Makefile")
                  (("SUBDIRS = gmp libffi")
                   "SUBDIRS = gmp")
                  (("\\$\\(MAKE\\) -C libffi.*") ""))
                (substitute* "compiler/ghc.cabal.in"
                  (("../libffi/build/include")
                   (string-append #$(this-package-input "libffi") "/include")))

                ;; Do not use libbfd, because it complicates the build and
                ;; requires more patching.  Disable all debug and profiling
                ;; builds.
                (substitute* "mk/config.mk.in"
                  (("GhcRTSWays \\+= debug") "")
                  (("GhcRTSWays \\+= debug_dyn thr_dyn thr_debug_dyn")
                   "GhcRTSWays += thr_dyn")
                  (("thr thr_p thr_debug") "thr")
                  (("GhcLibWays=p") "GhcLibWays="))

                ;; Replace /bin/sh.
                (substitute* '("configure"
                               "distrib/configure-bin.ac")
                  (("`/bin/sh") (string-append "`" bash))
                  (("SHELL=/bin/sh") (string-append "SHELL=" bash))
                  (("#! /bin/sh") (string-append "#! " bash)))
                (substitute* '("mk/config.mk.in")
                  (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
                (substitute* "aclocal.m4"
                  (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
                (substitute* '("libraries/unix/cbits/execvpe.c"
                               "libraries/Cabal/Distribution/Simple/Register.hs"
                               "libraries/process/System/Process/Internals.hs")
                  (("/bin/sh") bash)
                  (("\"sh\"") (string-append "\"" bash "\"")))))))))
    (native-search-paths (list (search-path-specification
                                (variable "GHC_PACKAGE_PATH")
                                (files (list
                                        (string-append "lib/ghc-" version)))
                                (file-pattern ".*\\.conf\\.d$")
                                (file-type 'directory))))
    (inputs
     (list gmp libffi))
    (native-inputs
     (list perl ghc-6.6))
    (home-page "https://www.haskell.org/ghc")
    (synopsis "The Glasgow Haskell Compiler")
    (description
     "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
interactive environment for the functional language Haskell.")
    (license license:bsd-3)))

(define-public ghc-7.0
  (package
    (inherit ghc-6.10)
    (name "ghc")
    (version "7.0.4")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://downloads.haskell.org/~ghc/"
                           version "/" name "-" version "-src.tar.bz2"))
       (sha256
        (base32
         "1vfhdvf9nls4pn1vy48ndy2s81klp1my6ch9dkg2373csvcpi6qs"))
       (snippet
        #~(begin (use-modules (guix build utils))
                 (delete-file-recursively "utils/ghc-pwd/dist-boot")))))
    (arguments
     (list
      #:system "i686-linux"
      #:test-target "test"
      #:tests? #false           ;not yet
      #:parallel-build? #false  ;fails when building libraries/*
      ;; Don't pass --build=<triplet>, because the configure script
      ;; auto-detects slightly different triplets for --host and --target and
      ;; then complains that they don't match.
      #:build #f
      #:validate-runpath? #f    ; libraries can't find each other.
      #:configure-flags
      #~(list
         (string-append "--with-gmp-libraries="
                        (assoc-ref %build-inputs "gmp") "/lib")
         (string-append "--with-gmp-includes="
                        (assoc-ref %build-inputs "gmp") "/include"))
      #:make-flags
      #~(list (string-append "CONFIG_SHELL=" (assoc-ref %build-inputs "bash")
                             "/bin/bash"))
      #:phases
      #~(modify-phases %standard-phases
          (replace 'bootstrap
            (lambda* (#:key inputs #:allow-other-keys)
              (let ((bash (which "bash")))
                ;; Use our libffi package
                (substitute* "rts/ghc.mk"
                  (("-I../libffi/build/include")
                   (string-append "-I" #$(this-package-input "libffi") "/include"))
                  (("-L../libffi/build/include")
                   (string-append "-L" #$(this-package-input "libffi") "/lib"))
                  (("-DDEBUG") ""))
                (substitute* '("Makefile"
                               "distrib/Makefile")
                  (("SUBDIRS = gmp libffi")
                   "SUBDIRS = gmp")
                  (("\\$\\(MAKE\\) -C libffi.*") ""))
                (substitute* "compiler/ghc.cabal.in"
                  (("../libffi/build/include")
                   (string-append #$(this-package-input "libffi") "/include")))

                ;; Do not use libbfd, because it complicates the build and
                ;; requires more patching.  Disable all debug and profiling
                ;; builds.
                (substitute* "mk/config.mk.in"
                  (("GhcRTSWays \\+= debug") "")
                  (("thr thr_debug thr_l") "thr thr_l")
                  (("dyn debug_dyn") "dyn")
                  (("thr_dyn thr_debug_dyn") "thr_dyn")
                  (("GhcLibWays += p") "GhcLibWays +="))

                ;; Replace /bin/sh.
                (substitute* '("configure"
                               "distrib/configure.ac")
                  (("`/bin/sh") (string-append "`" bash))
                  (("SHELL=/bin/sh") (string-append "SHELL=" bash))
                  (("#! /bin/sh") (string-append "#! " bash)))
                (substitute* '("mk/config.mk.in")
                  (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
                (substitute* "aclocal.m4"
                  (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
                (substitute* "utils/ghc-pkg/ghc.mk"
                  (("#!/bin/sh") (string-append "#!" bash)))
                (substitute* '("libraries/unix/cbits/execvpe.c"
                               "libraries/Cabal/Distribution/Simple/Hugs.hs"
                               "libraries/Cabal/Distribution/Simple/Program/Script.hs"
                               "libraries/process/System/Process/Internals.hs")
                  (("/bin/sh") bash)
                  (("\"sh\"") (string-append "\"" bash "\"")))))))))
    (native-search-paths (list (search-path-specification
                                (variable "GHC_PACKAGE_PATH")
                                (files (list
                                        (string-append "lib/ghc-" version)))
                                (file-pattern ".*\\.conf\\.d$")
                                (file-type 'directory))))
    (inputs
     (list gmp libffi ncurses perl))
    (native-inputs
     (list perl ghc-6.10))))

(define ghc-bootstrap-x86_64-7.8.4
  (origin
    (method url-fetch)
    (uri
     "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz")
    (sha256
     (base32
      "13azsl53xgj20mi1hj9x0xb32vvcvs6cpmvwx6znxhas7blh0bpn"))))

(define ghc-bootstrap-i686-7.8.4
  (origin
    (method url-fetch)
    (uri
     "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-i386-unknown-linux-deb7.tar.xz")
    (sha256
     (base32
      "0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg"))))

;; 43 tests out of 3965 fail.
;;
;; Most of them do not appear to be serious:
;;
;; - some tests generate files referring to "/bin/sh" and "/bin/ls". I've not
;;   figured out how these references are generated.
;;
;; - Some tests allocate more memory than expected (ca. 3% above upper limit)
;;
;; - Some tests try to load unavailable libriries: Control.Concurrent.STM,
;;   Data.Vector, Control.Monad.State.
;;
;; - Test posix010 tries to check the existence of a user on the system:
;;   getUserEntryForName: does not exist (no such user)
(define-public ghc-7
  (package
    (name "ghc")
    (version "7.10.3")
    (source
     (origin
      (method url-fetch)
      (uri (string-append "https://www.haskell.org/ghc/dist/"
                          version "/" name "-" version "-src.tar.xz"))
      (sha256
       (base32
        "1vsgmic8csczl62ciz51iv8nhrkm72lyhbz7p7id13y2w7fcx46g"))))
    (build-system gnu-build-system)
    (supported-systems '("i686-linux" "x86_64-linux"))
    (outputs '("out" "doc"))
    (inputs
     `(("gmp" ,gmp)
       ("ncurses" ,ncurses)

       ;; Use a LibFFI variant without static trampolines to work around
       ;; <https://gitlab.haskell.org/ghc/ghc/-/issues/20051>.
       ("libffi" ,libffi-sans-static-trampolines)

       ("ghc-testsuite"
        ,(origin
           (method url-fetch)
           (uri (string-append
                 "https://www.haskell.org/ghc/dist/"
                 version "/" name "-" version "-testsuite.tar.xz"))
           (sha256
            (base32
             "0fk4xjw1x5lk2ifvgqij06lrbf1vxq9qfix86h9r16c0bilm3hah"))))))
    (native-inputs
     `(("perl" ,perl)
       ("python" ,python-2)                ; for tests (fails with python-3)
       ("ghostscript" ,ghostscript)        ; for tests
       ("patchelf" ,patchelf)
       ;; GHC is built with GHC. Therefore we need bootstrap binaries.
       ("ghc-binary"
        ,(if (string-match "x86_64" (or (%current-target-system) (%current-system)))
             ghc-bootstrap-x86_64-7.8.4
             ghc-bootstrap-i686-7.8.4))))
    (arguments
     (list
       #:test-target "test"
       ;; We get a smaller number of test failures by disabling parallel test
       ;; execution.
       #:parallel-tests? #f

       ;; Don't pass --build=<triplet>, because the configure script
       ;; auto-detects slightly different triplets for --host and --target and
       ;; then complains that they don't match.
       #:build #f

       #:modules '((guix build gnu-build-system)
                   (guix build utils)
                   (srfi srfi-26)
                   (srfi srfi-1))
       #:configure-flags
       #~(list
           (string-append "--with-gmp-libraries="
                          (assoc-ref %build-inputs "gmp") "/lib")
           (string-append "--with-gmp-includes="
                          (assoc-ref %build-inputs "gmp") "/include")
           "--with-system-libffi"
           (string-append "--with-ffi-libraries="
                          (assoc-ref %build-inputs "libffi") "/lib")
           (string-append "--with-ffi-includes="
                          (assoc-ref %build-inputs "libffi") "/include"))
       ;; FIXME: The user-guide needs dblatex, docbook-xsl and docbook-utils.
       ;; Currently we do not have the last one.
       ;; #:make-flags
       ;; (list "BUILD_DOCBOOK_HTML = YES")
       #:phases
       #~(let* ((ghc-bootstrap-path
                  (string-append (getcwd) "/" #$name "-" #$version "/ghc-bin"))
                (ghc-bootstrap-prefix
                  (string-append ghc-bootstrap-path "/usr" )))
           (modify-phases %standard-phases
             (add-after 'unpack 'unpack-bin
               (lambda* (#:key inputs outputs #:allow-other-keys)
                (mkdir-p ghc-bootstrap-prefix)
                (with-directory-excursion ghc-bootstrap-path
                  (invoke "tar" "xvf" (assoc-ref inputs "ghc-binary")))))
             (add-after 'unpack-bin 'unpack-testsuite-and-fix-bins
               (lambda* (#:key inputs outputs #:allow-other-keys)
                 (with-directory-excursion ".."
                   (invoke "tar" "xvf" (assoc-ref inputs "ghc-testsuite")))
                 (substitute*
                   (list "testsuite/timeout/Makefile"
                         "testsuite/timeout/timeout.py"
                         "testsuite/timeout/timeout.hs"
                         "testsuite/tests/rename/prog006/Setup.lhs"
                         "testsuite/tests/programs/life_space_leak/life.test"
                         "libraries/process/System/Process/Internals.hs"
                         "libraries/unix/cbits/execvpe.c")
                   (("/bin/sh") (search-input-file inputs "/bin/sh"))
                   (("/bin/rm") "rm"))))
             (add-before 'configure 'install-bin
               (lambda* (#:key inputs outputs #:allow-other-keys)
                 (with-directory-excursion
                   (string-append ghc-bootstrap-path "/ghc-7.8.4")
                   (invoke "make" "install"))))
             (add-before 'install-bin 'configure-bin
               (lambda* (#:key inputs outputs #:allow-other-keys)
                 (let* ((binaries
                          (list
                            "./utils/ghc-pwd/dist-install/build/tmp/ghc-pwd"
                            "./utils/hpc/dist-install/build/tmp/hpc"
                            "./utils/haddock/dist/build/tmp/haddock"
                            "./utils/hsc2hs/dist-install/build/tmp/hsc2hs"
                            "./utils/runghc/dist-install/build/tmp/runghc"
                            "./utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
                            "./utils/hp2ps/dist/build/tmp/hp2ps"
                            "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
                            "./utils/unlit/dist/build/tmp/unlit"
                            "./ghc/stage2/build/tmp/ghc-stage2"))
                        (gmp (assoc-ref inputs "gmp"))
                        (gmp-lib (string-append gmp "/lib"))
                        (gmp-include (string-append gmp "/include"))
                        (ncurses-lib
                         (dirname (search-input-file inputs "/lib/libncurses.so")))
                        (ld-so (search-input-file inputs #$(glibc-dynamic-linker)))
                        (libtinfo-dir
                         (string-append ghc-bootstrap-prefix
                                        "/lib/ghc-7.8.4/terminfo-0.4.0.0")))
                   (with-directory-excursion
                     (string-append ghc-bootstrap-path "/ghc-7.8.4")
                     (setenv "CONFIG_SHELL" (which "bash"))
                     (setenv "LD_LIBRARY_PATH" gmp-lib)
                     ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
                     (for-each
                      (cut invoke "patchelf" "--set-interpreter" ld-so <>)
                      binaries)
                     ;; The binaries include a reference to libtinfo.so.5 which
                     ;; is a subset of libncurses.so.5.  We create a symlink in a
                     ;; directory included in the bootstrap binaries rpath.
                     (mkdir-p libtinfo-dir)
                     (symlink
                      (string-append ncurses-lib "/libncursesw.so."
                                     ;; Extract "6.0" from "6.0-20170930" if a
                                     ;; dash-separated version tag exists.
                                     #$(let* ((v (package-version ncurses))
                                              (d (or (string-index v #\-)
                                                     (string-length v))))
                                         (version-major+minor (string-take v d))))
                      (string-append libtinfo-dir "/libtinfo.so.5"))

                     (setenv "PATH"
                             (string-append (getenv "PATH") ":"
                                            ghc-bootstrap-prefix "/bin"))
                     (invoke
                      (string-append (getcwd) "/configure")
                      (string-append "--prefix=" ghc-bootstrap-prefix)
                      (string-append "--with-gmp-libraries=" gmp-lib)
                      (string-append "--with-gmp-includes=" gmp-include))))))))))
    (native-search-paths (list (search-path-specification
                                (variable "GHC_PACKAGE_PATH")
                                (files (list
                                        (string-append "lib/ghc-" version)))
                                (file-pattern ".*\\.conf\\.d$")
                                (file-type 'directory))))
    (home-page "https://www.haskell.org/ghc")
    (synopsis "The Glasgow Haskell Compiler")
    (description
     "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
interactive environment for the functional language Haskell.")
    (license license:bsd-3)))

(define-public ghc-8.0
  (package
    (name "ghc")
    (version "8.0.2")
    (source
     (origin
      (method url-fetch)
      (uri (string-append "https://www.haskell.org/ghc/dist/"
                          version "/" name "-" version "-src.tar.xz"))
      (sha256
       (base32 "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"))
      (patches
       (search-patches "ghc-8.0-fall-back-to-madv_dontneed.patch"))))
    (build-system gnu-build-system)
    (supported-systems '("i686-linux" "x86_64-linux"))
    (outputs '("out" "doc"))
    (inputs
     ;; Use a LibFFI variant without static trampolines to work around
     ;; <https://gitlab.haskell.org/ghc/ghc/-/issues/20051>.
     (list gmp ncurses libffi-sans-static-trampolines))
    (native-inputs
     `(("perl" ,perl)
       ("python" ,python-2)                ; for tests
       ("ghostscript" ,ghostscript)        ; for tests
       ;; GHC is built with GHC.
       ("ghc-bootstrap" ,ghc-7)
       ("ghc-testsuite"
        ,(origin
           (method url-fetch)
           (uri (string-append
                  "https://www.haskell.org/ghc/dist/"
                  version "/" name "-" version "-testsuite.tar.xz"))
           (sha256
            (base32 "1wjc3x68l305bl1h1ijd3yhqp2vqj83lkp3kqbr94qmmkqlms8sj")))) ))
    (arguments
     (list
       #:test-target "test"
       ;; We get a smaller number of test failures by disabling parallel test
       ;; execution.
       #:parallel-tests? #f

       ;; Don't pass --build=<triplet>, because the configure script
       ;; auto-detects slightly different triplets for --host and --target and
       ;; then complains that they don't match.
       #:build #f

       #:configure-flags
       #~(list
           (string-append "--with-gmp-libraries="
                          (assoc-ref %build-inputs "gmp") "/lib")
           (string-append "--with-gmp-includes="
                          (assoc-ref %build-inputs "gmp") "/include")
           "--with-system-libffi"
           (string-append "--with-ffi-libraries="
                          (assoc-ref %build-inputs "libffi") "/lib")
           (string-append "--with-ffi-includes="
                          (assoc-ref %build-inputs "libffi") "/include")
           (string-append "--with-curses-libraries="
                          (assoc-ref %build-inputs "ncurses") "/lib")
           (string-append "--with-curses-includes="
                          (assoc-ref %build-inputs "ncurses") "/include"))
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'unpack 'unpack-testsuite
             (lambda* (#:key inputs #:allow-other-keys)
               (with-directory-excursion ".."
                 (invoke "tar" "xvf" (assoc-ref inputs "ghc-testsuite")))))
           (add-before 'build 'fix-lib-paths
             (lambda* (#:key inputs #:allow-other-keys)
               (substitute*
                 (list "libraries/process/System/Process/Posix.hs"
                       "libraries/process/tests/process001.hs"
                       "libraries/process/tests/process002.hs"
                       "libraries/unix/cbits/execvpe.c")
                 (("/bin/sh") (search-input-file inputs "/bin/sh"))
                 (("/bin/ls") (search-input-file inputs "/bin/ls")))))
           (add-before 'build 'fix-environment
             (lambda _
               (unsetenv "GHC_PACKAGE_PATH")
               (setenv "CONFIG_SHELL" (which "bash"))))
           (add-before 'check 'fix-testsuite
             (lambda _
               (substitute*
                 (list "testsuite/timeout/Makefile"
                       "testsuite/timeout/timeout.py"
                       "testsuite/timeout/timeout.hs"
                       "testsuite/tests/programs/life_space_leak/life.test")
                 (("/bin/sh") (which "sh"))
                 (("/bin/rm") "rm")))))))
    (native-search-paths (list (search-path-specification
                                (variable "GHC_PACKAGE_PATH")
                                (files (list
                                        (string-append "lib/ghc-" version)))
                                (file-pattern ".*\\.conf\\.d$")
                                (file-type 'directory))))
    (home-page "https://www.haskell.org/ghc")
    (synopsis "The Glasgow Haskell Compiler")
    (description
     "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
interactive environment for the functional language Haskell.")
    (license license:bsd-3)))

(define-public ghc-8.4
  (package (inherit ghc-8.0)
    (name "ghc")
    (version "8.4.4")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://www.haskell.org/ghc/dist/"
                           version "/" name "-" version "-src.tar.xz"))
       (sha256
        (base32 "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i"))))
    (native-inputs
     `(("perl" ,perl)
       ("python" ,python)               ; for tests
       ("ghostscript" ,ghostscript)     ; for tests
       ;; GHC 8.4.4 is built with GHC >= 8.0.
       ("ghc-bootstrap" ,ghc-8.0)
       ("ghc-testsuite"
        ,(origin
           (method url-fetch)
           (uri (string-append
                 "https://www.haskell.org/ghc/dist/"
                 version "/" name "-" version "-testsuite.tar.xz"))
           (sha256
            (base32
             "0s8lf9sxj7n89pjagi58b3fahnp34qvmwhnn0j1fbg6955vbrfj6"))
           (modules '((guix build utils)))
           (snippet
            ;; collections.Iterable was moved to collections.abc in Python 3.10.
            '(substitute* "testsuite/driver/testlib.py"
               (("collections\\.Iterable")
                "collections.abc.Iterable")))))))
    (arguments
     (substitute-keyword-arguments (package-arguments ghc-8.0)
       ((#:phases phases)
        #~(modify-phases #$phases
            ;; This phase patches the 'ghc-pkg' command so that it sorts the list
            ;; of packages in the binary cache it generates.
            (add-before 'build 'fix-ghc-pkg-nondeterminism
              (lambda _
                (substitute* "utils/ghc-pkg/Main.hs"
                  (("confs = map \\(path </>\\) \\$ filter \\(\".conf\" `isSuffixOf`\\) fs")
                   "confs = map (path </>) $ filter (\".conf\" `isSuffixOf`) (sort fs)"))))
            (add-after 'unpack-testsuite 'fix-shell-wrappers
              (lambda _
                (substitute* '("driver/ghci/ghc.mk"
                               "utils/mkdirhier/ghc.mk"
                               "rules/shell-wrapper.mk")
                  (("echo '#!/bin/sh'")
                   (format #f "echo '#!~a'" (which "sh"))))))
            ;; This is necessary because the configure system no longer uses
            ;; “AC_PATH_” but “AC_CHECK_”, setting the variables to just the
            ;; plain command names.
            (add-before 'configure 'set-target-programs
              (lambda* (#:key inputs #:allow-other-keys)
                (let ((binutils (assoc-ref inputs "binutils"))
                      (gcc (assoc-ref inputs "gcc"))
                      (ld-wrapper (assoc-ref inputs "ld-wrapper")))
                  (setenv "CC" (string-append gcc "/bin/gcc"))
                  (setenv "CXX" (string-append gcc "/bin/g++"))
                  (setenv "LD" (string-append ld-wrapper "/bin/ld"))
                  (setenv "NM" (string-append binutils "/bin/nm"))
                  (setenv "RANLIB" (string-append binutils "/bin/ranlib"))
                  (setenv "STRIP" (string-append binutils "/bin/strip"))
                  ;; The 'ar' command does not follow the same pattern.
                  (setenv "fp_prog_ar" (string-append binutils "/bin/ar")))))))))
    (native-search-paths (list (search-path-specification
                                (variable "GHC_PACKAGE_PATH")
                                (files (list
                                        (string-append "lib/ghc-" version)))
                                (file-pattern ".*\\.conf\\.d$")
                                (file-type 'directory))))))

(define-public ghc-8.6
  (package (inherit ghc-8.4)
    (name "ghc")
    (version "8.6.5")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://www.haskell.org/ghc/dist/"
                           version "/" name "-" version "-src.tar.xz"))
       (sha256
        (base32 "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd"))))
    (native-inputs
     `(;; GHC 8.6.5 must be built with GHC >= 8.2.
       ("ghc-bootstrap" ,ghc-8.4)
       ("ghc-testsuite"
        ,(origin
           (method url-fetch)
           (uri (string-append
                 "https://www.haskell.org/ghc/dist/"
                 version "/" name "-" version "-testsuite.tar.xz"))
           (patches (search-patches "ghc-testsuite-dlopen-pie.patch"
                                    "ghc-testsuite-grep-compat.patch"
                                    "ghc-testsuite-recomp015-execstack.patch"))
           (sha256
            (base32
             "0pw9r91g2np3i806g2f4f8z4jfdd7mx226cmdizk4swa7av1qf91"))
           (modules '((guix build utils)))
           (snippet
            ;; collections.Iterable was moved to collections.abc in Python 3.10.
            '(substitute* "testsuite/driver/testlib.py"
               (("collections\\.Iterable")
                "collections.abc.Iterable")))))
       ,@(filter (match-lambda
                   (("ghc-bootstrap" . _) #f)
                   (("ghc-testsuite" . _) #f)
                   (_ #t))
                 (package-native-inputs ghc-8.4))))
    (arguments
     (substitute-keyword-arguments (package-arguments ghc-8.4)
       ((#:make-flags make-flags ''())
        #~(cons "EXTRA_RUNTEST_OPTS=--skip-perf-tests"
                #$make-flags))
       ((#:phases phases '%standard-phases)
        #~(modify-phases #$phases
           (add-after 'install 'remove-unnecessary-references
             (lambda* (#:key outputs #:allow-other-keys)
               (substitute* (find-files (string-append (assoc-ref outputs "out") "/lib/")
                                        "settings")
                 (("/gnu/store/.*/bin/(.*)" m program) program))

               ;; Remove references to "doc" output from "out" by rewriting
               ;; the "haddock-interfaces" fields and removing the optional
               ;; "haddock-html" field in the generated .conf files.
               (let ((doc (assoc-ref outputs "doc"))
                     (out (assoc-ref outputs "out")))
                 (with-fluids ((%default-port-encoding #f))
                   (for-each (lambda (config-file)
                               (substitute* config-file
                                 (("^haddock-html: .*") "\n")
                                 (((format #f "^haddock-interfaces: ~a" doc))
                                  (string-append "haddock-interfaces: " out))))
                             (find-files (string-append out "/lib") ".conf")))
                 ;; Move the referenced files to the "out" output.
                 (for-each (lambda (haddock-file)
                             (let* ((subdir (string-drop haddock-file (string-length doc)))
                                    (new    (string-append out subdir)))
                               (mkdir-p (dirname new))
                               (rename-file haddock-file new)))
                           (find-files doc "\\.haddock$")))))
           (add-after 'unpack-testsuite 'skip-tests
             (lambda _
               ;; These two tests refer to the root user, which doesn't exist
               ;; (see <https://bugs.gnu.org/36692>).
               (substitute* "libraries/unix/tests/all.T"
                 (("^test\\('T8108'") "# guix skipped: test('T8108'"))
               (substitute* "libraries/unix/tests/libposix/all.T"
                 (("^test\\('posix010'") "# guix skipped: test('posix010'"))))))))
    (native-search-paths (list (search-path-specification
                                (variable "GHC_PACKAGE_PATH")
                                (files (list
                                        (string-append "lib/ghc-" version)))
                                (file-pattern ".*\\.conf\\.d$")
                                (file-type 'directory))))))

(define-public ghc-8.8
  (package (inherit ghc-8.6)
    (name "ghc")
    (version "8.8.4")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://www.haskell.org/ghc/dist/"
                           version "/ghc-" version "-src.tar.xz"))
       (sha256
        (base32 "0bgwbxxvdn56l91bp9p5d083gzcfdi6z8l8b17qzjpr3n8w5wl7h"))))
    (native-inputs
     `(("ghc-bootstrap" ,ghc-8.6)
       ("ghc-testsuite"
        ,(origin
           (method url-fetch)
           (uri (string-append
                 "https://www.haskell.org/ghc/dist/"
                 version "/ghc-" version "-testsuite.tar.xz"))
           (patches (search-patches "ghc-testsuite-dlopen-pie.patch"
                                    "ghc-testsuite-grep-compat.patch"
                                    "ghc-testsuite-recomp015-execstack.patch"))
           (sha256
            (base32
             "0c55pj2820q26rikhpf636sn4mjgqsxjrl94vsywrh79dxp3k14z"))
           (modules '((guix build utils)))
           (snippet
            ;; collections.Iterable was moved to collections.abc in Python 3.10.
            '(substitute* "testsuite/driver/testlib.py"
               (("collections\\.Iterable")
                "collections.abc.Iterable")))))
       ("git" ,git-minimal/pinned)                 ; invoked during tests
       ,@(filter (match-lambda
                   (("ghc-bootstrap" . _) #f)
                   (("ghc-testsuite" . _) #f)
                   (_ #t))
                 (package-native-inputs ghc-8.6))))
    (arguments
     (substitute-keyword-arguments (package-arguments ghc-8.6)
       ((#:phases phases '%standard-phases)
        #~(modify-phases #$phases
           (add-before 'build 'fix-cc-reference
             (lambda _
               (substitute* "utils/hsc2hs/Common.hs"
                 (("\"cc\"") "\"gcc\""))))
           (add-after 'unpack-testsuite 'skip-more-tests
             (lambda _
               ;; XXX: This test fails because our ld-wrapper script
               ;; mangles the response file passed to the linker.
               (substitute* "testsuite/tests/hp2ps/all.T"
                 (("^test\\('T15904'") "# guix skipped: test('T15904'"))))))))
    (native-search-paths (list (search-path-specification
                                (variable "GHC_PACKAGE_PATH")
                                (files (list
                                        (string-append "lib/ghc-" version)))
                                (file-pattern ".*\\.conf\\.d$")
                                (file-type 'directory))))))

(define-public ghc-8.10
  (package
    (inherit ghc-8.8)
    (name "ghc")
    (version "8.10.7")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://www.haskell.org/ghc/dist/"
                           version "/ghc-" version "-src.tar.xz"))
       (sha256
        (base32 "179ws2q0dinl1a39wm9j37xzwm84zfz3c5543vz8v479khigdvp3"))))
    (native-inputs
     `(;; GHC 8.10.7 must be built with GHC >= 8.6.
       ("ghc-bootstrap" ,ghc-8.6)
       ("ghc-testsuite"
        ,(origin
           (method url-fetch)
           (uri (string-append
                 "https://www.haskell.org/ghc/dist/"
                 version "/ghc-" version "-testsuite.tar.xz"))
           (patches (search-patches "ghc-testsuite-dlopen-pie.patch"
                                    "ghc-testsuite-grep-compat.patch"
                                    "ghc-testsuite-recomp015-execstack.patch"))
           (sha256
            (base32
             "1zl25gg6bpx5601k8h3cqnns1xfc0nqgwnh8jvn2s65ra3f2g1nz"))
           (modules '((guix build utils)))
           (snippet
            ;; collections.Iterable was moved to collections.abc in Python 3.10.
            '(substitute* "testsuite/driver/testlib.py"
               (("collections\\.Iterable")
                "collections.abc.Iterable")))))
       ("git" ,git-minimal/pinned)                 ; invoked during tests
       ,@(filter (match-lambda
                   (("ghc-bootstrap" . _) #f)
                   (("ghc-testsuite" . _) #f)
                   (_ #t))
                 (package-native-inputs ghc-8.8))))
    (arguments
     (substitute-keyword-arguments (package-arguments ghc-8.8)
       ((#:phases phases '%standard-phases)
        #~(modify-phases #$phases
           (add-after 'unpack-testsuite 'patch-more-shebangs
             (lambda* (#:key inputs #:allow-other-keys)
               (let ((bash (assoc-ref inputs "bash")))
                 (substitute* '("testsuite/tests/driver/T8602/T8602.script")
                   (("/bin/sh")
                    (string-append bash "/bin/sh"))))))
           ;; Mark failing tests as broken. Reason for failure is unknown.
           (add-after 'skip-more-tests 'skip-even-more-tests
             (lambda _
               (substitute* '("testsuite/tests/driver/T16521/all.T")
                 (("extra_files" all) (string-append "[" all))
                 (("\\]\\), " all)
                  (string-append all "expect_broken(0)], ")))))
           (add-after 'skip-more-tests 'skip-failing-tests-i686
             (lambda _
               (substitute* '("testsuite/tests/codeGen/should_compile/all.T")
                 (("(test\\('T15155l', )when\\(unregisterised\\(\\), skip\\)" all before)
                  (string-append before "when(arch('i386'), skip)")))
               ;; Unexpected failures:
               ;;    quasiquotation/T14028.run  T14028 [bad stderr] (dyn)
               (substitute* '("testsuite/tests/quasiquotation/all.T")
                 (("unless\\(config.have_ext_interp, skip\\),")
                  "unless(config.have_ext_interp, skip), when(arch('i386'), skip),"))))
           ;; i686 fails on CI, but (sometimes and with generous timeouts) completes
           ;; locally. The issue seems to be that the testsuite tries to run some very
           ;; broad regular expressions on output files of several megabytes in size,
           ;; which takes a long time. Since the expressions never match anything on
           ;; our builds anyways, remove them.
           ;; TODO: Merge with 'skip-failing-tests-i686 or move into snippets on
           ;; next rebuild. Note that they are required for GHC 8.10 and 9.2.
           #$@(if (string-prefix? "i686" (or (%current-target-system)
                                             (%current-system)))
               #~((add-after 'skip-failing-tests-i686 'skip-more-failing-tests-i686
                    (lambda _
                      (substitute* '("testsuite/tests/profiling/should_run/all.T")
                        (("test\\('T11627a', \\[ ")
                         "test('T11627a', [ when(arch('i386'), skip), "))
                      (substitute* '("testsuite/driver/testlib.py")
                        ((".*changes being made to the file will invalidate the code signature.*")
                         "")
                        ((".*warning: argument unused during compilation:.*")
                         "")))))
               #~())))))
    (native-search-paths (list (search-path-specification
                                (variable "GHC_PACKAGE_PATH")
                                (files (list
                                        (string-append "lib/ghc-" version)))
                                (file-pattern ".*\\.conf\\.d$")
                                (file-type 'directory))))))

(define-public ghc-8 ghc-8.10)

(define-public ghc-9.0
  (package
    (inherit ghc-8.10)
    (name "ghc")
    (version "9.0.2")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://www.haskell.org/ghc/dist/" version
                                  "/ghc-" version "-src.tar.xz"))
              (sha256
               (base32
                "15wii8can2r3dcl6jjmd50h2jvn7rlmn05zb74d2scj6cfwl43hl"))
              (patches (search-patches "ghc-9-StgCRunAsm-only-when-needed.patch"))))
    (native-inputs
     `(;; GHC 9.0.2 must be built with GHC >= 8.8
       ("ghc-bootstrap" ,ghc-8.10)
       ("ghc-testsuite"
        ,(origin
           (method url-fetch)
           (uri (string-append
                  "https://www.haskell.org/ghc/dist/"
                  version "/ghc-" version "-testsuite.tar.xz"))
           (sha256
            (base32
             "1m5fzhr4gjn9ni8gxx7ag3fkbw1rspjzgv39mnfb0nkm5mw70v3s"))
           (patches (search-patches "ghc-9.2-grep-warnings.patch"
                                    "ghc-testsuite-recomp015-execstack.patch"))
           (modules '((guix build utils)))
           (snippet
            ;; collections.Iterable was moved to collections.abc in Python 3.10.
            '(substitute* "testsuite/driver/testlib.py"
               (("collections\\.Iterable")
                "collections.abc.Iterable")))))
       ,@(filter (match-lambda
                   (("ghc-bootstrap" . _) #f)
                   (("ghc-testsuite" . _) #f)
                   (_ #t))
                 (package-native-inputs ghc-8.10))))
    (native-search-paths
     (list (search-path-specification
            (variable "GHC_PACKAGE_PATH")
            (files (list (string-append "lib/ghc-" version)))
            (file-pattern ".*\\.conf\\.d$")
            (file-type 'directory))))))

(define-public ghc-9.2
  ;; Use 8.10 to shorten the build chain.
  (let ((base ghc-8.10))
    (package
      (inherit base)
      (name "ghc")
      (version "9.2.8")
      (source (origin
                (method url-fetch)
                (uri (string-append "https://www.haskell.org/ghc/dist/" version
                                    "/ghc-" version "-src.tar.xz"))
                (sha256
                 (base32
                  "18b7ln4gx2vy62jpv3z5slv3zfxmxnmkgajznks15zglddwd24sz"))
                (patches (search-patches "ghc-9.2-cabal-support-package-path.patch"
                                         "ghc-9-StgCRunAsm-only-when-needed.patch"))))
      (arguments
       (substitute-keyword-arguments (package-arguments base)
         ((#:phases phases '%standard-phases)
          #~(modify-phases #$phases
              ;; File Common.hs has been moved to src/ in this release.
              (replace 'fix-cc-reference
                (lambda _
                  (substitute* "utils/hsc2hs/src/Common.hs"
                    (("\"cc\"") "\"gcc\""))))
              (add-after 'skip-more-tests 'skip-T21694-i686
                (lambda _
                  (substitute* '("testsuite/tests/simplCore/should_compile/all.T")
                    (("^test\\('T21694', \\[ " all)
                     (string-append all "when(arch('i386'), skip), ")))))))
         ;; Increase verbosity, so running the test suite does not time out on CI.
         ((#:make-flags make-flags ''())
          #~(cons "VERBOSE=4" #$make-flags))))
      (properties '((max-silent-time . 36000))) ; 10 hours, for i686.
      (native-inputs
       `(;; GHC 9.2 must be built with GHC >= 8.6.
         ("ghc-bootstrap" ,base)
         ("ghc-testsuite"
          ,(origin
             (method url-fetch)
             (uri (string-append
                   "https://www.haskell.org/ghc/dist/"
                   version "/ghc-" version "-testsuite.tar.xz"))
             (sha256
              (base32
               "0cmmwhcwv9fjzvmgjj85d354858qqbmqfzaz5160xqj4yl9zk225"))
             (patches (search-patches "ghc-9.2-grep-warnings.patch"
                                      "ghc-testsuite-recomp015-execstack.patch"))))
         ,@(filter (match-lambda
                     (("ghc-bootstrap" . _) #f)
                     (("ghc-testsuite" . _) #f)
                     (_ #t))
                   (package-native-inputs base))))
      (native-search-paths
       (list (search-path-specification
              (variable "GHC_PACKAGE_PATH")
              (files (list (string-append "lib/ghc-" version)))
              (file-pattern ".*\\.conf\\.d$")
              (file-type 'directory)))))))

;; Versions newer than ghc defined below (i.e. the compiler
;; haskell-build-system uses) should use ghc-next as their name to
;; ensure ghc (without version specification) and ghc-* packages are
;; always compatible. See https://issues.guix.gnu.org/issue/47335.
(define-public ghc ghc-9.2)

;; 9.4 is the last version to support the make-based build system,
;; but it boot with 9.2, only 9.0 is supported.
(define ghc-bootstrap-for-9.4 ghc-9.0)

;; We need two extra dependencies built with ghc-bootstrap-for-9.4,
;; which are duplicated here from haskell-xyz to make sure the
;; bootstraping process always works.
(define ghc-alex-bootstrap-for-9.4
  (hidden-package
    (package
     (name "ghc-alex")
     (version "3.2.6")
     (source
      (origin
        (method url-fetch)
        (uri (hackage-uri "alex" version))
        (sha256
         (base32
          "042lrkn0dbpjn5ivj6j26jzb1fwrj8c1aj18ykxja89isg0hiali"))))
     (build-system haskell-build-system)
     (arguments
       (list #:tests? #f
             #:haskell ghc-bootstrap-for-9.4))
     (native-inputs
      (list which))
     (home-page "https://www.haskell.org/alex/")
     (synopsis
      "Tool for generating lexical analysers in Haskell")
     (description
      "Alex is a tool for generating lexical analysers in Haskell.  It takes a
 description of tokens based on regular expressions and generates a Haskell
 module containing code for scanning text efficiently.  It is similar to the
 tool lex or flex for C/C++.")
     (license license:bsd-3))))

(define ghc-happy-bootstrap-for-9.4
  (hidden-package
    (package
     (name "ghc-happy")
     (version "1.20.0")
     (source
      (origin
        (method url-fetch)
        (uri (hackage-uri "happy" version))
        (sha256
         (base32
          "1346r2x5ravs5fqma65bzjragqbb2g6v41wz9maknwm2jf7kl79v"))))
     (build-system haskell-build-system)
     (arguments
       (list #:haskell ghc-bootstrap-for-9.4
             #:tests? #f))
     (home-page "https://hackage.haskell.org/package/happy")
     (synopsis "Parser generator for Haskell")
     (description "Happy is a parser generator for Haskell.  Given a grammar
 specification in BNF, Happy generates Haskell code to parse the grammar.
 Happy works in a similar way to the yacc tool for C.")
     (license license:bsd-3))))

(define-public ghc-9.4
  ;; Inherit from 9.2, which added a few fixes, but boot from 9.0 (see above).
  (let ((base ghc-9.2))
    (package
      (inherit base)
      (name "ghc-next")
      (version "9.4.4")
      (source (origin
                (method url-fetch)
                (uri (string-append "https://www.haskell.org/ghc/dist/" version
                                    "/ghc-" version "-src.tar.xz"))
                (sha256
                 (base32
                  "1qk7rlqf02s3b6m6sqqngmjq1mxnrz88h159lz6k25gddmdg5kp8"))
                (patches (search-patches "ghc-9-StgCRunAsm-only-when-needed.patch"))))
      (arguments
       (substitute-keyword-arguments (package-arguments base)
         ((#:phases phases '%standard-phases)
          #~(modify-phases #$phases
             ;; Files don’t exist any more.
             (delete 'skip-tests)))))
      (native-inputs
       `(;; GHC 9.4 must be built with GHC >= 9.0.
         ("ghc-bootstrap" ,ghc-bootstrap-for-9.4)
         ("ghc-testsuite"
          ,(origin
             (method url-fetch)
             (uri (string-append
                    "https://www.haskell.org/ghc/dist/"
                    version "/ghc-" version "-testsuite.tar.xz"))
             (sha256
              (base32
               "04p2lawxxg3nyv6frzhyjyh3arhqqyh5ka3alxa2pxhcd2hdcja3"))
             (patches (search-patches "ghc-testsuite-recomp015-execstack.patch"))))
         ("ghc-alex" ,ghc-alex-bootstrap-for-9.4)
         ("ghc-happy" ,ghc-happy-bootstrap-for-9.4)
         ,@(filter (match-lambda
                     (("ghc-bootstrap" . _) #f)
                     (("ghc-testsuite" . _) #f)
                     (_ #t))
                   (package-native-inputs base))))
      (native-search-paths
       (list (search-path-specification
              (variable "GHC_PACKAGE_PATH")
              (files (list (string-append "lib/ghc-" version)))
              (file-pattern ".*\\.conf\\.d$")
              (file-type 'directory)))))))

;;; haskell.scm ends here
onfiguration files.") (license license:gpl3+))) (define-public libcap-ng (package (name "libcap-ng") (version "0.7.10") (source (origin (method url-fetch) (uri (string-append "https://people.redhat.com/sgrubb/libcap-ng/libcap-ng-" version ".tar.gz")) (sha256 (base32 "1gzzy12agfa9ddipdf72h9y68zqqnvsjjylv4vnq6hj4w2safk58")))) (build-system gnu-build-system) (arguments `(#:configure-flags (list "--without-python"))) (home-page "https://people.redhat.com/sgrubb/libcap-ng/") (synopsis "Library for more easily working with POSIX capabilities") (description "The libcap-ng library is intended to make programming with POSIX capabilities easier than the traditional libcap library. It includes utilities that can analyse all currently running applications and print out any capabilities and whether or not it has an open ended bounding set. The included utilities are designed to let admins and developers spot apps from various ways that may be running with too much privilege.") ;; The library is lgpl2.1+, but also ships some utils which are gpl2+. (license (list license:lgpl2.1+ license:gpl2+)))) (define-public smartmontools (package (name "smartmontools") (version "7.1") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/smartmontools/smartmontools/" version "/smartmontools-" version ".tar.gz")) (sha256 (base32 "0imqb7ka4ia5573w8rnpck571pjjc9698pdjcapy9cfyk4n4swrz")))) (build-system gnu-build-system) (inputs `(("libcap-ng" ,libcap-ng))) (home-page "https://www.smartmontools.org/") (synopsis "S.M.A.R.T. harddisk control and monitoring tools") (description "The smartmontools package contains utility programs to control and monitor storage systems using the Self-Monitoring, Analysis and Reporting Technology System (@dfn{S.M.A.R.T.}) built into most modern ATA and SCSI hard disks. In many cases, these utilities will provide advanced warning of disk degradation and failure.") (license license:gpl2+))) (define-public fdupes (package (name "fdupes") (version "1.6.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/adrianlopezroche/fdupes") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "19b6vqblddaw8ccw4sn0qsqzbswlhrz8ia6n4m3hymvcxn8skpz9")))) (build-system gnu-build-system) (arguments '(#:phases (modify-phases %standard-phases (delete 'configure)) #:tests? #f ; no 'check' target #:make-flags (list "CC=gcc" (string-append "PREFIX=" (assoc-ref %outputs "out"))))) (home-page "https://github.com/adrianlopezroche/fdupes") (synopsis "Identify duplicate files") (description "fdupes is a program for identifying duplicate files residing within specified directories.") (license license:expat))) (define-public graphios (package (name "graphios") (version "2.0.3") (source (origin (method url-fetch) (uri (pypi-uri "graphios" version)) (sha256 (base32 "1h87hvc315wg6lklbf4l7csd3n5pgljwrfli1p3nasdi0izgn66i")))) (build-system python-build-system) (arguments ;; Be warned: Building with Python 3 succeeds, but the build process ;; throws a syntax error that is ignored. `(#:python ,python-2 #:phases (modify-phases %standard-phases (add-before 'build 'fix-setup.py (lambda* (#:key outputs #:allow-other-keys) ;; Fix hardcoded, unprefixed file names. (let ((out (assoc-ref outputs "out"))) (substitute* '("setup.py") (("/etc") (string-append out "/etc")) (("/usr") out) (("distro_ver = .*") "distro_ver = ''")) #t)))))) (home-page "https://github.com/shawn-sterling/graphios") (synopsis "Emit Nagios metrics to Graphite, Statsd, and Librato") (description "Graphios is a script to emit nagios perfdata to various upstream metrics processing and time-series systems. It's currently compatible with Graphite, Statsd, Librato and InfluxDB. Graphios can emit Nagios metrics to any number of supported upstream metrics systems simultaneously.") (license license:gpl2+))) (define-public ansible (package (name "ansible") (version "2.9.11") (source (origin (method url-fetch) (uri (pypi-uri "ansible" version)) (sha256 (base32 "1c9ayh61qwasgncmlw7rjx5r4g5n2cpg1d5blgn53zg7xhrx1yc8")))) (build-system python-build-system) (native-inputs `(("python-bcrypt" ,python-bcrypt) ("python-pynacl" ,python-pynacl) ("python-httplib2" ,python-httplib2) ("python-passlib" ,python-passlib) ("python-nose" ,python-nose) ("python-mock" ,python-mock) ("python-jinja2" ,python-jinja2) ("python-pyyaml" ,python-pyyaml) ("python-paramiko" ,python-paramiko))) (inputs `(("python-cryptography" ,python-cryptography) ("python-jinja2" ,python-jinja2) ("python-pyyaml" ,python-pyyaml) ("python-paramiko" ,python-paramiko))) (arguments `(#:phases (modify-phases %standard-phases ;; Several ansible commands (ansible-config, ansible-console, etc.) ;; are just symlinks to a single ansible executable. The ansible ;; executable behaves differently based on the value of ;; sys.argv[0]. This does not work well with our wrap phase, and ;; therefore the following two phases are required as a workaround. (add-after 'unpack 'hide-wrapping (lambda _ ;; Overwrite sys.argv[0] to hide the wrapper script from it. (substitute* "bin/ansible" (("import traceback" all) (string-append all " import re sys.argv[0] = re.sub(r'\\.([^/]*)-real$', r'\\1', sys.argv[0]) "))) #t)) (add-after 'install 'replace-symlinks (lambda* (#:key outputs #:allow-other-keys) ;; Replace symlinks with duplicate copies of the ansible ;; executable. (let ((out (assoc-ref outputs "out"))) (for-each (lambda (subprogram) (delete-file (string-append out "/bin/ansible-" subprogram)) (copy-file (string-append out "/bin/ansible") (string-append out "/bin/ansible-" subprogram))) (list "config" "console" "doc" "galaxy" "inventory" "playbook" "pull" "vault"))) #t))))) (home-page "https://www.ansible.com/") (synopsis "Radically simple IT automation") (description "Ansible is a radically simple IT automation system. It handles configuration management, application deployment, cloud provisioning, ad hoc task execution, and multinode orchestration---including trivializing things like zero-downtime rolling updates with load balancers.") (license license:gpl3+))) (define-public debops (package (name "debops") (version "1.1.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/debops/debops") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "052b2dykdn35pdpn9s4prawl6nl6yzih8nyf54hpvhpisvjrm1v5")) (patches (search-patches "debops-constants-for-external-program-names.patch" "debops-debops-defaults-fall-back-to-less.patch")))) (build-system python-build-system) (native-inputs `(("git" ,git))) (inputs `(("ansible" ,ansible) ("encfs" ,encfs) ("fuse" ,fuse) ("util-linux" ,util-linux) ;; for umount ("findutils" ,findutils) ("gnupg" ,gnupg) ("which" ,which))) (propagated-inputs `(("python-future" ,python-future) ("python-distro" ,python-distro))) (arguments `(#:tests? #f #:phases (modify-phases %standard-phases (add-after 'unpack 'nuke-debops-update (lambda _ (chmod "bin/debops-update" #o755) ; FIXME work-around git-fetch issue (with-output-to-file "bin/debops-update" (lambda () (format #t "#!/bin/sh echo 'debops is installed via guix. guix-update is useless in this case. Please use `guix package -u debops` instead.'"))) #t)) ;; patch shebangs only in actuall scripts, not in files included in ;; roles (which are to be delivered to the targte systems) (delete `patch-generated-file-shebangs) (replace 'patch-source-shebangs (lambda _ (for-each patch-shebang (find-files "bin" (lambda (file stat) ;; Filter out symlinks. (eq? 'regular (stat:type stat))) #:stat lstat)))) (add-after 'unpack 'fix-paths (lambda _ (define (substitute-program-names file) ;; e.g. ANSIBLE_PLAYBOOK = '/gnu/store/…/bin/ansible-playbook' (for-each (lambda (name) (let ((varname (string-upcase (string-map (lambda (c) (if (char=? c #\-) #\_ c)) name)))) (substitute* file (((string-append "^(" varname " = )'.*'") line prefix) (string-append prefix "'" (which name) "'"))))) '("ansible-playbook" "encfs" "find" "fusermount" "umount" "gpg" "ansible" "which"))) (for-each substitute-program-names '("bin/debops" "bin/debops-padlock" "bin/debops-task" "debops/__init__.py" "debops/cmds/__init__.py")) #t))))) (home-page "https://www.debops.org/") (synopsis "Collection of general-purpose Ansible roles") (description "The Ansible roles provided by that can be used to manage Debian or Ubuntu hosts. In addition, a default set of Ansible playbooks can be used to apply the provided roles in a controlled way, using Ansible inventory groups. The roles are written with a high customization in mind, which can be done using Ansible inventory. This way the role and playbook code can be shared between multiple environments, with different configuration in to each one. Services can be managed on a single host, or spread between multiple hosts. DebOps provides support for different SQL and NoSQL databases, web servers, programming languages and specialized applications useful in a data center environment or in a cluster. The project can also be used to deploy virtualization environments using KVM/libvirt, Docker or LXC technologies to manage virtual machines and/or containers.") (license license:gpl3+))) (define-public emacs-ansible-doc (let ((commit "86083a7bb2ed0468ca64e52076b06441a2f8e9e0")) (package (name "emacs-ansible-doc") (version (git-version "0.4" "1" commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/lunaryorn/ansible-doc.el") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "0lap404ch74w99n3xip176jr42b38xhyzkfnkyqg0g3wk2cd3aq8")))) (build-system emacs-build-system) ;; Unmaintained by upstream. (home-page "https://github.com/lunaryorn/ansible-doc.el") (synopsis "Ansible documentation for Emacs") (description "This package provides an Ansible documentation for GNU Emacs. @code{ansible-doc} allows you to view the documentation of an Ansible module and @code{ansible-doc-mode} minor mode adds documentation lookup to YAML Mode. You could enable the mode with @code{(add-hook 'yaml-mode-hook #'ansible-doc-mode)}.") (license license:gpl3+)))) (define-public cpulimit (package (name "cpulimit") (version "0.2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/opsengine/cpulimit") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1dz045yhcsw1rdamzpz4bk8mw888in7fyqk1q1b3m1yk4pd1ahkh")))) (build-system gnu-build-system) (arguments `(#:phases (modify-phases %standard-phases (delete 'configure) (replace 'build (lambda _ (invoke "make" "CC=gcc" "-Csrc"))) (replace 'check (lambda _ (invoke "make" "CC=gcc" "-Ctests"))) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin"))) (install-file "src/cpulimit" bin)) #t))))) (home-page "https://github.com/opsengine/cpulimit") (synopsis "Limit CPU usage") (description "Cpulimit limits the CPU usage of a process. It does not change the nice value or other scheduling priority settings, but the real CPU usage, and is able to adapt itself dynamically to the overall system load. Children processes and threads of the specified process may optionally share the same limits.") (license license:gpl2+))) (define-public autojump (package (name "autojump") (version "22.5.3") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/wting/autojump") (commit (string-append "release-v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1rgpsh70manr2dydna9da4x7p8ahii7dgdgwir5fka340n1wrcws")))) (build-system gnu-build-system) (native-inputs ; for tests `(("python-mock" ,python-mock) ("python-pytest" ,python-pytest))) (inputs `(("python" ,python-wrapper))) (arguments `(#:phases (modify-phases %standard-phases (add-after 'unpack 'make-git-checkout-writable ;; ‘install.py’ modifies files before installing them. (lambda _ (for-each make-file-writable (find-files ".")) #t)) (delete 'configure) (delete 'build) (replace 'check (lambda _ (invoke "python" "tests/unit/autojump_utils_test.py"))) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (setenv "SHELL" (which "bash")) (invoke "python" "install.py" (string-append "--destdir=" (assoc-ref outputs "out")))))))) (home-page "https://github.com/wting/autojump") (synopsis "Shell extension for file system navigation") (description "Autojump provides a faster way to navigate your file system, with a \"cd command that learns\". It works by maintaining a database of the directories you use the most from the command line and allows you to \"jump\" to frequently used directories by typing only a small pattern.") (license license:gpl3+))) (define-public fasd (package (name "fasd") (version "1.0.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/clvv/fasd") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "1awi71jdv3mhjrmar2d4z1i90kn7apd7aq1w31sh6w4yibz9kiyj")))) (build-system gnu-build-system) (arguments `(#:phases (modify-phases %standard-phases (delete 'configure)) ;no configuration #:tests? #f ;no tests #:make-flags (list (string-append "PREFIX=" %output)))) (home-page "https://github.com/clvv/fasd") (synopsis "Quick access to files and directories for shells") (description "Fasd (pronounced similar to \"fast\") is a command-line productivity booster. Fasd offers quick access to files and directories for POSIX shells. It is inspired by tools like autojump, z, and v. Fasd keeps track of files and directories you have accessed so that you can quickly reference them in the command line.") (license license:x11))) (define-public iftop (package (name "iftop") (version "1.0pre4") (source (origin (method url-fetch) (uri (string-append "http://www.ex-parrot.com/~pdw/iftop/download" "/iftop-" version ".tar.gz")) (sha256 (base32 "15sgkdyijb7vbxpxjavh5qm5nvyii3fqcg9mzvw7fx8s6zmfwczp")))) (build-system gnu-build-system) (inputs `(("libpcap" ,libpcap) ("ncurses" ,ncurses))) (synopsis "Monitor network usage") (description "Iftop does for network usage what @command{top} does for CPU usage. It listens to network traffic on a named interface and displays a table of current bandwidth usage by pairs of hosts.") (home-page "http://www.ex-parrot.com/~pdw/iftop/") (license license:gpl2+))) (define-public munge (package (name "munge") (version "0.5.14") (source (origin (method url-fetch) (uri (string-append "https://github.com/dun/munge/releases/" "download/munge-" version "/munge-" version ".tar.xz")) (sha256 (base32 "0h06sghb4rqvv1ywyd6mzsmbcgh712v6ygrff0gzm440y4ca41k6")) (modules '((guix build utils))) (snippet '(begin ;; Don't insist on write access to /var. (substitute* "src/etc/Makefile.in" (("\\$\\(INSTALL\\)(.*)localstatedir" _ middle) (string-append "-$(INSTALL)" middle "localstatedir")) (("\\$\\(MKDIR_P\\) .*(local|run)statedir.*") "")) #t)))) (inputs `(("openssl" ,openssl) ("libgcrypt" ,libgcrypt))) (build-system gnu-build-system) (arguments '(#:configure-flags (list "--localstatedir=/var" (string-append "--with-pkgconfigdir=" (assoc-ref %outputs "out") "/lib/pkgconfig")) #:phases (modify-phases %standard-phases ;; XXX Many test series fail. Some might be fixable, others do no-no ;; things like invoking ‘sudo’. (add-after 'unpack 'skip-failing-tests (lambda _ (for-each (lambda (test) (substitute* "t/Makefile.in" (((string-append test "\\.t ")) ""))) (list "0100-munged-lock" "0010-basic" "0011-munged-cmdline" "0012-munge-cmdline" "0013-unmunge-cmdline" "0101-munged-security-socket" "0102-munged-security-keyfile" "0103-munged-security-logfile" "0110-munged-origin-addr")) #t))))) (home-page "https://dun.github.io/munge/") (synopsis "Cluster computing authentication service") (description "Munge is an authentication service for creating and validating credentials. It allows a process to authenticate the UID and GID of another local or remote process within a group of hosts having common users and groups. These hosts form a security realm that is defined by a shared cryptographic key. Clients within this security realm can create and validate credentials without the use of root privileges, reserved ports, or platform-specific methods.") (license license:gpl3+))) (define-public audit (package (name "audit") (home-page "https://people.redhat.com/sgrubb/audit/") (version "2.8.5") (source (origin (method url-fetch) (uri (string-append home-page "audit-" version ".tar.gz")) (sha256 (base32 "1dzcwb2q78q7x41shcachn7f4aksxbxd470yk38zh03fch1l2p8f")))) (build-system gnu-build-system) (arguments `(#:configure-flags (list "--with-python=no" "--disable-static"))) (inputs `(("openldap" ,openldap) ("gnutls" ,gnutls) ("sasl" ,cyrus-sasl))) (synopsis "User-space component to the Linux auditing system") (description "auditd is the user-space component to the Linux auditing system, which allows logging of system calls made by user-land processes. It's responsible for writing audit records to the disk. Viewing the logs is done with the @code{ausearch} or @code{aureport} utilities. Configuring the audit rules is done with the @code{auditctl} utility.") (license license:gpl2+))) (define-public nmap (package (name "nmap") (version "7.80") (source (origin (method url-fetch) (uri (string-append "https://nmap.org/dist/nmap-" version ".tar.bz2")) (sha256 (base32 "1aizfys6l9f9grm82bk878w56mg0zpkfns3spzj157h98875mypw")) (modules '((guix build utils))) (snippet '(begin (for-each delete-file-recursively ;; Remove bundled lua, pcap, and pcre libraries. ;; FIXME: Remove bundled liblinear once packaged. '("liblua" "libpcap" "libpcre" ;; Remove pre-compiled binares. "mswin32")) #t)))) (build-system gnu-build-system) (inputs `(("openssl" ,openssl) ("libpcap" ,libpcap) ("pcre" ,pcre) ("lua" ,lua) ("zlib" ,zlib) ;for NSE compression support ;; For 'ndiff'. ("python" ,python-2))) ;; TODO Add zenmap output. (outputs '("out" "ndiff")) (arguments `(#:configure-flags '("--without-zenmap") #:phases (modify-phases %standard-phases (add-after 'configure 'patch-Makefile (lambda _ (substitute* "Makefile" ;; Do not attempt to build lua. (("build-dnet build-lua") "build-dnet")) #t)) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (define (make out . args) (apply invoke "make" (string-append "prefix=" out) args)) (define (python-path dir) (string-append dir "/lib/python" ,(version-major+minor (package-version python)) "/site-packages")) (let ((out (assoc-ref outputs "out")) (ndiff (assoc-ref outputs "ndiff"))) (for-each mkdir-p (list out ndiff)) (make out "install-nmap" "install-nse" "install-ncat" "install-nping") (make ndiff "install-ndiff") (wrap-program (string-append ndiff "/bin/ndiff") `("PYTHONPATH" prefix (,(python-path ndiff))))) #t)) ;; These are the tests that do not require network access. (replace 'check (lambda _ (invoke "make" "check-nse" "check-ndiff" "check-dns")))) ;; Nmap can't cope with out-of-source building. #:out-of-source? #f)) (home-page "https://nmap.org/") (synopsis "Network discovery and security auditing tool") (description "Nmap (\"Network Mapper\") is a network discovery and security auditing tool. It is also useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime. It also provides an advanced netcat implementation (ncat), a utility for comparing scan results (ndiff), and a packet generation and response analysis tool (nping).") ;; This package uses nmap's bundled versions of libdnet and liblinear, which ;; both use a 3-clause BSD license. (license (list license:nmap license:bsd-3)))) (define-public dstat (package (name "dstat") (version "0.7.4") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/dagwieers/dstat") (commit (string-append "v" version)))) (file-name (git-file-name "dstat" version)) (sha256 (base32 "1qnmkhqmjd1m3if05jj29dvr5hn6kayq9bkkkh881w472c0zhp8v")) (patches (search-patches "dstat-fix-crash-when-specifying-delay.patch" "dstat-skip-devices-without-io.patch")))) (build-system gnu-build-system) (arguments `(#:tests? #f ; no make check #:make-flags (let ((out (assoc-ref %outputs "out"))) (list (string-append "DESTDIR=" out) "prefix=/")) #:phases (modify-phases %standard-phases (add-after 'unpack 'fix-python3-DeprecationWarning (lambda _ (substitute* "dstat" (("collections") "collections.abc")) #t)) (delete 'configure) ; no configure script (add-after 'install 'wrap (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (wrap-program (string-append out "/bin/dstat") `("PYTHONPATH" ":" prefix (,(getenv "PYTHONPATH")))) #t)))))) (inputs `(("python" ,python-wrapper) ("python-six" ,python-six))) (synopsis "Versatile resource statistics tool") (description "Dstat is a versatile replacement for @command{vmstat}, @command{iostat}, @command{netstat}, and @command{ifstat}. Dstat overcomes some of their limitations and adds some extra features, more counters and flexibility. Dstat is handy for monitoring systems during performance tuning tests, benchmarks or troubleshooting. Dstat allows you to view all of your system resources in real-time, you can, e.g., compare disk utilization in combination with interrupts from your IDE controller, or compare the network bandwidth numbers directly with the disk throughput (in the same interval).") (home-page "http://dag.wiee.rs/home-made/dstat/") (license license:gpl2+))) (define-public thefuck (package (name "thefuck") (version "3.30") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/nvbn/thefuck") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "0fnf78956pwhb9cgv1jmgypnkma5xzflkivfrkfiadbgin848yfg")) (patches (search-patches "thefuck-test-environ.patch")))) (build-system python-build-system) (arguments '(#:phases (modify-phases %standard-phases (delete 'check) (add-after 'install 'check (lambda* (#:key inputs outputs #:allow-other-keys) ;; Tests look for installed package (add-installed-pythonpath inputs outputs) ;; Some tests need write access to $HOME. (setenv "HOME" "/tmp") (invoke "py.test" "-v") #t))))) (propagated-inputs `(("python-colorama" ,python-colorama) ("python-decorator" ,python-decorator) ("python-psutil" ,python-psutil) ("python-pyte" ,python-pyte) ("python-six" ,python-six))) (native-inputs `(("go" ,go) ("python-mock" ,python-mock) ("python-pytest" ,python-pytest) ("python-pytest-mock" ,python-pytest-mock))) (home-page "https://github.com/nvbn/thefuck") (synopsis "Correct mistyped console command") (description "The Fuck tries to match a rule for a previous, mistyped command, creates a new command using the matched rule, and runs it.") (license license:x11))) (define-public di (package (name "di") (version "4.48") (source (origin (method url-fetch) (uri (string-append "https://gentoo.com/di/di-" version ".tar.gz")) (sha256 (base32 "0crvvfsxh8ryc0j19a2x52i9zacvggm8zi6j3kzygkcwnpz4km8r")))) (build-system gnu-build-system) (arguments `(#:tests? #f ; obscure test failures #:phases (modify-phases %standard-phases (delete 'configure) ; no configure script (add-before 'build 'setup-environment (lambda* (#:key outputs #:allow-other-keys) (setenv "CC" ,(cc-for-target)) (setenv "prefix" (assoc-ref outputs "out")) #t))) #:make-flags (list "--environment-overrides"))) (home-page "https://gentoo.com/di/") (synopsis "Advanced df like disk information utility") (description "@code{di} is a disk information utility, displaying everything that your @code{df} command does and more. It features the ability to display your disk usage in whatever format you prefer. It is designed to be highly portable and produce uniform output across heterogeneous networks.") (license license:zlib))) (define-public cbatticon (package (name "cbatticon") (version "1.6.10") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/valr/cbatticon") (commit version))) (sha256 (base32 "0ivm2dzhsa9ir25ry418r2qg2llby9j7a6m3arbvq5c3kaj8m9jr")) (file-name (git-file-name name version)))) (build-system gnu-build-system) (arguments `(#:tests? #f ; no tests #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) "CC=gcc") #:phases (modify-phases %standard-phases (delete 'configure)))) ; no configure script (inputs `(("gtk+" ,gtk+) ("gettext" ,gettext-minimal) ("libnotify" ,libnotify))) (native-inputs `(("pkg-config" ,pkg-config))) (synopsis "Lightweight battery icon for the system tray") (description "cbatticon is a lightweight battery icon that displays the status of your battery in the system tray.") (home-page "https://github.com/valr/cbatticon") (license license:gpl2+))) (define-public interrobang (let ((revision "1") (commit "896543735e1c99144765fdbd7b6e6b5afbd8b881")) (package (name "interrobang") (version (git-version "0.0.0" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/TrilbyWhite/interrobang") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "1n13m70p1hfba5dy3i8hfclbr6k9q3d9dai3dg4jvhdhmxcpjzdf")))) (build-system gnu-build-system) (arguments `(#:tests? #f ; no tests #:phases (modify-phases %standard-phases (delete 'configure)) ; no configure script #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))))) (inputs `(("libx11" ,libx11))) (native-inputs `(("pkg-config" ,pkg-config))) (synopsis "Scriptable launcher menu") (description "Interrobang is a scriptable launcher menu with a customizable shortcut syntax and completion options.") (home-page "https://github.com/TrilbyWhite/interrobang") (license license:gpl3+)))) (define-public pam-krb5 (package (name "pam-krb5") (version "4.8") (source (origin (method url-fetch) (uri (string-append "https://archives.eyrie.org/software/kerberos/" "pam-krb5-" version ".tar.xz")) (patches (search-patches "pam-krb5-CVE-2020-10595.patch")) (sha256 (base32 "1qjp8i1s9bz7g6kiqrkzzkxn5pfspa4sy53b6z40fqmdf9przdfb")))) (build-system gnu-build-system) (arguments `(#:phases (modify-phases %standard-phases (add-before 'configure 'disable-tests (lambda _ ;; The build container seems to interfere with some tests. (substitute* "tests/TESTS" (("module/basic\n") "")) (substitute* "tests/TESTS" (("pam-util/vector\n") "")) #t))))) (inputs `(("linux-pam" ,linux-pam) ("mit-krb5" ,mit-krb5))) (native-inputs `(("perl" ,perl) ("perl-test-pod" ,perl-test-pod))) ; required for tests (synopsis "Kerberos PAM module") (description "Pam-krb5 is a Kerberos PAM module for either MIT Kerberos or Heimdal. It supports ticket refreshing by screen savers, configurable authorization handling, authentication of non-local accounts for network services, password changing, and password expiration, as well as all the standard expected PAM features. It works correctly with OpenSSH, even with @code{ChallengeResponseAuthentication} and @code{PrivilegeSeparation} enabled, and supports extensive configuration either by PAM options or in krb5.conf or both. PKINIT is supported with recent versions of both MIT Kerberos and Heimdal and FAST is supported with recent MIT Kerberos.") (home-page "https://www.eyrie.org/~eagle/software/pam-krb5") ;; Dual licenced under a homebrew non-copyleft OR GPL (any version) ;; However, the tarball does not contain a copy of the GPL, so unless ;; we put one in, we cannot distribute it under GPL without violating ;; clause requiring us to give all recipients a copy. (license license:gpl1+))) (define (sunxi-tools-source version) (origin (method git-fetch) (uri (git-reference (url "https://github.com/linux-sunxi/sunxi-tools") (commit (string-append "v" version)))) (sha256 (base32 "04f3jqg8ww4jxsf9c6ddcdgy2xbhkyp0b3l5f1hvvbv94p81rjxd")) (modules '((guix build utils))) (snippet ;; Remove binaries contained in the tarball which are only for the ;; target and can be regenerated anyway. '(begin (delete-file-recursively "bin") #t)) (file-name (git-file-name "sunxi-tools" version)))) (define sunxi-target-tools (package (name "sunxi-target-tools") (version "1.4.2") (build-system gnu-build-system) (source (sunxi-tools-source version)) (arguments `(#:system "armhf-linux" #:tests? #f #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) (string-append "CROSS_COMPILE=") "CC=gcc") #:phases (modify-phases %standard-phases (delete 'configure) (replace 'build (lambda* (#:key make-flags #:allow-other-keys) (apply invoke "make" "target-tools" make-flags))) (replace 'install (lambda* (#:key make-flags #:allow-other-keys) (apply invoke "make" "install-target-tools" make-flags)))))) (home-page "https://github.com/linux-sunxi/sunxi-tools") (synopsis "Hardware management tools for Allwinner computers") (description "This package contains tools for Allwinner devices: @enumerate @item @command{sunxi-meminfo}: Prints memory bus settings. @end enumerate") (license license:gpl2+))) (define-public sunxi-tools (package (name "sunxi-tools") (version "1.4.2") (source (sunxi-tools-source version)) (native-inputs `(("sunxi-target-tools" ,sunxi-target-tools) ("pkg-config" ,pkg-config))) (inputs `(("libusb" ,libusb))) (build-system gnu-build-system) (arguments `(#:tests? #f ; no tests exist #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) (string-append "CROSS_COMPILE=disabled") "CC=gcc") #:phases (modify-phases %standard-phases (delete 'configure) (replace 'build (lambda* (#:key make-flags #:allow-other-keys) (apply invoke "make" "tools" "misc" make-flags))) (replace 'install (lambda* (#:key inputs outputs make-flags #:allow-other-keys) ;; Those tools have been built for armhf but are part of the ;; installation in the upstream package. So do the same ;; here. (copy-recursively (assoc-ref inputs "sunxi-target-tools") (assoc-ref outputs "out")) (apply invoke "make" "install-tools" "install-misc" make-flags)))))) (home-page "https://github.com/linux-sunxi/sunxi-tools") (synopsis "Hardware management tools for Allwinner computers") (description "This package contains tools for Allwinner devices: @enumerate @item @command{sunxi-fexc}, @command{bin2fex}, @command{fex2bin}: Compile a textual description of a board (.fex) to a binary representation (.bin). @item @command{sunxi-fel}: Puts an Allwinner device into FEL mode which makes it register as a special USB device (rather than USB host). You can then connect it to another computer and flash it from there. @item @command{sunxi-nand-part}: Partitions NAND flash. @item @command{sunxi-bootinfo}: Reads out boot0 and boot1 (Allwinner bootloader) parameters. @item @command{sunxi-pio}: Sets GPIO parameters and oscillates a GPIO in order to be able to find it. @item @command{sunxi-meminfo}: Prints memory bus settings. @item @command{sunxi-nand-image-builder}: Prepares raw NAND images. @end enumerate") (license license:gpl2+))) (define-public sedsed (package (name "sedsed") (version "1.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/aureliojargas/sedsed") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "05cl35mwljdb9ynbbsfa8zx6ig8r0xncbg2cir9vwn5manndjj18")))) (build-system python-build-system) (arguments `(#:tests? #f ; no tests #:phases (modify-phases %standard-phases (add-after 'unpack 'patch-sed-in (lambda _ (substitute* "sedsed.py" (("sedbin = 'sed'") (string-append "sedbin = '" (which "sed") "'"))) #t)) (delete 'build) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin"))) ;; Just one file to copy around (install-file "sedsed.py" bin) #t))) (add-after 'wrap 'symlink ;; Create 'sedsed' symlink to "sedsed.py". (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin")) (sed (string-append bin "/sedsed")) (sedpy (string-append bin "/sedsed.py"))) (symlink sedpy sed) #t)))))) (home-page "https://aurelio.net/projects/sedsed") (synopsis "Sed sed scripts") (description "@code{sedsed} can debug, indent, tokenize and HTMLize your @command{sed} script. In debug mode, it reads your script and adds extra commands to it. When executed you can see the data flow between the commands, revealing all the magic sed performs on its internal buffers. In indent mode, your script is reformatted with standard spacing. In tokenize mode, you can see the elements of every command you use. In HTMLize mode, your script is converted to a beautiful colored HTML file, with all the commands and parameters identified for your viewing pleasure. With sedsed you can master any sed script. No more secrets, no more hidden buffers.") (license license:expat))) (define-public igt-gpu-tools (package (name "igt-gpu-tools") (version "1.24") (source (origin (method git-fetch) (uri (git-reference (url "https://gitlab.freedesktop.org/drm/igt-gpu-tools.git") (commit (string-append "igt-gpu-tools-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1gpdjs5aj6vsnzwcjvw5bb120lgffvvshi4202phr0bzw3b92ky8")))) (build-system gnu-build-system) (arguments `(#:tests? #f)) ; many of the tests try to load kernel modules (inputs `(("cairo" ,cairo) ("elfutils" ,elfutils) ; libdw ("eudev" ,eudev) ("glib" ,glib) ("kmod" ,kmod) ("libdrm" ,libdrm) ("libpciaccess" ,libpciaccess) ("libunwind" ,libunwind) ("libxrandr" ,libxrandr) ("openssl" ,openssl) ("procps" ,procps) ("util-macros" ,util-macros))) (native-inputs `(("autoconf" ,autoconf) ("automake" ,automake) ("libtool" ,libtool) ("pkg-config" ,pkg-config))) (home-page "https://gitlab.freedesktop.org/drm/igt-gpu-tools") (synopsis "Tools for development and testing of the Intel DRM driver") (description "IGT GPU Tools is a collection of tools for development and testing of the Intel DRM driver. There are many macro-level test suites that get used against the driver, including xtest, rendercheck, piglit, and oglconform, but failures from those can be difficult to track down to kernel changes, and many require complicated build procedures or specific testing environments to get useful results. Therefore, IGT GPU Tools includes low-level tools and tests specifically for development and testing of the Intel DRM Driver.") (supported-systems '("i686-linux" "x86_64-linux")) (license license:expat))) (define-public fabric (package (name "fabric") (version "1.14.1") (source (origin (method url-fetch) (uri (pypi-uri "Fabric" version)) (sha256 (base32 "1a3ndlpdw6bhn8fcw1jgznl117a8pnr84az9rb5fwnrypf1ph2b6")))) (build-system python-build-system) (arguments `(#:python ,python-2 ; Python 2 only #:phases (modify-phases %standard-phases (replace 'check (lambda _ (invoke "nosetests" "-v" "tests/" ;; This test hangs indefinitely when run on a single core VM ;; (see GNU bug #26647 and Debian bug #850230). "--exclude=test_nested_execution_with_explicit_ports" ;; This test randomly fails in certain environments causing too ;; much noise to be useful (see Debian bug #854686). "--exclude=test_should_use_sentinel_for_tasks_that_errored")))))) (native-inputs `(("python2-fudge" ,python2-fudge) ; Requires < 1.0 ("python2-jinja2" ,python2-jinja2) ; Requires < 3.0 ("python2-nose" ,python2-nose) ; Requires < 2.0 ("python2-pynacl" ,python2-pynacl) ("python2-bcrypt" ,python2-bcrypt))) (propagated-inputs `(("python2-paramiko" ,python2-paramiko))) (home-page "https://www.fabfile.org/") (synopsis "Simple Pythonic remote execution and deployment tool") (description "Fabric is designed to upload files and run shell commands on a number of servers in parallel or serially. These commands are grouped in tasks (which are regular Python functions) and specified in a @dfn{fabfile}. It is similar to Capistrano, except it's implemented in Python and doesn't expect you to be deploying Rails applications. Fabric is a simple, Pythonic tool for remote execution and deployment.") (license license:bsd-2))) (define-public neofetch (package (name "neofetch") (version "7.0.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/dylanaraps/neofetch") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "0xc0fdc7n5bhqirh83agqiy8r14l14zwca07czvj8vgnsnfybslr")))) (build-system gnu-build-system) (arguments `(#:tests? #f ; there are no tests #:make-flags (list (string-append "PREFIX=" %output)) #:phases (modify-phases %standard-phases (delete 'configure)))) ; no configure script (home-page "https://github.com/dylanaraps/neofetch") (synopsis "System information script") (description "Neofetch is a command-line system information tool written in Bash. Neofetch displays information about your system next to an image, your OS logo, or any ASCII file of your choice. The main purpose of Neofetch is to be used in screenshots to show other users what operating system or distribution you are running, what theme or icon set you are using, etc.") (license license:expat))) (define-public screenfetch (package (name "screenfetch") (version "3.9.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/KittyKatt/screenFetch") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "04l8aqr474pb115nagn9f6y48jw92n1qfszgw7dbhgl4mpn95lcr")))) (build-system trivial-build-system) (arguments `(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (let ((source (assoc-ref %build-inputs "source")) (out (assoc-ref %outputs "out"))) (mkdir-p (string-append out "/bin/")) (copy-file (string-append source "/screenfetch-dev") (string-append out "/bin/screenfetch")) (install-file (string-append source "/screenfetch.1") (string-append out "/man/man1/")) (install-file (string-append source "/COPYING") (string-append out "/share/doc/" ,name "-" ,version)) (substitute* (string-append out "/bin/screenfetch") (("/usr/bin/env bash") (string-append (assoc-ref %build-inputs "bash") "/bin/bash"))) (wrap-program (string-append out "/bin/screenfetch") `("PATH" ":" prefix (,(string-append (assoc-ref %build-inputs "bc") "/bin:" (assoc-ref %build-inputs "scrot") "/bin:" (assoc-ref %build-inputs "xdpyinfo") "/bin" (assoc-ref %build-inputs "xprop") "/bin")))) (substitute* (string-append out "/bin/screenfetch") (("#!#f") (string-append "#!" (assoc-ref %build-inputs "bash") "/bin/bash"))))))) (inputs `(("bash" ,bash) ("bc" ,bc) ("scrot" ,scrot) ("xdpyinfo" ,xdpyinfo) ("xprop" ,xprop))) (home-page "https://github.com/KittyKatt/screenFetch") (synopsis "System information script") (description "Bash screenshot information tool which can be used to generate those nifty terminal theme information and ASCII distribution logos in everyone's screenshots nowadays.") (license license:gpl3))) (define-public ufetch (let ((commit "98b622023e03fe24dbc137e9a68104dfe1fbd04a") (revision "1")) (package (name "ufetch") (version (git-version "0.2" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://gitlab.com/jschx/ufetch.git") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "09c4zmikza16xpydinnqbi3hmcibfrrn10wij7j0j1wv1pj2sl2l")))) (build-system trivial-build-system) (inputs `(("bash" ,bash) ("tput" ,ncurses))) (arguments `(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (let* ((source (assoc-ref %build-inputs "source")) (output (assoc-ref %outputs "out")) (bindir (string-append output "/bin")) (docdir (string-append output "/share/doc/ufetch-" ,version)) (tput (string-append (assoc-ref %build-inputs "tput") "/bin/tput"))) (install-file (string-append source "/LICENSE") docdir) (setenv "PATH" (string-append (assoc-ref %build-inputs "bash") "/bin")) (mkdir-p bindir) (for-each (lambda (src) (let ((dst (string-append bindir "/" (basename src)))) (copy-file src dst) (patch-shebang dst) (substitute* dst (("tput") tput)))) (find-files source "ufetch-[[:alpha:]]*$")) ;; Note: the `ufetch` we create below will only work if run under ;; the Guix System. I.e. a user trying to run `ufetch` on a ;; foreign distro will not get great results. The `screenfetch` ;; program does actual runtime detection of the operating system, ;; and would be a better choice in such a situation. (symlink "ufetch-guix" (string-append bindir "/ufetch")))))) (home-page "https://gitlab.com/jschx/ufetch") (synopsis "Tiny system info") (description "This package provides a tiny system info utility.") (license license:isc)))) (define-public pfetch (let ((commit "e18a0959ab98b963744755ec4687e59dc11db3c5") (revision "0")) (package (name "pfetch") (version (git-version "0.7.0" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/dylanaraps/pfetch") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "1md40av6i3xvvwig5jzhy4kf3s5sgxxk35r0vcyrjd8qyndk927l")))) (build-system trivial-build-system) (inputs `(("bash" ,bash))) (arguments `(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (let* ((source (lambda (f) (string-append (assoc-ref %build-inputs "source") "/" f))) (output (assoc-ref %outputs "out")) (docdir (string-append output "/share/doc/pfetch-" ,version))) (install-file (source "LICENSE.md") docdir) (install-file (source "README.md") docdir) (install-file (source "pfetch") (string-append output "/bin")) (patch-shebang (string-append output "/bin/pfetch") (list (string-append (assoc-ref %build-inputs "bash") "/bin"))) #t)))) (home-page "https://github.com/dylanaraps/pfetch") (synopsis "System information tool") (description "This package provides a simple, configurable system information tool.") (license license:expat)))) (define-public nnn (package (name "nnn") (version "3.3") (source (origin (method url-fetch) (uri (string-append "https://github.com/jarun/nnn/releases/download/v" version "/nnn-v" version ".tar.gz")) (sha256 (base32 "1jiaygylwrlz6rlls1q69xw10j6ypr96yshsbzisg0adk37lbchn")))) (build-system gnu-build-system) (inputs `(("ncurses" ,ncurses) ("readline" ,readline))) (native-inputs `(("pkg-config" ,pkg-config))) (arguments '(#:tests? #f ; no tests #:phases (modify-phases %standard-phases (delete 'configure)) ; no configure script #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) "CC=gcc"))) (home-page "https://github.com/jarun/nnn") (synopsis "Terminal file browser") (description "@command{nnn} is a fork of @command{noice}, a blazing-fast lightweight terminal file browser with easy keyboard shortcuts for navigation, opening files and running tasks. There is no config file and mime associations are hard-coded. The incredible user-friendliness and speed make it a perfect utility on modern distros.") (license license:bsd-2))) (define-public thermald (package (name "thermald") (version "1.9.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/01org/thermal_daemon") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0iagc3jqpnh6q2fa1gx4wx6r8qg0556j60xr159zqg95djr4dv99")))) (build-system gnu-build-system) (arguments `(#:configure-flags (let ((out (assoc-ref %outputs "out"))) (list (string-append "--sysconfdir=" out "/etc") (string-append "--with-dbus-sys-dir=" out "/etc/dbus-1/system.d") "--localstatedir=/var")))) (native-inputs `(("autoconf" ,autoconf) ("automake" ,automake) ("glib" ,glib "bin") ; for glib-genmarshal, etc. ("pkg-config" ,pkg-config))) (inputs `(("dbus-glib" ,dbus-glib) ("libxml2" ,libxml2))) (home-page "https://01.org/linux-thermal-daemon/") (synopsis "CPU scaling for thermal management") (description "The Linux Thermal Daemon helps monitor and control temperature on systems running the Linux kernel.") ;; arm and aarch64 don't have cpuid.h. (supported-systems '("i686-linux" "x86_64-linux")) (license license:gpl2+))) (define-public masscan (package (name "masscan") (version "1.0.5") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/robertdavidgraham/masscan") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "0q0c7bsf0pbl8napry1qyg0gl4pd8wn872h4mz9b56dx4rx90vqg")))) (build-system gnu-build-system) (inputs `(("libpcap" ,libpcap))) (arguments '(#:test-target "regress" #:make-flags (list "CC=gcc" (string-append "PREFIX=" (assoc-ref %outputs "out"))) #:phases (modify-phases %standard-phases (delete 'configure) ; no ./configure script (add-after 'unpack 'patch-path (lambda* (#:key outputs inputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (pcap (assoc-ref inputs "libpcap"))) (substitute* "src/rawsock-pcap.c" (("libpcap.so") (string-append pcap "/lib/libpcap.so"))) #t)))))) (synopsis "TCP port scanner") (description "MASSCAN is an asynchronous TCP port scanner. It can detect open ports, and also complete the TCP connection and interact with the remote application, collecting the information received.") (home-page "https://github.com/robertdavidgraham/masscan") ;; 'src/siphash24.c' is the SipHash reference implementation, which ;; bears a CC0 Public Domain Dedication. (license license:agpl3+))) (define-public hungrycat (package (name "hungrycat") (version "0.4.1") (source (origin (method url-fetch) (uri (string-append "https://github.com/jwilk/hungrycat/" "releases/download/" version "/" "hungrycat-" version ".tar.gz")) (sha256 (base32 "03fc1zsrf99lvxa7b4ps6pbi43304wbxh1f6ci4q0vkal370yfwh")))) (build-system gnu-build-system) (native-inputs ;; For tests. `(("python" ,python-wrapper) ("python-nose" ,python-nose))) (arguments `(#:test-target "test")) (synopsis "A single tool that combines @command{cat} & @command{rm}") (description "hungrycat prints the contents of a file to standard output, while simultaneously freeing the disk space it occupied. It is useful if you need to process a large file, don't have enough space to store both the input and output files, and don't need the input file afterwards. While similar in principle to running @command{cat} immediately followed by @command{rm}, @command{hungrycat} actually frees blocks as soon as they are printed instead of after the entire file has been read, which is often too late.") (home-page "https://jwilk.net/software/hungrycat") (license license:expat))) (define-public launchmon (package (name "launchmon") (version "1.0.2") (source (origin (method url-fetch) (uri (string-append "https://github.com/LLNL/LaunchMON/releases/download/v" version "/launchmon-v" version ".tar.gz")) (sha256 (base32 "0fm3nd9mydm9v2bf7bh01dbgrfnpwkapxa3dsvy3x1z0rz61qc0x")) (modules '((guix build utils))) (snippet '(begin ;; Fix build failure with GCC 7 due to a conversion error. ;; Remove for versions > 1.0.2. (substitute* "launchmon/src/linux/lmon_api/lmon_coloc_spawner.cxx" ((" lmonpl = '\\\\0'") " *lmonpl = '\\0'")) #t)))) (build-system gnu-build-system) (inputs `(("mpi" ,openmpi) ("munge" ,munge) ("boost" ,boost) ("libelf" ,libelf) ("libgcrypt" ,libgcrypt) ("libgpg-error" ,libgpg-error))) (synopsis "Infrastructue for large scale tool daemon launching") (description "LaunchMON is a software infrastructure that enables HPC run-time tools to co-locate tool daemons with a parallel job. Its API allows a tool to identify all the remote processes of a job and to scalably launch daemons into the relevant nodes.") (home-page "https://github.com/LLNL/LaunchMON") (supported-systems '("i686-linux" "x86_64-linux")) (license license:lgpl2.1))) (define-public spindle (package (name "spindle") (version "0.10") (source (origin ;; We use git checkout to avoid github auto-generated tarballs (method git-fetch) (uri (git-reference (url "https://github.com/hpc/Spindle") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "15n3ay0qq81r5v7fif61q1vdjcq44pp2nynkh3fvbzc9fj3c39wd")))) (build-system gnu-build-system) (arguments '(#:configure-flags '("--enable-sec-launchmon" "--enable-sec-munge" "--enable-sec-none"))) (inputs `(("mpi" ,openmpi) ("munge" ,munge) ("launchmon" ,launchmon) ("libgcrypt" ,libgcrypt))) (synopsis "Scalable library loading in HPC environments") (description "Spindle is a tool for improving the performance of dynamic library and Python loading in HPC environments.") (home-page "https://github.com/hpc/Spindle") ;; This package supports x86_64 and PowerPC64 (supported-systems '("x86_64-linux")) (license license:lgpl2.1))) (define-public inxi-minimal (let ((real-name "inxi")) (package (name "inxi-minimal") (version "3.1.04-1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/smxi/inxi") (commit version))) (file-name (git-file-name real-name version)) (sha256 (base32 "1mirnrrqfjyl2r7fwnpjlk37i5hf8f7lxv2yxcbdfjf2b3dfbpvl")))) (build-system trivial-build-system) (inputs `(("bash" ,bash-minimal) ("perl" ,perl) ("procps" ,procps))) (native-inputs `(("gzip" ,gzip))) (arguments `(#:modules ((guix build utils) (ice-9 match) (srfi srfi-26)) #:builder (begin (use-modules (guix build utils) (ice-9 match) (srfi srfi-26)) (setenv "PATH" (string-append (assoc-ref %build-inputs "bash") "/bin" ":" (assoc-ref %build-inputs "gzip") "/bin" ":" (assoc-ref %build-inputs "perl") "/bin" ":")) (copy-recursively (assoc-ref %build-inputs "source") ,(string-append real-name "-" version)) (with-directory-excursion ,(string-append real-name "-" version) (with-fluids ((%default-port-encoding #f)) (substitute* "inxi" (("/usr/bin/env perl") (which "perl")))) (let ((bin (string-append %output "/bin"))) (install-file "inxi" bin) (wrap-program (string-append bin "/inxi") `("PATH" ":" = ("$PATH" ,@(map (lambda (input) (match input ((name . store) (let ((store-append (cut string-append store <>))) (cond ((member name '("util-linux")) (string-append (store-append "/bin") ":" (store-append "/sbin"))) ((member name '("dmidecode" "iproute2")) (store-append "/sbin")) (else (store-append "/bin"))))))) %build-inputs))) `("PERL5LIB" ":" = ,(delete "" (map (match-lambda (((? (cut string-prefix? "perl-" <>) name) . dir) (string-append dir "/lib/perl5/site_perl")) (_ "")) %build-inputs))))) (invoke "gzip" "inxi.1") (install-file "inxi.1.gz" (string-append %output "/share/man/man1"))) #t))) (home-page "https://smxi.org/docs/inxi.htm") (synopsis "Full-featured system information script") (description "Inxi is a system information script that can display various things about your hardware and software to users in an IRC chatroom or support forum. It runs with the @code{/exec} command in most IRC clients.") (license license:gpl3+)))) (define-public inxi (package (inherit inxi-minimal) (name "inxi") (inputs `(("dmidecode" ,dmidecode) ("file" ,file) ("bind:utils" ,isc-bind "utils") ; dig ("gzip" ,gzip) ("iproute2" ,iproute) ; ip ("kmod" ,kmod) ; modinfo ("lm-sensors" ,lm-sensors) ("mesa-utils" ,mesa-utils) ("pciutils" ,pciutils) ("tar" ,tar) ("tree" ,tree) ("util-linux" ,util-linux) ; lsblk ("usbutils" ,usbutils) ; lsusb ("wmctrl" ,wmctrl) ("xdpyinfo" ,xdpyinfo) ("xprop" ,xprop) ("xrandr" ,xrandr) ("coreutils" ,coreutils) ; uptime ("inetutils" ,inetutils) ; ifconfig ("perl-cpanel-json-xs" ,perl-cpanel-json-xs) ("perl-http-tiny" ,perl-http-tiny) ("perl-io-socket-ssl" ,perl-io-socket-ssl) ("perl-json-xs" ,perl-json-xs) ("perl-time-hires" ,perl-time-hires) ;; TODO: Add more inputs: ;; ipmi-sensors ;; hddtemp ;; perl-xml-dumper ;; ipmitool ,@(package-inputs inxi-minimal))))) (define-public pscircle (package (name "pscircle") (version "1.3.1") (source (origin (method git-fetch) (uri (git-reference (url "https://gitlab.com/mildlyparallel/pscircle.git") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1sm99423hh90kr4wdjqi9sdrrpk65j2vz2hzj65zcxfxyr6khjci")))) (build-system meson-build-system) (native-inputs `(("pkg-config" ,pkg-config))) (inputs `(("cairo" ,cairo) ("libpng" ,libpng) ("libx11" ,libx11))) (home-page "https://gitlab.com/mildlyparallel/pscircle") (synopsis "Visualize Linux processes in a form of radial tree") (description "@code{pscircle} visualizes Linux processes in the form of a radial tree.") (license license:gpl2+))) (define-public python-pyudev (package (name "python-pyudev") (version "0.22.0") (source (origin (method url-fetch) (uri (pypi-uri "pyudev" version)) (sha256 (base32 "0xmj6l08iih2js9skjqpv4w7y0dhxyg91zmrs6v5aa65gbmipfv9")))) (build-system python-build-system) (arguments `(#:tests? #f ; Tests require /sys #:phases (modify-phases %standard-phases (add-after 'unpack 'patch-ctypes-udev (lambda* (#:key inputs outputs #:allow-other-keys) (let ((eudev (assoc-ref inputs "eudev"))) (substitute* "src/pyudev/core.py" (("'udev'") (string-append "'" eudev "/lib/libudev.so'"))) (substitute* "src/pyudev/_ctypeslib/utils.py" ;; Use absolute paths instead of keys. (("= find_library") "= ")) #t)))))) (inputs `(("eudev" ,eudev))) (propagated-inputs `(("python-six" ,python-six))) (native-inputs `(("python-docutils" ,python-docutils) ("python-hypothesis" ,python-hypothesis) ("python-mock" ,python-mock) ("python-pytest" ,python-pytest) ("python-sphinx" ,python-sphinx))) (home-page "https://pyudev.readthedocs.io/") (synopsis "Python udev binding") (description "This package provides @code{udev} bindings for Python.") (license license:lgpl2.1))) (define-public solaar (package (name "solaar") (version "0.9.2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/pwr/Solaar") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "085mfa13dap3wqik1dqlad0d7kff4rv7j4ljh99c7l8nhczkqgwm")))) (build-system python-build-system) (arguments `(#:phases (modify-phases %standard-phases (add-after 'unpack 'fix-prefix-detection (lambda _ (substitute* "setup.py" (("'--prefix' in sys\\.argv") "len([x.startswith('--prefix=') for x in sys.argv]) > 0")) #t)) (add-before 'build 'setenv-PATH (lambda _ (setenv "PYTHONPATH" (string-append "lib:" (getenv "PYTHONPATH"))) #t))))) (propagated-inputs `(("python-pygobject" ,python-pygobject) ("python-pyudev" ,python-pyudev))) (home-page "https://smxi.org/docs/inxi.htm") (synopsis "Linux devices manager for the Logitech Unifying Receiver") (description "This package provides tools to manage clients of the Logitech Unifying Receiver.") (license license:gpl2))) (define-public lynis (package (name "lynis") ;; Also update the ‘lynis-sdk’ input to the commit matching this release. (version "2.7.5") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/CISOfy/lynis") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "1lkkbvxm0rgrrlx0szaxmf8ghc3d26wal96sgqk84m37mvs1f7p0")) (modules '((guix build utils))) (snippet '(begin ;; Remove proprietary plugins. As of now, all plugins supplied with ;; lynis are proprietary. In the future, if free plugins are ;; provided, whitelist them from deletion. (for-each delete-file (find-files "plugins")) #t)))) (build-system gnu-build-system) (native-inputs `(;; For tests ("lynis-sdk" ,(origin (method git-fetch) (uri (git-reference (url "https://github.com/CISOfy/lynis-sdk") (commit "bf1c1d95121da9ca79a9eac5a15ed8d81e34094d"))) (file-name (git-file-name "lynis-sdk" version)) (sha256 (base32 "1ndz5v0039dqa87cva2dk55a8hkw0fibsw8hh2ddmny9qkr4l3dp")))))) (arguments `(#:phases (modify-phases %standard-phases (replace 'configure (lambda* (#:key inputs outputs #:allow-other-keys) (substitute* "lynis" (("/usr/share/lynis") (string-append (assoc-ref outputs "out") "/share/lynis"))) (substitute* "include/functions" (("/usr/local/etc/lynis") (string-append (assoc-ref outputs "out") "/etc/lynis"))) #t)) (delete 'build) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (install-file "lynis" (string-append out "/bin/")) (install-file "default.prf" (string-append out "/etc/lynis")) (for-each (lambda (dir) (copy-recursively dir (string-append out "/share/lynis/" dir))) (list "db" "include" "plugins")) (install-file "lynis.8" (string-append out "/share/man/man8")) #t))) (replace 'check (lambda* (#:key inputs #:allow-other-keys) (copy-recursively (assoc-ref inputs "lynis-sdk") "../lynis-sdk") (setenv "LANG" "en_US.UTF-8") (let ((lynis-dir (getcwd))) (with-directory-excursion "../lynis-sdk" (substitute* "config" (("\\.\\./lynis") lynis-dir)) (substitute* "unit-tests/tests-language-translations.sh" (("\\.\\./lynis") lynis-dir)) (invoke "sh" "lynis-devkit" "run" "unit-tests")))))))) (home-page "https://cisofy.com/lynis/") (synopsis "Security auditing tool") (description "Lynis is a security auditing tool. It performs an in-depth security scan and runs on the system itself. The primary goal is to test security defenses and provide tips for further system hardening. It will also scan for general system information, vulnerable software packages, and possible configuration issues.") (license license:gpl3+))) (define-public ngrep (package (name "ngrep") (version "1.47") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/jpr5/ngrep/") (commit (string-append "V" (string-replace-substring version "." "_"))))) (file-name (git-file-name name version)) (sha256 (base32 "1x2fyd7wdqlj1r76ilal06cl2wmbz0ws6i3ys204sbjh1cj6dcl7")))) (build-system gnu-build-system) (inputs `(("libpcap" ,libpcap))) (arguments `(#:tests? #f ;; No tests. #:configure-flags (list (string-append "--with-pcap-includes=" (assoc-ref %build-inputs "libpcap") "/include/pcap")))) (home-page "https://github.com/jpr5/ngrep/") (synopsis "Grep-like utility to search for network packets on an interface") (description "@command{ngrep} is like GNU grep applied to the network layer. It's a PCAP-based tool that allows you to specify an extended regular or hexadecimal expression to match against data payloads of packets. It understands many kinds of protocols, including IPv4/6, TCP, UDP, ICMPv4/6, IGMP and Raw, across a wide variety of interface types, and understands BPF filter logic in the same fashion as more common packet sniffing tools, such as tcpdump and snoop.") (license license:bsd-3))) (define-public pam-mount (package (name "pam-mount") (version "2.16") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/pam-mount/pam_mount/" version "/pam_mount-" version ".tar.xz")) (sha256 (base32 "1rvi4irb7ylsbhvx1cr6islm2xxw1a4b19q6z4a9864ndkm0f0mf")) (patches ;; Patch adding support for encrypted volumes in LUKS2 format. ;; It comes from the Gentoo package definition for sys-auth/pam_mount. (search-patches "pam-mount-luks2-support.patch")))) (build-system gnu-build-system) (native-inputs `(("perl" ,perl) ("pkg-config" ,pkg-config))) (inputs `(("cryptsetup" ,cryptsetup) ("libhx" ,libhx) ("libxml2" ,libxml2) ("linux-pam" ,linux-pam) ("lvm2" ,lvm2) ("openssl" ,openssl) ("pcre" ,pcre) ("libmount" ,util-linux "lib") ("util-linux" ,util-linux))) (arguments `(#:configure-flags (list (string-append "--with-slibdir=" %output "/lib") (string-append "--with-ssbindir=" %output "/sbin")) #:phases (modify-phases %standard-phases (add-after 'unpack 'fix-program-paths (lambda* (#:key inputs outputs #:allow-other-keys) (let ((util-linux (assoc-ref inputs "util-linux")) (out (assoc-ref outputs "out"))) (substitute* "src/mtcrypt.c" (("\"mount\";") (string-append "\"" util-linux "/bin/mount\";")) (("\"umount\";") (string-append "\"" util-linux "/bin/umount\";")) (("\"fsck\",") (string-append "\"" util-linux "/sbin/fsck\","))) (substitute* "src/rdconf1.c" (("\"mount\", \"") (string-append "\"" util-linux "/bin/mount\", \"")) (("\"umount\", \"") (string-append "\"" util-linux "/bin/umount\", \"")) (("\"fsck\", \"") (string-append "\"" util-linux "/sbin/fsck\", \"")) (("\"pmvarrun\", \"") (string-append "\"" out "/sbin/pmvarrun\", \"")))) #t))))) (home-page "http://pam-mount.sourceforge.net") (synopsis "PAM module to mount volumes for a user session") (description "Pam-mount is a PAM module that can mount volumes when a user logs in. It supports mounting local filesystems of any kind the normal mount utility supports. It can also mount encrypted LUKS volumes using the password supplied by the user when logging in.") (license (list license:gpl2+ license:lgpl2.1+)))) (define-public jc (package (name "jc") (version "1.11.8") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/kellyjonbrazil/jc") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0rkckbgm04ql4r48wjgljfiqvsz36n99yqcpcyna8lvlm8h4nmwa")))) (build-system python-build-system) (propagated-inputs `(("python-ruamel.yaml" ,python-ruamel.yaml) ("python-xmltodict" ,python-xmltodict) ("python-pygments" ,python-pygments))) (home-page "https://github.com/kellyjonbrazil/jc") (synopsis "Convert the output of command-line tools to JSON") (description "@code{jc} JSONifies the output of many CLI tools and file-types for easier parsing in scripts.") (license license:expat))) (define-public jtbl (package (name "jtbl") (version "1.1.6") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/kellyjonbrazil/jtbl") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1zzd7rd63xva50f22d1rfja4r302aizrafarhwm67vv181swvdya")))) (build-system python-build-system) (inputs `(("python-tabulate" ,python-tabulate))) (home-page "https://github.com/kellyjonbrazil/jtbl") (synopsis "Command-line tool to print JSON data as a table in the terminal") (description "@code{jtbl} accepts piped JSON data from stdin and outputs a text table representation to stdout.") (license license:expat))) (define-public hosts (package (name "hosts") (version "3.6.3") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/xwmx/hosts") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "1ni4z89kxzgwm26hhx908g04f2h0fypy7lgfa0rvsz8d0wslgcsn")))) (build-system trivial-build-system) (inputs `(("bats" ,bats) ;for test ("awk" ,gawk) ("bash" ,bash) ("coreutils" ,coreutils) ("diffutils" ,diffutils) ("grep" ,grep) ("ncurses" ,ncurses) ;tput ("sed" ,sed))) (arguments `(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) ;; copy source (copy-recursively (assoc-ref %build-inputs "source") ".") ;; patch-shebang phase (setenv "PATH" (string-append (assoc-ref %build-inputs "bash") "/bin" ":" (assoc-ref %build-inputs "awk") "/bin" ":" (assoc-ref %build-inputs "coreutils") "/bin" ":" (assoc-ref %build-inputs "diffutils") "/bin" ":" (assoc-ref %build-inputs "grep") "/bin" ":" (assoc-ref %build-inputs "ncurses") "/bin" ":" (assoc-ref %build-inputs "sed") "/bin" ":" "/run/setuid-programs" ":" (getenv "PATH"))) (substitute* "hosts" (("#!/usr/bin/env bash") (string-append "#!" (which "bash") "\nPATH=" (getenv "PATH")))) ;; check phase (setenv "TERM" "linux") ;set to tty for test (invoke (string-append (assoc-ref %build-inputs "bats") "/bin/bats") "test") ;; install phase (install-file "hosts" (string-append %output "/bin")) (let ((bash-completion (string-append %output "/etc/bash_completion.d"))) (mkdir-p bash-completion) (copy-file "etc/hosts-completion.bash" (string-append bash-completion "/hosts"))) (let ((zsh-completion (string-append %output "/share/zsh/site-functions"))) (mkdir-p zsh-completion) (copy-file "etc/hosts-completion.zsh" (string-append zsh-completion "/_hosts"))) (let ((doc (string-append %output "/share/doc/" ,name "-" ,version))) (mkdir-p doc) (install-file "LICENSE" doc) (install-file "README.md" doc)) #t))) (home-page "https://github.com/xwmx/hosts/") (synopsis "Script for editing a foreign distro's @file{/etc/hosts} file") (description "Hosts is a command line program for managing @file{/etc/hosts} entries. On Guix System, @file{/etc/hosts} is managed from the system configuration; hosts only works when using the Guix package manager on a foreign distro. @command{hosts} works with existing hosts files and entries, providing commands to add, remove, comment, and search.") (license license:expat)))