summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-03-27 14:00:48 +0200
committerLudovic Courtès <ludo@gnu.org>2018-03-27 14:51:44 +0200
commitb06a70e05dc6252a3ecb28db5898de7ebc110973 (patch)
tree08ed804b9f76857f02bd0b8ab1f34e13c9a0e026 /guix/scripts
parentde0021322d010871d2c144f01f9dc4efc5c231c4 (diff)
graph: Add "module" node type.
* guix/scripts/graph.scm (module-from-package) (source-module-dependencies*): New procedures. (%module-node-type): New variable. (%node-types): Add it. * guix/modules.scm (source-module-dependencies): Export. * tests/graph.scm ("module graph"): New test. * doc/guix.texi (Invoking guix graph): Document it.
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/graph.scm38
1 files changed, 36 insertions, 2 deletions
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm
index 78f09f181b..346ca4ea88 100644
--- a/guix/scripts/graph.scm
+++ b/guix/scripts/graph.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -27,9 +27,11 @@
#:use-module (guix gexp)
#:use-module (guix derivations)
#:use-module (guix memoization)
+ #:use-module (guix modules)
#:use-module ((guix build-system gnu) #:select (standard-packages))
#:use-module (gnu packages)
#:use-module (guix sets)
+ #:use-module ((guix utils) #:select (location-file))
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
@@ -44,6 +46,7 @@
%derivation-node-type
%reference-node-type
%referrer-node-type
+ %module-node-type
%node-types
guix-graph))
@@ -332,6 +335,36 @@ substitutes."
;;;
+;;; Scheme modules.
+;;;
+
+(define (module-from-package package)
+ (file-name->module-name (location-file (package-location package))))
+
+(define (source-module-dependencies* module)
+ "Like 'source-module-dependencies' but filter out modules that are not
+package modules, while attempting to retain user package modules."
+ (remove (match-lambda
+ (('guix _ ...) #t)
+ (('system _ ...) #t)
+ (('language _ ...) #t)
+ (('ice-9 _ ...) #t)
+ (('srfi _ ...) #t)
+ (_ #f))
+ (source-module-dependencies module)))
+
+(define %module-node-type
+ ;; Show the graph of package modules.
+ (node-type
+ (name "module")
+ (description "the graph of package modules")
+ (convert (lift1 (compose list module-from-package) %store-monad))
+ (identifier (lift1 identity %store-monad))
+ (label object->string)
+ (edges (lift1 source-module-dependencies* %store-monad))))
+
+
+;;;
;;; List of node types.
;;;
@@ -344,7 +377,8 @@ substitutes."
%bag-emerged-node-type
%derivation-node-type
%reference-node-type
- %referrer-node-type))
+ %referrer-node-type
+ %module-node-type))
(define (lookup-node-type name)
"Return the node type called NAME. Raise an error if it is not found."