unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Trev <trev@trevdev.ca>
To: GUIX Help <help-guix@gnu.org>
Subject: Troubles building "nimble" with nim
Date: Wed, 06 Jul 2022 10:57:08 -0700	[thread overview]
Message-ID: <87tu7uceff.fsf@codinator.mail-host-address-is-not-set> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 5400 bytes --]


Hello Guix!

I am in the weeds while trying to properly build "nimble", the package
manager that is included with the nim programming language. The current
guix package (gnu/packages/nim) completely misses this build step. I
wonder if previous contributors also struggled with this.

For some context I am attempting to directly replicate these steps from
https://nim-lang.org/install_unix.html:

#+BEGIN_QUOTE
sh build.sh
bin/nim c koch
./koch boot -d:release
./koch tools
#+END_QUOTE

My (and the current package record) can build the nim binary using gcc, no problem. However when we get to the part where nim builds its own features with the compiled compiler, something seems to be trying to call =/bin/sh= directly, despite hard-coded references to that process having been been substituted out.

I have submitted a ticket with Nim here just so that I may ask some thoughtful questions. That conversation is here: https://github.com/nim-lang/Nim/issues/19976

The error output is:

#+BEGIN_SRC sh
c_code/2_2/stdlib_browsers.nim.o c_code/2_2/@mnim.nim.o -ldl -lm -lrt
: SUCCESS
Hint: used config file '/tmp/guix-build-nim-1.6.6.drv-0/nim-1.6.6/config/nim.cfg' [Conf]
Hint: used config file '/tmp/guix-build-nim-1.6.6.drv-0/nim-1.6.6/config/config.nims' [Conf]
......................................................................................................................
CC: stdlib_digitsutils.nim
Error: invocation of external compiler program failed. No such file or directory
Additional info: Could not find command: '/bin/sh'. OS error: No such file or directory 2
error: in phase 'build': uncaught exception:
%exception #<&invoke-error program: "./bin/nim" arguments: ("c" "koch") exit-status: 1 term-signal: #f stop-signal: #f> 
phase `build' failed after 96.6 seconds
command "./bin/nim" "c" "koch" failed with status 1
#+END_SRC

My current attempt at packaging this looks like this:

#+BEGIN_SRC scheme
(define-module (gnu packages nim)
  #:use-module (guix build-system gnu)
  #:use-module (guix gexp)
  #:use-module (guix download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (gnu packages pcre)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages cmake))

(define-public nim
  (package
    (name "nim")
    (version "1.6.6")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://nim-lang.org/download/"
                           name "-" version ".tar.xz"))
       (sha256
        (base32 "0lm4450ig8k4l3rzxv6kcqji5l1lzicsw76ckwxm0q9qdz713cb7"))))
    (build-system gnu-build-system)
    (native-inputs (list pcre openssl cmake))
    (arguments
     `(#:tests? #f ; No tests.
       #: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/") (string-append out "/usr/"))
                 (("/etc/") (string-append out "/etc/"))
                 (("/opt/") (string-append out "/opt/")))
               #t)))
         (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")
                 (("/bin/sh") sh))
               (substitute* (find-files "c_code" "stdlib_osproc.c")
                 (("\"/bin/sh\", 7") (format #f "~s, ~s" sh (string-length sh)))))
             #t))
         (replace 'build
           (lambda _
             (setenv "XDG_CACHE_HOME" "./cache-home")
             (mkdir-p "./cache-home")
             (invoke "sh" "build.sh")
             (invoke "./bin/nim" "c" "koch")
             (invoke "koch" "boot" "-d:release")
             (invoke "koch" "tools")
             #t))
         (replace 'install
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (mkdir-p (string-append out "/usr/bin"))
               (invoke "./install.sh" (string-append out "/usr/bin"))
               #t))))))
    (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)))
#+END_SRC

I have tried:

1. Symlinking (without any success) /bin/sh to (which "bash")
2. Exporting $SHELL to (which "bash")
3. Attempted (without much luck) to ~alias cc=gcc~ to see if it's not the shell that's missing, it's the command "cc", and adding cmake as a separate input
4. Grokking the Nim source code that I don't perfectly understand to see how it could somehow decide to call something that isn't on path aside from a string that's "/bin/sh".
   
If someone appreciates packaging this better than can share some wisdom, it would be appreciated.


[-- Attachment #1.2: Type: text/plain, Size: 66 bytes --]

-- 

Trev : 0FB7 D06B 4A2A F07E AD5B  1169 183B 6306 8AA1 D206

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

             reply	other threads:[~2022-07-06 17:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06 17:57 Trev [this message]
2022-07-20 15:16 ` Troubles building "nimble" with nim Efraim Flashner
2022-07-24 15:13   ` Trev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tu7uceff.fsf@codinator.mail-host-address-is-not-set \
    --to=trev@trevdev.ca \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).