1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
| | (define-module (guix build julia-build-system)
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
#:use-module (guix build utils)
;; #:use-module (srfi srfi-1)
;; #:use-module (srfi srfi-11)
;; #:use-module (srfi srfi-26)
;; #:use-module (ice-9 rdelim)
;; #:use-module (ice-9 regex)
#:use-module (ice-9 match)
#:export (%standard-phases
julia-create-package-toml
julia-build))
;; (define* (set-emacs-load-path #:key source inputs #:allow-other-keys)
;; (define (inputs->directories inputs)
;; "Extract the directory part from INPUTS."
;; (match inputs
;; (((names . directories) ...) directories)))
;; (define (input-directory->el-directory input-directory)
;; "Return the correct Emacs Lisp directory in INPUT-DIRECTORY or #f, if there
;; is no Emacs Lisp directory."
;; (let ((legacy-elisp-directory (string-append input-directory %legacy-install-suffix))
;; (guix-elisp-directory
;; (string-append
;; input-directory %install-suffix "/"
;; (store-directory->elpa-name-version input-directory))))
;; (cond
;; ((file-exists? guix-elisp-directory) guix-elisp-directory)
;; ((file-exists? legacy-elisp-directory) legacy-elisp-directory)
;; (else #f))))
;; (define (input-directories->el-directories input-directories)
;; "Return the list of Emacs Lisp directories in INPUT-DIRECTORIES."
;; (filter-map input-directory->el-directory input-directories))
;; "Set the EMACSLOADPATH environment variable so that dependencies are found."
;; (let* ((source-directory (getcwd))
;; (input-elisp-directories (input-directories->el-directories
;; (inputs->directories inputs)))
;; (emacs-load-path-value
;; (string-join
;; (append input-elisp-directories (list source-directory))
;; ":" 'suffix)))
;; (setenv "EMACSLOADPATH" emacs-load-path-value)
;; (format #t "environment variable `EMACSLOADPATH' set to ~a\n"
;; emacs-load-path-value)))
(define* (install #:key outputs source #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(package-dir (string-append out "/share/julia/packages/"
(string-append
(strip-store-file-name source)))))
(mkdir-p package-dir)
(copy-recursively source package-dir))
#t)
;; FIXME: Precompilation is working, but I don't know how to tell
;; julia to use use it. If setting HOME to
;; /gnu/store/xib48jxkhiy0gylnm3q430zfwk6am47h-profile/share/julia/compiled/,
;; julia tries to write files there
(define* (precompile #:key outputs source inputs #:allow-other-keys)
(define (inputs->directories inputs)
"Extract the directory part from INPUTS."
(match inputs
(((names . directories) ...) directories)))
(let* ((out (assoc-ref outputs "out"))
(builddir (string-append out "/share/julia/"))
(pacakge (strip-store-file-name source)))
(mkdir-p builddir)
(setenv "JULIA_DEPOT_PATH" builddir)
(setenv "JULIA_LOAD_PATH"
(string-append
"@stdlib:"
(string-append out "/share/julia/packages/:")
(string-join (inputs->directories inputs) "/share/julia/packages/:")))
;; (invoke "julia" "-e" (string-append "println(LOAD_PATH)"))
(invoke "julia" "-e" (string-append "using " pacakge))
)
#t)
;; (define* (check #:key outputs source inputs #:allow-other-keys)
;; (define (inputs->directories inputs)
;; "Extract the directory part from INPUTS."
;; (match inputs
;; (((names . directories) ...) directories)))
;; (let* ((out (assoc-ref outputs "out"))
;; (builddir (string-append out "/share/julia/"))
;; (pacakge (strip-store-file-name source)))
;; (mkdir-p builddir)
;; (setenv "JULIA_DEPOT_PATH" builddir)
;; (setenv "JULIA_LOAD_PATH"
;; (string-append
;; "@:@v#.#:@stdlib:"
;; (string-append out "/share/julia/packages/:")
;; (string-join (inputs->directories inputs) "/share/julia/packages/:")))
;; ;; (invoke "julia" "-e" (string-append "println(LOAD_PATH)"))
;; (invoke "julia" "-e" (string-append "using Pkg; Pkg.test(\"" pacakge "\")"))
;; )
;; #t)
;;*
(define (julia-create-package-toml outputs source
name uuid version
deps)
(let ((f (open-file
(string-append
(assoc-ref outputs "out")
"/share/julia/packages/"
(string-append
name "/Project.toml"))
"w")))
(display (string-append
"
name = \"" name "\"
uuid = \"" uuid "\"
version = \"" version "\"
") f)
(when (not (null? deps))
(display "[deps]\n" f)
(for-each (lambda dep
(display (string-append (car (car dep)) " = \"" (cdr (car dep)) "\"\n")
f))
deps))
(close-port f))
#t)
(define %standard-phases
(modify-phases gnu:%standard-phases
(replace 'install install)
(add-after 'install 'precompile precompile)
;; (replace 'check check)
;; (add-after 'unpack 'set-julia-load-path set-julia-load-path)
(delete 'configure)
(delete 'bootstrap)
(delete 'patch-usr-bin-file)
(delete 'build)
(delete 'reset-gzip-timestamps)
(delete 'check)))
(define* (julia-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
"Build the given Julia package, applying all of PHASES in order."
(apply gnu:gnu-build
#:inputs inputs #:phases phases
args))
|