summaryrefslogtreecommitdiff
path: root/guix/scripts/graph.scm
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2023-01-30 11:33:18 +0200
committerEfraim Flashner <efraim@flashner.co.il>2023-01-30 12:39:40 +0200
commit4cf1acc7f3033b50b0bf19e02c9f522d522d338c (patch)
tree9fd64956ee60304c15387eb394cd649e49f01467 /guix/scripts/graph.scm
parentedb8c09addd186d9538d43b12af74d6c7aeea082 (diff)
parent595b53b74e3ef57a1c0c96108ba86d38a170a241 (diff)
Merge remote-tracking branch 'origin/master' into core-updates
Conflicts: doc/guix.texi gnu/local.mk gnu/packages/admin.scm gnu/packages/base.scm gnu/packages/chromium.scm gnu/packages/compression.scm gnu/packages/databases.scm gnu/packages/diffoscope.scm gnu/packages/freedesktop.scm gnu/packages/gnome.scm gnu/packages/gnupg.scm gnu/packages/guile.scm gnu/packages/inkscape.scm gnu/packages/llvm.scm gnu/packages/openldap.scm gnu/packages/pciutils.scm gnu/packages/ruby.scm gnu/packages/samba.scm gnu/packages/sqlite.scm gnu/packages/statistics.scm gnu/packages/syndication.scm gnu/packages/tex.scm gnu/packages/tls.scm gnu/packages/version-control.scm gnu/packages/xml.scm guix/build-system/copy.scm guix/scripts/home.scm
Diffstat (limited to 'guix/scripts/graph.scm')
-rw-r--r--guix/scripts/graph.scm14
1 files changed, 12 insertions, 2 deletions
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm
index 2f102180c9..6847dd1962 100644
--- a/guix/scripts/graph.scm
+++ b/guix/scripts/graph.scm
@@ -569,6 +569,12 @@ Emit a representation of the dependency graph of PACKAGE...\n"))
(category packaging)
(synopsis "view and query package dependency graphs")
+ (define (shorter? str1 str2)
+ (< (string-length str1) (string-length str2)))
+
+ (define length-sorted
+ (cut sort <> shorter?))
+
(with-error-handling
(define opts
(parse-command-line args %options
@@ -598,13 +604,17 @@ Emit a representation of the dependency graph of PACKAGE...\n"))
(run-with-store store
;; XXX: Since grafting can trigger unsolicited builds, disable it.
- (mlet %store-monad ((_ (set-grafting #f))
+ (mlet %store-monad ((_g (set-grafting #f))
(nodes (mapm %store-monad
(node-type-convert type)
(reverse items))))
(if (assoc-ref opts 'path?)
+ ;; Sort by string length such that, in case of multiple
+ ;; outputs, the shortest one (which corresponds to "out") is
+ ;; picked (yup, a hack).
(match nodes
- (((node1 _ ...) (node2 _ ...))
+ (((= length-sorted (node1 _ ...))
+ (= length-sorted (node2 _ ...)))
(display-path node1 node2 type))
(_
(leave (G_ "'--path' option requires exactly two \