Commit 87850a5f authored by ROUBY Pierre-Antoine's avatar ROUBY Pierre-Antoine
Browse files

guix-kernel: Fix guix package.

* Makefile.am (kernel.json): Delete rule.
* environment.scm (arguments): substitute openssl, guile, guile-load-path,
  guile-load-compiled-path and kernel path.
  (source): Use local file.
* guix-kernel/environ.scm (guile-current-load-path->args-list,
  guix-current-load-compiled-path->args-list): New procedures.
* kernel.json: Rename 'kernel.json.in' to 'kernel.json'.
  (argv) Add '@guile@', '@LOAD_PATH@', '@LOAD_COMPILED_PATH@' and
  '@guix-jupyter-kernerl.scm@' for subsitution.
* guix-jupyter-kernel.scm (start-sub-kernel): Propagated guile load path
  and load compiled path.
parent fe0788b5
......@@ -27,15 +27,10 @@ SOURCES = \
guix-jupyter-kernel.scm \
guix-jupyter-subkernel.scm
EXTRA_DIST += kernel.json.in
EXTRA_DIST += kernel.json
assetsdir = $(datadir)/jupyter/kernels/guix/
nobase_dist_assets_DATA = kernel.json
# Flags for 'guild compile'.
GUILD_COMPILE_FLAGS = -Wformat -Wunbound-variable -Warity-mismatch
kernel.json: kernel.json.in
$(SED) -e 's,@''guilemoduledir''@,$(moddir),g' \
< $< > $@.tmp
mv $@.tmp $@
......@@ -6,6 +6,8 @@
(use-modules ((guix licenses) #:prefix license:)
(guix packages)
(guix download)
(guix git-download)
(guix gexp)
(guix utils)
(guix build-system gnu)
(gnu packages)
......@@ -19,14 +21,62 @@
(package
(name "guix-kernel")
(version "0.0.1")
(source (string-append (getcwd) "/guix-kernel-" version ".tar.gz"))
(source (local-file "." "guix-kernel"
#:recursive? #t))
(build-system gnu-build-system)
(arguments
`(#:phases
`(#:modules ((srfi srfi-26)
(ice-9 match)
(ice-9 popen)
(ice-9 rdelim)
,@%gnu-build-system-modules)
#:phases
(modify-phases %standard-phases
(add-before 'configure 'env
(lambda _
(setenv "GUILE_AUTO_COMPILE" "0"))))))
(setenv "GUILE_AUTO_COMPILE" "0")
#t))
(add-before 'build 'sed-openssl
(lambda* (#:key inputs outputs #:allow-other-keys)
(substitute* (string-append "guix-kernel/hmac.scm")
(("openssl")
(string-append (assoc-ref %build-inputs "openssl")
"/bin/openssl")))))
(add-after 'install 'sed-kernel-json
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(guix (assoc-ref inputs "guix"))
(guile (assoc-ref inputs "guile"))
(json (assoc-ref inputs "guile-json"))
(s-zmq (assoc-ref inputs "guile-simple-zmq"))
(deps (list out s-zmq guix json))
(effective
(read-line
(open-pipe* OPEN_READ
(string-append guile "/bin/guile")
"-c" "(display (effective-version))")))
(path (map (cut string-append "-L\", \"" <>
"/share/guile/site/"
effective)
deps))
(gopath (map (cut string-append "-C\", \"" <>
"/lib/guile/" effective
"/site-ccache")
deps))
(kernel-dir (string-append out "/share/jupyter/kernels/guix/")))
(substitute* (string-append kernel-dir "kernel.json")
(("@guile@")
(string-append (assoc-ref %build-inputs "guile")
"/bin/guile"))
(("@LOAD_PATH@")
(string-join path "\",\n\t\t\""))
(("@LOAD_COMPILED_PATH@")
(string-join gopath "\",\n\t\t\""))
(("@guix-jupyter-kernel.scm@")
(string-append out "/share/guile/site/2.2/"
"guix-jupyter-kernel.scm")))
#t))))))
(native-inputs
`(("autoconf" ,autoconf)
("automake" ,automake)
......
......@@ -387,11 +387,14 @@
(let ((guile-version (if (string-null? guile)
(guile-current-version->path)
(guile->path guile))))
(execle guile-version
(environ)
"guile" "--no-auto-compile" "-s"
subkernel-path
name notebook-info-key)))
(apply execle guile-version
(environ)
(append (list "guile")
(guile-current-load-path->args-list)
(guile-current-load-compiled-path->args-list)
(list "--no-auto-compile" "-s"
subkernel-path
name notebook-info-key)))))
(define (start-kernel pid)
(display (string-append "kernel: pid: " (number->string (getpid))
......
......@@ -24,9 +24,13 @@
#:use-module (guix monads)
#:use-module (guix derivations)
#:use-module (guix build utils)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
#:export (guile->path
guile-current-version->path
guile-current-load-path->args-list
guile-current-load-compiled-path->args-list
package-name->path))
......@@ -49,6 +53,16 @@
"Return path to current guile executable file."
(guile->path (string-append "guile" "@" (version))))
(define (guile-current-load-path->args-list)
"Return list of load path with '-L' prefix for each path."
(append-map (cut list "-L" <>)
%load-path))
(define (guile-current-load-compiled-path->args-list)
"Return list of load compiled path with '-C' prefix for each path."
(append-map (cut list "-C" <>)
%load-compiled-path))
(define (package-name->path name)
"Return store path for package coresponding to NAME."
(run-with-store (store) (m-package-by-name->package-path name)))
{
"argv": ["guile", "-s",
"@guilemoduledir@/guix-jupyter-kernel.scm",
"argv": ["@guile@",
"@LOAD_PATH@",
"@LOAD_COMPILED_PATH@",
"--no-auto-compile", "-s",
"@guix-jupyter-kernel.scm@",
"--", "{connection_file}"],
"display_name": "Guix",
"language": "scheme"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment