Last active
December 11, 2020 15:01
-
-
Save mbakke/f354272666fbef09c5229f7b853778f1 to your computer and use it in GitHub Desktop.
List the number of dependents of each package in Guix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (guix store) | |
(guix monads) | |
(guix packages) | |
(guix graph) | |
(guix scripts graph) | |
(gnu packages) | |
(ice-9 format)) | |
(define (all-packages) | |
(fold-packages (lambda (package result) | |
(cons package result)) | |
'() | |
#:select? (const #t))) ;include hidden packages | |
(with-store store | |
(run-with-store store | |
(mlet %store-monad ((edges (node-back-edges %bag-node-type | |
(package-closure (all-packages))))) | |
(define (dependents package) | |
(node-transitive-edges (list package) edges)) | |
(map (lambda (package) | |
(format #t "~d ~a~%" | |
(length (dependents package)) | |
(package-name package))) | |
(all-packages)) | |
(return #t)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment