Beyond started with the Guix workflow language
Recap
In the previous section we defined a workflow. This section builds on the knowledge from the previous section, so if you haven't read that, now is the time to get beyond started.
Extending workflows
In the dynamic-workflow
we created files and
compressed them. In the following workflow we will generate a file
containing some information about these compressed files to learn how
we can extend a workflow at any point in a new workflow.
;; We are going to extend the workflow defined in the file
;; "example-workflow.w".
define dynamic-workflow
load-workflow "example-workflow.w"
process: (list-file-template filename)
name
string-append "list-file-"
basename filename
packages "gzip"
inputs filename
outputs
string-append filename ".list"
run-time
complexity
space 20 mebibytes
time 30 seconds
# { gzip --list {{inputs}} > {{outputs}} }
;; Get all processes of the other workflow.
define foreign-processes
workflow-processes dynamic-workflow
;; Get the processes that we want to extend on.
define compress-file-processes
processes-filter-by-name foreign-processes "compress-file"
;; Create the new processes.
define list-file-processes
map list-file-template
append-map process-outputs compress-file-processes
workflow: extended-dynamic-workflow
processes
append
;; These are the process connections of the imported workflow
workflow-restrictions dynamic-workflow
;; And these are the new process connections. The "zip" procedure
;; pairs up each of the processes in "list-file-processes" with
;; one of the processes in "compress-file-processes".
zip list-file-processes compress-file-processes
With list-file-template
we created a procedure
that returns a process
that generates a file containing
details about the compressed archive. We use this function
in extended-dynamic-workflow
to run after
each compress-file
process.
In the processes
field we include the contents
of dynamic-workflow
, thereby concisely extending it.
Further reading
The GNU Guile and GNU Guix manuals are good places to learn the language and concepts on which GWL builds.