unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Help me create a janet-build-system
@ 2021-05-15  5:07 Jack Hill
  2021-05-15  7:00 ` Leo Prikler
  0 siblings, 1 reply; 4+ messages in thread
From: Jack Hill @ 2021-05-15  5:07 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2381 bytes --]

Greetings Guix,

I'm working on creating a build system for Janet [0] modules. This is my 
first time working with build systems, and while I have a much better 
understanding than when I started, I still don't understand it fully. I've 
attached my work in progress patches. The first five set the stage by 
updating and improving our Janet package. Patch six adds the build system, 
and patch seven adds an example package, janet-posix-spawn.

[0] https://janet-lang.org

Trying to build janet-posix-spawn results in:

```
jackhill@alperton ~/repos/guix [env]$ ./pre-inst-env guix build janet-posix-spawn
The following derivations will be built:
    /gnu/store/y1xpmfaqswcmiwzpc1bgak18rbw2k4ad-janet-posix-spawn-0.0.1.drv
    /gnu/store/w52ndznq3v42xxv4lfrpdlmwgn8r0f2x-module-import-compiled.drv
building /gnu/store/w52ndznq3v42xxv4lfrpdlmwgn8r0f2x-module-import-compiled.drv...
Backtrace:
In system/base/compile.scm:
      43:4 19 (call-with-output-file/atomic _ _ _)
In ice-9/boot-9.scm:
   1736:10 18 (with-exception-handler _ _ #:unwind? _ # _)
In system/base/compile.scm:
     59:11 17 (_)
    155:11 16 (_ #<closed: file 7ffff69868c0>)
    235:18 15 (read-and-compile #<input: guix/build/janet-build-syst?> ?)
    183:32 14 (compile-fold (#<procedure compile-tree-il (x e opts)>) ?)
In ice-9/boot-9.scm:
    2806:4 13 (save-module-excursion _)
In language/scheme/compile-tree-il.scm:
     31:15 12 (_)
In ice-9/psyntax.scm:
   1241:36 11 (expand-top-sequence _ _ _ #f _ _ _)
   1233:19 10 (parse _ (("placeholder" placeholder)) ((top) #(# # ?)) ?)
    285:10  9 (parse _ (("placeholder" placeholder)) (()) _ c&e (# #) #)
In ice-9/eval.scm:
    293:34  8 (_ #<module (#{ g32}#) 7ffff697ac80>)
In ice-9/boot-9.scm:
    3380:4  7 (define-module* _ #:filename _ #:pure _ #:version _ # _ ?)
   2565:24  6 (call-with-deferred-observers _)
   3393:24  5 (_)
    222:29  4 (map1 (((guix build gnu-build-system) #:prefix gnu:) # ?))
    222:29  3 (map1 (((guix build utils)) ((guix utils))))
    222:17  2 (map1 (((guix utils))))
    3300:6  1 (resolve-interface (guix utils) #:select _ #:hide _ # _ ?)
   1669:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1669:16: In procedure raise-exception:
no code for module (guix utils)
```

What have I done wrong?

More generally, I expect there are many ways I could improve the build 
system. What are they?

Thanks!
Jack

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-diff; name=0001-gnu-janet-Update-to-1.15.5.patch, Size: 1197 bytes --]

From f229d3863f5e93606db1275dcb30ad4f3092496b Mon Sep 17 00:00:00 2001
From: Jack Hill <jackhill@jackhill.us>
Date: Thu, 13 May 2021 01:09:22 -0400
Subject: [PATCH 1/7] gnu: janet: Update to 1.15.5.

* gnu/packages/lisp.scm (janet): Update to 1.15.5.
---
 gnu/packages/lisp.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index 24babaf469..6e35062561 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -1053,7 +1053,7 @@ including a built-in database engine and a GUI system.")
 (define-public janet
   (package
     (name "janet")
-    (version "1.12.2")
+    (version "1.15.5")
     (source
      (origin
        (method git-fetch)
@@ -1062,7 +1062,7 @@ including a built-in database engine and a GUI system.")
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "0if514zdmbjvvrsa9x5yfvg2b14sz53yaka12g3yhwkq8ls3qk0c"))))
+        (base32 "0gl0p3x0ylj4hxiwjclg1waxq8csadw60qw6pa9h5y4w1bcqffmk"))
     (build-system gnu-build-system)
     (arguments
      `(#:make-flags (list
-- 
2.31.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Type: text/x-diff; name=0002-gnu-janet-Use-test-target.patch, Size: 1529 bytes --]

From 3aaa244fac08956af7e71f99b3323465d8c58e87 Mon Sep 17 00:00:00 2001
From: Jack Hill <jackhill@jackhill.us>
Date: Thu, 13 May 2021 00:51:52 -0400
Subject: [PATCH 2/7] gnu: janet: Use #:test-target

* gnu/packages/lisp.scm (janet)[arguments]: Add 'test-target' keyword. Remove
customized 'check' phase.
---
 gnu/packages/lisp.scm | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index 6e35062561..2e656cdbbc 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2020 Zhu Zihao <all_but_last@163.com>
 ;;; Copyright © 2021 Sharlatan Hellseher <sharlatanus@gmail.com>
+;;; Copyright © 2021 Jack Hill <jackhill@jackhill.us>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1070,12 +1071,10 @@ including a built-in database engine and a GUI system.")
                      (string-append "PREFIX=")
                      (string-append "CC=" (assoc-ref %build-inputs "gcc")
                                     "/bin/gcc"))
+       #:test-target "test"
        #:phases
        (modify-phases %standard-phases
-         (delete 'configure)
-         (replace 'check
-           (lambda _
-             (invoke "make" "test"))))))
+         (delete 'configure))))
     (home-page "https://janet-lang.org/")
     (synopsis "Functional, imperative and embeddable programming language")
     (description
-- 
2.31.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: Type: text/x-diff; name=0003-gnu-janet-Prefer-PREFIX-over-DESTDIR.patch, Size: 1153 bytes --]

From 9ab488ac99c3d4be2f0b5d98a037d89c8f18eb59 Mon Sep 17 00:00:00 2001
From: Jack Hill <jackhill@jackhill.us>
Date: Thu, 13 May 2021 00:55:01 -0400
Subject: [PATCH 3/7] gnu: janet: Prefer PREFIX over DESTDIR

* gnu/packages/lisp.scm (janet)[make-flags]: Specify output path with PREFIX
instead of DESTDIR.
---
 gnu/packages/lisp.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index 2e656cdbbc..fff5865043 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -1067,10 +1067,9 @@ including a built-in database engine and a GUI system.")
     (build-system gnu-build-system)
     (arguments
      `(#:make-flags (list
-                     (string-append "DESTDIR=" (assoc-ref %outputs "out"))
-                     (string-append "PREFIX=")
                      (string-append "CC=" (assoc-ref %build-inputs "gcc")
                                     "/bin/gcc"))
+                     (string-append "PREFIX=" (assoc-ref %outputs "out"))
        #:test-target "test"
        #:phases
        (modify-phases %standard-phases
-- 
2.31.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: Type: text/x-diff; name=0004-gnu-janet-Support-cross-compilation.patch, Size: 1054 bytes --]

From 5db00260eefdaaf6fe9a642eb26e7780477c7e9a Mon Sep 17 00:00:00 2001
From: Jack Hill <jackhill@jackhill.us>
Date: Thu, 13 May 2021 00:58:30 -0400
Subject: [PATCH 4/7] gnu: janet: Support cross-compilation

* gnu/packages/lisp.scm (janet)[make-flags]: Use cc-for-target.
---
 gnu/packages/lisp.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index fff5865043..6ee4651447 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -1067,9 +1067,8 @@ including a built-in database engine and a GUI system.")
     (build-system gnu-build-system)
     (arguments
      `(#:make-flags (list
-                     (string-append "CC=" (assoc-ref %build-inputs "gcc")
-                                    "/bin/gcc"))
                      (string-append "PREFIX=" (assoc-ref %outputs "out"))
+                     (string-append "CC=" ,(cc-for-target)))
        #:test-target "test"
        #:phases
        (modify-phases %standard-phases
-- 
2.31.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: Type: text/x-diff; name=0005-gnu-janet-Respect-GUIX_JANET_PATH.patch, Size: 4136 bytes --]

From 8ea53fa3d939b5f2eb7bdbfa4b7f0dc1f245b729 Mon Sep 17 00:00:00 2001
From: Jack Hill <jackhill@jackhill.us>
Date: Thu, 13 May 2021 01:13:08 -0400
Subject: [PATCH 5/7] gnu: janet: Respect GUIX_JANET_PATH

* gnu/packages/patches/janet-guix-janet-path.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/lisp.scm (janet)[source]: Use it
[native-search-paths]: New field.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/lisp.scm                         |  7 ++++
 .../patches/janet-guix-janet-path.patch       | 37 +++++++++++++++++++
 3 files changed, 45 insertions(+)
 create mode 100644 gnu/packages/patches/janet-guix-janet-path.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index fc8e117a88..1f66a97030 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1258,6 +1258,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/jamvm-2.0.0-aarch64-support.patch	\
   %D%/packages/patches/jamvm-2.0.0-disable-branch-patching.patch	\
   %D%/packages/patches/jamvm-2.0.0-opcode-guard.patch		\
+  %D%/packages/patches/janet-guix-janet-path.patch		\
   %D%/packages/patches/java-antlr4-Add-standalone-generator.patch	\
   %D%/packages/patches/java-antlr4-fix-code-too-large.java	\
   %D%/packages/patches/java-tunnelvisionlabs-antlr-code-too-large.patch	\
diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index 6ee4651447..0dea527e3c 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -1064,6 +1064,8 @@ including a built-in database engine and a GUI system.")
        (file-name (git-file-name name version))
        (sha256
         (base32 "0gl0p3x0ylj4hxiwjclg1waxq8csadw60qw6pa9h5y4w1bcqffmk"))
+       (patches
+        (search-patches "janet-guix-janet-path.patch"))))
     (build-system gnu-build-system)
     (arguments
      `(#:make-flags (list
@@ -1073,6 +1075,11 @@ including a built-in database engine and a GUI system.")
        #:phases
        (modify-phases %standard-phases
          (delete 'configure))))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "GUIX_JANET_PATH")
+            (separator ":")
+            (files '("lib/janet")))))
     (home-page "https://janet-lang.org/")
     (synopsis "Functional, imperative and embeddable programming language")
     (description
diff --git a/gnu/packages/patches/janet-guix-janet-path.patch b/gnu/packages/patches/janet-guix-janet-path.patch
new file mode 100644
index 0000000000..5082beb378
--- /dev/null
+++ b/gnu/packages/patches/janet-guix-janet-path.patch
@@ -0,0 +1,37 @@
+author: Jack Hill <jackhill@jackhill.us>
+Upstream discussion: https://github.com/janet-lang/janet/discussions/695
+diff --git a/src/boot/boot.janet b/src/boot/boot.janet
+index 59e0a016..f9174916 100644
+--- a/src/boot/boot.janet
++++ b/src/boot/boot.janet
+@@ -3328,6 +3328,30 @@
+   (if-let [jp (getenv-alias "JANET_HEADERPATH")] (setdyn :headerpath jp))
+   (if-let [jprofile (getenv-alias "JANET_PROFILE")] (setdyn :profilepath jprofile))
+ 
++  # Guix customization to make Janet respect GUIX_JANET_PATH
++  # environment variable.  GUIX_JANET_PATH is a native search path
++  # added by Guix to tell Janet where to find modules install in the
++  # same profile via Guix packages.  This is done by augmenting
++  # Janet's module/paths array.
++  (def- guix-janet-path (os/getenv "GUIX_JANET_PATH"))
++
++  # The Janet standard extensions and loaders.  List copied from
++  # the calls to module/add-paths in src/boot/boot.janet.
++  (def- default-janet-loaders
++    [[":native:" :native]
++     ["/init.janet" :source]
++     [".janet" :source]
++     [".jimage" :image]])
++
++  (defn- add-guix-path [p]
++    (each [ext loader] default-janet-loaders
++      (array/push module/paths [(string p "/:all:" ext) loader check-is-dep])))
++
++  (if guix-janet-path
++    (each elem (string/split ":" guix-janet-path)
++      (add-guix-path elem)))
++  # End of Guix customization
++
+   # Flag handlers
+   (def handlers
+     {"h" (fn [&]
\ No newline at end of file
-- 
2.31.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #7: Type: text/x-diff; name=0006-build-system-Add-janet-build-system.patch, Size: 8712 bytes --]

From abd4ca272b784545c71d4ec12554670cdd2cd8ee Mon Sep 17 00:00:00 2001
From: Jack Hill <jackhill@jackhill.us>
Date: Sat, 15 May 2021 00:41:34 -0400
Subject: [PATCH 6/7] build-system: Add janet-build-system.

* guix/build-system/janet.scm: New file.
* guix/build/janet-build-system.scm: New file.
* Makefile.am (MODULES): Add them.
---
 Makefile.am                       |   2 +
 guix/build-system/janet.scm       | 116 ++++++++++++++++++++++++++++++
 guix/build/janet-build-system.scm |  62 ++++++++++++++++
 3 files changed, 180 insertions(+)
 create mode 100644 guix/build-system/janet.scm
 create mode 100644 guix/build/janet-build-system.scm

diff --git a/Makefile.am b/Makefile.am
index 4cbef5a6e6..1a88604966 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -139,6 +139,7 @@ MODULES =					\
   guix/build-system/emacs.scm			\
   guix/build-system/font.scm			\
   guix/build-system/go.scm			\
+  guix/build-system/janet.scm			\
   guix/build-system/meson.scm			\
   guix/build-system/minify.scm			\
   guix/build-system/asdf.scm			\
@@ -191,6 +192,7 @@ MODULES =					\
   guix/build/minify-build-system.scm		\
   guix/build/font-build-system.scm		\
   guix/build/go-build-system.scm		\
+  guix/build/janet-build-system.scm		\
   guix/build/android-repo.scm			\
   guix/build/asdf-build-system.scm		\
   guix/build/bzr.scm				\
diff --git a/guix/build-system/janet.scm b/guix/build-system/janet.scm
new file mode 100644
index 0000000000..de0947d86f
--- /dev/null
+++ b/guix/build-system/janet.scm
@@ -0,0 +1,116 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Jack Hill <jackhill@jackhill.us>
+;;;
+;;; 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 (guix build-system janet)
+  #:use-module (guix build-system)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix derivations)
+  #:use-module (guix packages)
+  #:use-module (guix utils)
+  #:use-module (ice-9 match)
+  #:export (janet-build
+            janet-build-system))
+
+(define %janet-build-system-modules
+  ;; Build-side modules imported by default.
+  `((guix build janet-build-system)
+    ,@%gnu-build-system-modules))
+
+(define (default-janet)
+  "Return the default Janet package."
+  ;; Lazily resolve the binding to avoid a circular dependency.
+  (let ((lisp (resolve-interface '(gnu packages lisp))))
+    (module-ref lisp 'janet)))
+
+(define* (lower name
+                #:key source inputs native-inputs outputs
+                system target
+                (janet (default-janet))
+                #:allow-other-keys
+                #:rest arguments)
+  "Return a bag for NAME."
+  (define private-keywords
+    '(#:source #:target #:janet #:inputs #:native-inputs))
+
+  (bag
+    (name name)
+    (system system)
+    (host-inputs `(,@(if source
+                         `(("source" ,source))
+                         '())
+                   ,@inputs
+                   ;; Keep the standard inputs of 'gnu-build-system'.
+                   ,@(standard-packages)))
+    (build-inputs `(("janet" ,janet)
+                    ,@native-inputs))
+    (outputs outputs)
+    (build janet-build)
+    (arguments (strip-keyword-arguments private-keywords arguments))))
+
+(define* (janet-build store name inputs
+                      #:key
+                      (search-paths '())
+                     (tests? #t)
+                     (phases '(@ (guix build janet-build-system)
+                                 %standard-phases))
+                     (outputs '("out"))
+                     (system (%current-system))
+                     (locale "en_US.utf8")
+                     (guile #f)
+                     (imported-modules %janet-build-system-modules)
+                     (modules '((guix build janet-build-system)
+                                (guix build utils)
+                                (guix utils))))
+  "Build SOURCE using RUBY and INPUTS."
+  (define builder
+    `(begin
+       (use-modules ,@modules)
+       (janet-build #:name ,name
+                    #:source ,(match (assoc-ref inputs "source")
+                                (((? derivation? source))
+                                 (derivation->output-path source))
+                                ((source)
+                                 source)
+                                (source
+                                 source))
+                    #:tests? ,tests?
+                    #:phases ,phases
+                    #:outputs %outputs
+                    #:inputs %build-inputs)))
+
+  (define guile-for-build
+    (match guile
+      ((? package?)
+       (package-derivation store guile system #:graft? #f))
+      (#f
+       (let* ((distro (resolve-interface '(gnu packages commencement)))
+              (guile  (module-ref distro 'guile-final)))
+         (package-derivation store guile system #:graft? #f)))))
+
+  (build-expression->derivation store name builder
+                                #:inputs inputs
+                                #:system system
+                                #:modules imported-modules
+                                #:outputs outputs
+                                #:guile-for-build guile-for-build))
+
+(define janet-build-system
+  (build-system
+    (name 'janet)
+    (description "The standard Janet build system")
+    (lower lower)))
diff --git a/guix/build/janet-build-system.scm b/guix/build/janet-build-system.scm
new file mode 100644
index 0000000000..da4a6f3698
--- /dev/null
+++ b/guix/build/janet-build-system.scm
@@ -0,0 +1,62 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Jack Hill <jackhill@jackhill.us>
+;;;
+;;; 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 (guix build janet-build-system)
+  #:use-module ((guix build gnu-build-system) #:prefix gnu:)
+  #:use-module (guix build utils)
+  #:use-module (guix utils)
+  #:export (%standard-phases
+            janet-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard Janet package build procedure.
+;;
+;; Code:
+
+(define* (build #:rest arguments)
+  "Build a Janet package with jpm"
+  (invoke "jpm" "--verbose"
+          (string-append "--compiler=" (cc-for-target))
+          (string-append "--cpp-compiler=" (cxx-for-target))
+          "build"))
+
+(define* (check #:key tests? #:allow-other-keys)
+  "Test a janet package with jpm.  Skip the tests if TESTS?  is #f."
+  (if tests?
+      (invoke "jpm" "--verbose" "test")))
+
+(define* (install #:key outputs #:allow-other-keys)
+  "Install a Janet package with jpm"
+  (let ((out (assoc-ref outputs "out")))
+    (invoke "jpm" "--verbose"
+            (string-append "--modpath=" out "/lib/janet")
+            (string-append "--binpath=" out "/bin")
+            "install")))
+
+(define %standard-phases
+  (modify-phases gnu:%standard-phases
+    (delete 'bootstrap)
+    (delete 'configure)
+    (replace 'build build)
+    (replace 'check check)
+    (replace 'install install)))
+
+(define* (janet-build #:key inputs (phases %standard-phases)
+                     #:allow-other-keys #:rest args)
+  (apply gnu:gnu-build #:inputs inputs #:phases phases args))
-- 
2.31.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: Type: text/x-diff; name=0007-gnu-Add-janet-posix-spawn.patch, Size: 2862 bytes --]

From af9b878206080041fb21ee317bc7c7c47777ae34 Mon Sep 17 00:00:00 2001
From: Jack Hill <jackhill@jackhill.us>
Date: Sat, 15 May 2021 00:45:28 -0400
Subject: [PATCH 7/7] gnu: Add janet-posix-spawn.

* gnu/packages/jaent-xyz.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk               |  1 +
 gnu/packages/janet-xyz.scm | 42 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 gnu/packages/janet-xyz.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 1f66a97030..577f6df609 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -299,6 +299,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/irc.scm  			\
   %D%/packages/iso-codes.scm			\
   %D%/packages/jami.scm				\
+  %D%/packages/janet-xyz.scm				\
   %D%/packages/java.scm				\
   %D%/packages/java-compression.scm		\
   %D%/packages/java-graphics.scm		\
diff --git a/gnu/packages/janet-xyz.scm b/gnu/packages/janet-xyz.scm
new file mode 100644
index 0000000000..91f7be288a
--- /dev/null
+++ b/gnu/packages/janet-xyz.scm
@@ -0,0 +1,42 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Jack Hill <jackhill@jackhill.us>
+;;;
+;;; 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 janet-xyz)
+  #:use-module (guix packages)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system janet)
+  #:use-module ((guix licenses) #:prefix license:))
+
+(define-public janet-posix-spawn
+  (package
+    (name "janet-posix-spawn")
+    (version "0.0.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/andrewchambers/janet-posix-spawn")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0jgj6my0jsz8r3wjczasm2bw56gv9i9mfrnl8697csb7mhg3si5b"))))
+    (build-system janet-build-system)
+    (home-page "https://github.com/andrewchambers/janet-posix-spawn")
+    (synopsis "Posix spawn for Jante")
+    (description "Janet library implementing posix spawn.")
+    (license license:expat)))
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Help me create a janet-build-system
  2021-05-15  5:07 Help me create a janet-build-system Jack Hill
@ 2021-05-15  7:00 ` Leo Prikler
  2021-05-15 19:25   ` Jack Hill
  0 siblings, 1 reply; 4+ messages in thread
From: Leo Prikler @ 2021-05-15  7:00 UTC (permalink / raw)
  To: Jack Hill, guix-devel

Am Samstag, den 15.05.2021, 01:07 -0400 schrieb Jack Hill:
> Greetings Guix,
> 
> I'm working on creating a build system for Janet [0] modules. This is
> my 
> first time working with build systems, and while I have a much
> better 
> understanding than when I started, I still don't understand it fully.
> I've 
> attached my work in progress patches. The first five set the stage
> by 
> updating and improving our Janet package. Patch six adds the build
> system, 
> and patch seven adds an example package, janet-posix-spawn.
> 
> [0] https://janet-lang.org
> 
> Trying to build janet-posix-spawn results in:
> 
> ```
> jackhill@alperton ~/repos/guix [env]$ ./pre-inst-env guix build
> janet-posix-spawn
> The following derivations will be built:
>     /gnu/store/y1xpmfaqswcmiwzpc1bgak18rbw2k4ad-janet-posix-spawn-
> 0.0.1.drv
>     /gnu/store/w52ndznq3v42xxv4lfrpdlmwgn8r0f2x-module-import-
> compiled.drv
> building /gnu/store/w52ndznq3v42xxv4lfrpdlmwgn8r0f2x-module-import-
> compiled.drv...
> Backtrace:
> In system/base/compile.scm:
>       43:4 19 (call-with-output-file/atomic _ _ _)
> In ice-9/boot-9.scm:
>    1736:10 18 (with-exception-handler _ _ #:unwind? _ # _)
> In system/base/compile.scm:
>      59:11 17 (_)
>     155:11 16 (_ #<closed: file 7ffff69868c0>)
>     235:18 15 (read-and-compile #<input: guix/build/janet-build-
> syst?> ?)
>     183:32 14 (compile-fold (#<procedure compile-tree-il (x e opts)>)
> ?)
> In ice-9/boot-9.scm:
>     2806:4 13 (save-module-excursion _)
> In language/scheme/compile-tree-il.scm:
>      31:15 12 (_)
> In ice-9/psyntax.scm:
>    1241:36 11 (expand-top-sequence _ _ _ #f _ _ _)
>    1233:19 10 (parse _ (("placeholder" placeholder)) ((top) #(# # ?))
> ?)
>     285:10  9 (parse _ (("placeholder" placeholder)) (()) _ c&e (# #)
> #)
> In ice-9/eval.scm:
>     293:34  8 (_ #<module (#{ g32}#) 7ffff697ac80>)
> In ice-9/boot-9.scm:
>     3380:4  7 (define-module* _ #:filename _ #:pure _ #:version _ # _
> ?)
>    2565:24  6 (call-with-deferred-observers _)
>    3393:24  5 (_)
>     222:29  4 (map1 (((guix build gnu-build-system) #:prefix gnu:) #
> ?))
>     222:29  3 (map1 (((guix build utils)) ((guix utils))))
>     222:17  2 (map1 (((guix utils))))
>     3300:6  1 (resolve-interface (guix utils) #:select _ #:hide _ # _
> ?)
>    1669:16  0 (raise-exception _ #:continuable? _)
> 
> ice-9/boot-9.scm:1669:16: In procedure raise-exception:
> no code for module (guix utils)
> ```
> 
> What have I done wrong?
Your code imports (guix utils), but (guix utils) is not present within
the module closure present at build time.  
Did you mean (guix build utils)?

> More generally, I expect there are many ways I could improve the
> build system. What are they?
I know little about jpm, but in my opinion you ought to let the user
customize the flags passed on to jpm at least in the build target --
not so sure about check and install.  If janet-build-system allows some
degree of customization, consider also letting the user override the
test-target.

Regards,
Leo



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help me create a janet-build-system
  2021-05-15  7:00 ` Leo Prikler
@ 2021-05-15 19:25   ` Jack Hill
  2021-05-15 19:55     ` Leo Prikler
  0 siblings, 1 reply; 4+ messages in thread
From: Jack Hill @ 2021-05-15 19:25 UTC (permalink / raw)
  To: Leo Prikler; +Cc: guix-devel

Leo,

Thanks for your reply

On Sat, 15 May 2021, Leo Prikler wrote:

> Your code imports (guix utils), but (guix utils) is not present within
> the module closure present at build time.
> Did you mean (guix build utils)?

I used cc-for-target and cxx-for-target from (guix utils). Where would I 
add (guix utils) so it is included on the build side?

>> More generally, I expect there are many ways I could improve the
>> build system. What are they?
> I know little about jpm, but in my opinion you ought to let the user
> customize the flags passed on to jpm at least in the build target --
> not so sure about check and install.  If janet-build-system allows some
> degree of customization, consider also letting the user override the
> test-target.

I think I should at least try to make the with-toolchain package 
transformation option work. Beyond that, I'm not sure how much 
customization jpm offers without editing project.janet. I'll take a look 
at some of the other build systems for language-specific build tools for 
ideas (I think a lot of them have a similar, minimal feature set). I also 
hope that once I get a working build system and gain some experience using 
it to create packages, some customization opportunities will present 
themselves.

Best,
Jack


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help me create a janet-build-system
  2021-05-15 19:25   ` Jack Hill
@ 2021-05-15 19:55     ` Leo Prikler
  0 siblings, 0 replies; 4+ messages in thread
From: Leo Prikler @ 2021-05-15 19:55 UTC (permalink / raw)
  To: Jack Hill; +Cc: guix-devel

Am Samstag, den 15.05.2021, 15:25 -0400 schrieb Jack Hill:
> Leo,
> 
> Thanks for your reply
> 
> On Sat, 15 May 2021, Leo Prikler wrote:
> 
> > Your code imports (guix utils), but (guix utils) is not present
> > within
> > the module closure present at build time.
> > Did you mean (guix build utils)?
> 
> I used cc-for-target and cxx-for-target from (guix utils). Where
> would I add (guix utils) so it is included on the build side?
In my opinion, these flags ought to be added on the build-system side
of things, not on the build side.  There you can just add those two
flags to the ones already provided by the package.

> > > More generally, I expect there are many ways I could improve the
> > > build system. What are they?
> > I know little about jpm, but in my opinion you ought to let the
> > user
> > customize the flags passed on to jpm at least in the build target
> > --
> > not so sure about check and install.  If janet-build-system allows
> > some
> > degree of customization, consider also letting the user override
> > the
> > test-target.
> 
> I think I should at least try to make the with-toolchain package 
> transformation option work. Beyond that, I'm not sure how much 
> customization jpm offers without editing project.janet. [...]
If certain guixy things would require you to edit/create that file, you
should do that.  I think ant-build-system does something similar.

Regards,
Leo



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-15 19:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-15  5:07 Help me create a janet-build-system Jack Hill
2021-05-15  7:00 ` Leo Prikler
2021-05-15 19:25   ` Jack Hill
2021-05-15 19:55     ` Leo Prikler

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).