aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 José Miguel Sánchez García <jmi2k@openmailbox.org>
;;; Copyright © 2017, 2022 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
;;; Copyright © 2022 (unmatched parenthesis <paren@disroot.org>
;;; Copyright © 2022 Trevor Richards <trev@trevdev.ca>
;;; Copyright © 2023 Gruruya <greytest@disroot.org>
;;;
;;; 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 nim)
  #:use-module (guix build-system gnu)
  #:use-module (guix download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (gnu packages bdw-gc)
  #:use-module (gnu packages certs)
  #:use-module (gnu packages parallel)
  #:use-module (gnu packages pcre)
  #:use-module (gnu packages sqlite)
  #:use-module (gnu packages tls))

(define-public nim
  (package
    (name "nim")
    (version "1.6.12")
    (source
     (origin
      (method url-fetch)
      (uri (string-append "https://nim-lang.org/download/"
                          name "-" version ".tar.xz"))
      (sha256
       (base32 "1hjd9dxhqzn2ifr988li8q7v6kxpxlcqbdllfd6lsq3knw50pvxc"))))
    (build-system gnu-build-system)
    (arguments
     `(#:tests? #f          ; TODO: Investigate tests failures.
       #:phases
         (modify-phases %standard-phases
           (delete 'configure)          ; no configure script
           (add-after 'unpack 'patch-installer
             (lambda* (#:key outputs #:allow-other-keys)
               (let ((out (assoc-ref outputs "out")))
                 (substitute* "install.sh"
                  (("/usr/local") out)
                  (("/lib/nim") "/lib")
                  (("/opt/nimble") (string-append out "/share/nimble"))
                  (("configdir=/etc/nim")
                   (string-append "configdir=" out "/etc/nim"))))))
           (add-after 'unpack 'patch-dynamic-libraries
             (lambda* (#:key inputs native-inputs #:allow-other-keys)
               ;(substitute* "compiler/nodejs.nim"
               ;  (("nodejs")
               ;   (search-input-file (or native-inputs inputs)
               ;                      "/bin/nodejs"))
               ;  (("node")
               ;   (search-input-file (or native-inputs inputs)
               ;                      "/bin/node")))
               (substitute* "lib/system.nim"
                 (("libgc\\.so")
                  (search-input-file (or native-inputs inputs)
                                     "/lib/libgc.so")))
               ;(substitute* "lib/wrappers/mysql.nim"
               ;  (("\(libmysqlclient|libmariadbclient\)\\.so")
               ;   (search-input-file (or native-inputs inputs)
               ;                      "/lib/libmariadbclient.so")))
               (substitute* "lib/wrappers/openssl.nim"
                 (("libssl\\.so")
                  (search-input-file (or native-inputs inputs)
                                     "/lib/libssl.so"))
                 (("libcrypto\\.so")
                  (search-input-file (or native-inputs inputs)
                                     "/lib/libcrypto.so")))
               (substitute* "lib/wrappers/pcre.nim"
                 (("libpcre\\.so")
                  (search-input-file (or native-inputs inputs)
                                     "/lib/libpcre.so")))
               ;(substitute* "lib/wrappers/postgres.nim"
               ;  (("libpg\\.so")
               ;   (search-input-file (or native-inputs inputs)
               ;                      "/lib/libpg.so")))
               (substitute* "lib/wrappers/sqlite3.nim"
                 (("libsqlite3\\.so")
                  (search-input-file (or native-inputs inputs)
                                     "/lib/libsqlite3.so")))))
           (add-after 'patch-source-shebangs 'patch-more-shebangs
             (lambda _
               (let ((sh (which "sh")))
                 (substitute* '("tests/stdlib/tosprocterminate.nim"
                                "tests/stdlib/tstrscans.nim"
                                "lib/pure/osproc.nim"
                                "lib/pure/strscans.nim")
                   (("/bin/sh") sh))
                 (substitute* (find-files "c_code" "@m\\.\\.@slib@spure@sosproc\\.nim\\.c")
                   (("\"/bin/sh\", 7") (format #f "~s, ~s" sh (string-length sh)))))))
           (replace 'build
             (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
               (setenv "XDG_CACHE_HOME" "./cache-home")
               (setenv "HOME" "./cache-home")
               (mkdir-p "./cache-home")
               (invoke "sh" "build.sh"
                       "--parallel"
                       (if parallel-build?
                         (number->string (parallel-job-count))
                         "1"))
               (sleep 5)        ; Wait for the parallel builds to finish.
               (invoke "./bin/nim" "c" "-d:release" "koch")
               (invoke "./koch" "boot" "-d:release")
               (invoke "./koch" "tools")))
           (replace 'check
             (lambda* (#:key tests? #:allow-other-keys)
               (when tests?
                 (invoke "./koch" "tests"))))
           (replace 'install
             (lambda* (#:key outputs #:allow-other-keys)
               (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
                 (mkdir-p bin)
                 (invoke "./install.sh" bin)
                 (for-each (lambda (file)
                             (install-file file bin))
                           (delete "testament" (find-files "bin"))))))
           (add-after 'install 'install-completions
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((share (string-append (assoc-ref outputs "out") "/share"))
                      (bash  (string-append share "/bash-completion/completions"))
                      (zsh   (string-append share "/zsh/vendor_completions")))
                 (mkdir-p bash)
                 (mkdir-p zsh)
                 (copy-file "tools/nim.bash-completion"
                            (string-append bash "/nim"))
                 (copy-file "dist/nimble/nimble.bash-completion"
                            (string-append bash "/nimble"))
                 (copy-file "tools/nim.zsh-completion"
                            (string-append zsh "/_nim"))
                 (copy-file "dist/nimble/nimble.bash-completion"
                            (string-append zsh "/_nimble"))))))))
    (inputs (list libgc openssl pcre sqlite))
    (native-inputs (list nss-certs parallel))
    (home-page "https://nim-lang.org")
    (synopsis "Statically-typed, imperative programming language")
    (description "Nim (formerly known as Nimrod) is a statically-typed,
imperative programming language that tries to give the programmer ultimate power
without compromises on runtime efficiency.  This means it focuses on compile-time
mechanisms in all their various forms.")
    (license license:expat)))
re-inst-env.in: Do not set 'NIX_HASH' environment variable. Ludovic Courtès 2020-08-29build: Remove check for Guile 2.2.1 bug....This check is unnecessary since e688c2df3924423b67892cc9939ca099c729d1cb. * m4/guix.m4 (GUIX_ASSERT_SYNTAX_OBJECT_EQUAL): Remove. * configure.ac: Remove user. Ludovic Courtès 2020-08-24Use "guile-zlib" and "guile-lzlib" instead of (guix config)....* Makefile.am (MODULES): Remove guix/zlib.scm and guix/lzlib.scm, (SCM_TESTS): remove tests/zlib.scm, tests/lzlib.scm. * build-aux/build-self.scm (make-config.scm): Remove unused %libz variable. * configure.ac: Remove LIBZ and LIBLZ variables and check instead for Guile-zlib and Guile-lzlib. * doc/guix.texi ("Requirements"): Remove zlib requirement and add Guile-zlib and Guile-lzlib instead. * gnu/packages/package-management.scm (guix)[native-inputs]: Add "guile-zlib" and "guile-lzlib", [inputs]: remove "zlib" and "lzlib", [propagated-inputs]: ditto, [arguments]: add "guile-zlib" and "guile-lzlib" to Guile load path. * guix/config.scm.in (%libz, %liblz): Remove them. * guix/lzlib.scm: Remove it. * guix/man-db.scm: Use (zlib) instead of (guix zlib). * guix/profiles.scm (manual-database): Do not stub (guix config) in imported modules list, instead add "guile-zlib" to the extension list. * guix/scripts/publish.scm: Use (zlib) instead of (guix zlib) and (lzlib) instead of (guix lzlib), (string->compression-type, effective-compression): do not check for zlib and lzlib availability. * guix/scripts/substitute.scm (%compression-methods): Do not check for lzlib availability. * guix/self.scm (specification->package): Add "guile-zlib" and "guile-lzlib" and remove "zlib" and "lzlib", (compiled-guix): remove "zlib" and "lzlib" arguments and add guile-zlib and guile-lzlib to the dependencies, also do not pass "zlib" and "lzlib" to "make-config.scm" procedure, (make-config.scm): remove "zlib" and "lzlib" arguments as well as %libz and %liblz variables. * guix/utils.scm (lzip-port): Use (lzlib) instead of (guix lzlib) and do not check for lzlib availability. * guix/zlib.scm: Remove it. * m4/guix.m4 (GUIX_LIBZ_LIBDIR, GUIX_LIBLZ_FILE_NAME): Remove them. * tests/lzlib.scm: Use (zlib) instead of (guix zlib) and (lzlib) instead of (guix lzlib), and do not check for zlib and lzlib availability. * tests/publish.scm: Ditto. * tests/substitute.scm: Do not check for lzlib availability. * tests/utils.scm: Ditto. * tests/zlib.scm: Remove it. Mathieu Othacehe 2020-06-16etc: Add committer script....* etc/committer.scm.in: New file. * configure.ac: Configure it. Ricardo Wurmus 2020-05-28maint: Check whether Guile-Gcrypt is recent enough....Suggested by Danny Milosavljevic <dannym@scratchpost.org> in <https://bugs.gnu.org/41494>. * m4/guix.m4 (GUIX_CHECK_GUILE_GCRYPT): New macro. * configure.ac: Use it. Ludovic Courtès 2020-05-14etc: indent-code.el: Use the --quick option....This prevents Emacs from loading the autoload definitions found in its profile, which needlessly clutters the output. It also prevents Geiser (if installed) from blocking the script and asking the user to input the Scheme implementation to use. The trick for passing multiple arguments to Emacs is to use what is called a "sesquicolon" (see https://www.emacswiki.org/emacs/EmacsScripts). * etc/indent-code.el.in: Rename to... * etc/indent-code.el: ...this. Adapt the shebang to use a sesquicolon, and pass the --quick option to Emacs. Since this line is interpreted by the shell, simply use Emacs from the PATH instead of from a hard coded location. (main): New procedure, used as the entry point. * configure.ac: Remove the warning about Emacs. Emacs can now be installed any time by the user if they want to use the script. * .gitignore: No longer ignore changes to etc/indent-code.el. Maxim Cournoyer 2020-04-23build: Don't build man pages when cross-compiling....* configure.ac: Define 'CROSS_COMPILING' Automake conditional. * doc/local.mk (dist_man1_MANS): Wrap in "if !CROSS_COMPILING". Ludovic Courtès 2020-03-11build: Require Guile 2.2.3 or later....* configure.ac: For 2.2.x, require 2.2.3 or later. Ludovic Courtès