Artanis modifications needed for Guix packaging

This page discusses modification to the Artanis web server softare required for packaging an Artanis application. Guidelines for writing a Guix compatible Artanis application can be found here.

Artanis

GNU Artanis is a web server written in Guile (a scheme dialect). Artanis -the web server software - has been packaged for Guix. The packaging recipe can be found in …/gnu/packages/guile-xyz.scm. Artanis applications such as LIMS*Nucleus are not by default packageable by guix due to the presence of a writeable ../tmp directory in the application folder. Here is the partial directory structure of LIMS*Nucleus:

The directory ../limsn/limsn/tmp holds temporary files created while users are navigating the application. Since the Guix store is immutable, a temporary folder is not allowed and must be moved outside of the application. Artanis defines a variable ‘current-toplevel’ which, in the above example would be ../limsn/limsn. In the labsolns modified artanis all references to ‘current-toplevel’ are divided into two groups:

variable description
1 current-toplevel redirected to /tmp/limsn i.e. references that create a temporary file
2 immutable-toplevel references that point to the original ‘current-toplevel’ i.e. references that do not create files and can reside in the immutable /gnu/store… directory

Source Code Modifications

To allow for Guix packaging of Artanis applications the following modifications to the Artanis source code are introduced during packaging:

File line Modified source code
utils.scm 279 (if (immutable-toplevel)
280 (format #f “~a/pub/~a” (immutable-toplevel) path)
833 (let* ((toplevel (immutable-toplevel))
1309 (immutable-toplevel) file)))
tpl/parser.scm 40 (format #f “~a/~a/~a” (immutable-toplevel) pub args))))
52 (mfile (format #f “~a/~a/manifest.json” (immutable-toplevel) path))
commands/work.scm 77 (let ((entry (string-append (immutable-toplevel) “/” *artanis-entry*)))
126 (add-to-load-path (immutable-toplevel))
mvc/controller.scm 45 (immutable-toplevel) ’name method)))
62 (define toplevel (immutable-toplevel))
webapi/restful.scm 58 (load (format #f “~a/app/api/~a.scm” (immutable-toplevel) s)))

Recipe File Modifications

The above changes are introduced during the installation of Artanis. Recipe file additions are:

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
	  ;;============START forguix mods=========================================================================
;;immutable-toplevel is the original current-toplevel in /gnu/store
;;current-toplevel is the mutable toplevel in /tmp/<appname>/tmp/cache

(substitute* "artanis/commands/work.scm"
(("\\(let \\(\\(entry \\(string-append \\(current-toplevel\\) \"/\" \\*artanis-entry\\*\\)\\)\\)")
"(let ((entry (string-append (immutable-toplevel) \"/\" *artanis-entry*)))")
(("\\(add-to-load-path \\(current-toplevel\\)\\)")
"(add-to-load-path (immutable-toplevel))")
(("\\(add-to-load-path \\(string-append \\(current-toplevel\\) \"/lib\"\\)\\)")
"(add-to-load-path (string-append (immutable-toplevel) \"/lib\"))"))
(substitute* '("artanis/tpl/parser.scm"
"artanis/mvc/controller.scm"
"artanis/webapi/restful.scm")
(("current-toplevel")
"immutable-toplevel"))
(substitute* "artanis/utils.scm"
(("\\(let\\* \\(\\(toplevel \\(current-toplevel\\)\\)")
"(let* ((toplevel (immutable-toplevel))")
(("\\(current-toplevel\\) file\\)\\)\\)")
"(immutable-toplevel) file)))")
(("\\(if \\(current-toplevel\\)")
"(if (immutable-toplevel)")
((" \\(let \\(\\(p \\(-> path\\)\\)\\)")
" (let ((p (-> path))(dummy (format (artanis-current-output) \"current-appname: ~a\" (current-appname) )))")
(("\\(format \\#f \"~a/pub/~a\" \\(current-toplevel\\) path\\)")
"(format #f \"~a/pub/~a\" (immutable-toplevel) path)")
)
(substitute* "artanis/env.scm"
((" current-toplevel\n")
" current-toplevel\n %immutable-toplevel\n immutable-toplevel\n")
(("\\(define \\(current-toplevel\\)\n")
"(define %immutable-toplevel (make-parameter #f))\n")
((" \\(or \\(%current-toplevel\\)\n")
" (define (immutable-toplevel)\n")
((" \\(find-ENTRY-path identity #t\\)\\)\\)\n")
" (or (%immutable-toplevel)\n (find-ENTRY-path identity #t)))\n\n(define (current-toplevel) (string-append \"/tmp/\" (and=> (string-match \".+/(.+)$\" (getcwd)) (lambda (m) (match:substring m 1))))) ")

) ;;use of (current-appname) causes disk thrashing and freezing
;; (find-ENTRY-path identity #t) evaluates to #f and so can't be used

;;============END forguix mods=========================================================================

Get the modified Artanis software

  1. Set up your system so that you can utilize the labsolns channel
  2. guix pull
  3. guix edit artanis (to see the recipe)
  4. guix package -i artanis (to install or upgrade to the modified Artanis)

Caution

Note that the Guix modified Artanis is labeled as v0.5.2 and so (Sept 2022) will “upgrade” your copy of Artanis.

Guix modified Artanis has been tested with LIMS*Nucleus. Modifications may have broken Artanis features that are not used by LIMS*Nucleus.