Skip to content

Instantly share code, notes, and snippets.

@mbakke
Last active December 11, 2020 15:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbakke/f354272666fbef09c5229f7b853778f1 to your computer and use it in GitHub Desktop.
Save mbakke/f354272666fbef09c5229f7b853778f1 to your computer and use it in GitHub Desktop.
List the number of dependents of each package in Guix
(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