Beyond started with the Guix workflow language
dynamic-workflow we create files and compressed those files. In the following workflow we will delete those compressed files to learn how we can extend a workflow at any point in a new workflow.
(define-module (extended-example-workflow) #:use-module (guix processes) #:use-module (guix workflows) #:use-module ((gnu packages compression) #:prefix package:) #:use-module (srfi srfi-1) #:use-module (example-workflow)) ; We are going to extend "example-workflow". (define (delete-file-template filename) (process (name (string-append "delete-file-" (basename filename))) (run-time (complexity (space (megabytes 20)) (time 10))) (procedure `(delete-file ,filename)))) (define-public extended-dynamic-workflow (let* (;; Get all processes of the other workflow. (foreign-processes (workflow-processes dynamic-workflow)) ;; Get the processes that we want to extend on. (compress-file-processes (processes-filter-by-name foreign-processes "compress-file")) ;; Create the new processes. (delete-file-processes (map delete-file-template (map process-outputs compress-file-processes)))) (workflow (name "extended-dynamic-workflow") (processes (append foreign-processes delete-file-processes)) (restrictions (append (workflow-restrictions dynamic-workflow) (zip delete-file-processes compress-file-processes))))))
delete-file-template we created a function that returns a
process that removes a file. We use this function in
extended-dynamic-workflow to run after each
restrictions fields we include the contents of
dynamic-workflow. Explicitly expressing the new
restrictions displays how this workflow extends the other in a concise way. Because
dynamic-workflow is defined in a Scheme module, we can use the
#:use-module facility to refer to it.