To define a module and export its defined methods:
1 | (define-module (conman utilities) |
Note that when you use (use-module (conman utilities))
that the module designation is essentially a path to the .scm. So in this example the system expects to find somewhere on the %load-path the directory conman with the utilities.scm file in it. To append the working directory to the load path, one of the very first commands should be (add-to-load-path "/home/mbc/projects")
. If the file instead was located at /home/mbc/projects/conman/web/utilities.scm, then I would have to use (use-module (conman web utilities))
To run as a script in a protected Guix environment:
1 | guix environment --pure --network --expose=/etc/ssl/certs/ --manifest=manifest.scm -- guile -e main -s conman.scm 7 2 |
In this example the args passed into main are ‘(‘conman.scm’ ‘7’ ‘2’)
1 | (specifications->manifest |
The script comman can be shortened by placing some of the commands in the script file. This may make the script computer specific - i.e. the hash for the Guile executable might be unique for each computer. Determine what the Guile executable is by looking in /gnu/store:
1 | mbc@xps:~$ find /gnu/store -wholename *guile-3.0.4/bin/guile |
Include the executable at the top of the script. See https://www.gnu.org/software/guile/manual/html_node/The-Meta-Switch.html
1 |
|
Now an abridged command can be used in the terminal:
1 | mbc@xps:~/projects/conman$ guix environment --pure --network --expose=/etc/ssl/certs/ --manifest=manifest.scm -- ./conman.scm 7 2 |
1 |