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.