diff options
author | Tobias Geerinckx-Rice <me@tobias.gr> | 2023-08-27 02:00:00 +0200 |
---|---|---|
committer | Tobias Geerinckx-Rice <me@tobias.gr> | 2024-09-01 02:00:00 +0200 |
commit | de4da24d346c9c52b74a11c4978e908c0ff132b2 (patch) | |
tree | 6826ed5a4cf9297d82de218ed73d965788ac1b57 | |
parent | c04d489e772206b27e90681addfa2b578d4ebb89 (diff) |
WIP graph -f
-rw-r--r-- | guix/scripts/graph.scm | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm index 6740858d8b..f719fe8362 100644 --- a/guix/scripts/graph.scm +++ b/guix/scripts/graph.scm @@ -21,6 +21,7 @@ #:use-module (guix ui) #:use-module (guix graph) #:use-module (guix scripts) + #:autoload (guix import json) (json->scheme-file) #:use-module (guix packages) #:use-module (guix monads) #:use-module (guix store) @@ -505,6 +506,9 @@ package modules, while attempting to retain user package modules." (option '(#\e "expression") #t #f (lambda (opt name arg result) (alist-cons 'expression arg result))) + (option '(#\f "file") #t #f + (lambda (opt name arg result) + (alist-cons 'file arg result))) (find (lambda (option) (member "load-path" (option-names option))) %standard-build-options) @@ -587,17 +591,23 @@ Emit a representation of the dependency graph of PACKAGE...\n")) (with-store store (let* ((transform (options->transformation opts)) (max-depth (assoc-ref opts 'max-depth)) - (items (filter-map (match-lambda - (('argument . (? store-path? item)) - item) - (('argument . spec) - (transform - (specification->package spec))) - (('expression . exp) - (transform - (read/eval-package-expression exp))) - (_ #f)) - opts))) + (items + (filter-map (match-lambda + (('argument . (? store-path? item)) + item) + (('argument . spec) + (transform + (specification->package spec))) + (('expression . exp) + (transform + (read/eval-package-expression exp))) + (('file . file) + (let ((file (or (and (string-suffix? ".json" file) + (json->scheme-file file)) + file))) + (transform (load* file (make-user-module '()))))) + (_ #f)) + opts))) (when (null? items) (warning (G_ "no arguments specified; creating an empty graph~%"))) |