Jelle Licht <jli...@fsfe.org> skribis: > On Jul 29, 2016 16:53, "Catonano" <caton...@gmail.com> wrote:
[...] >> For example: which are the packages with less or no dependencies (and a >> lot of dependants) ? >> Because those should be imported first, in my opinion. [...] > ^ This, I like. Does anyone have any suggestions on tools that could help > me do this in guile? I understand you want to perform these queries on NPM packages, not Guix packages, but if you could hook your NPM package representation in (guix graph)¹, you could do the same as this: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use(guix graph) scheme@(guile-user)> ,use(guix scripts graph) scheme@(guile-user)> ,use(gnu packages) scheme@(guile-user)> ,use(guix monad-repl) scheme@(guile-user)> ,enter-store-monad store-monad@(guile-user) [1]> (node-back-edges %bag-node-type (fold-packages cons '())) $4 = #<procedure 59ac880 at guix/graph.scm:87:17 (node)> store-monad@(guile-user) [1]> ,q scheme@(guile-user)> ,use(srfi srfi-1) scheme@(guile-user)> (filter (lambda (p) (> (node-reachable-count (list p) $4) 600)) (fold-packages cons '())) $5 = (#<package inputproto@2.3.1 gnu/packages/xorg.scm:973 325e3c0> #<package renderproto@0.11.1 gnu/packages/xorg.scm:1690 326c000> #<package xextproto@7.3.0 gnu/packages/xorg.scm:2308 328df00> #<package libxft@2.3.2 gnu/packages/xorg.scm:1302 326ca80> #<package libsm@1.2.2 gnu/packages/xorg.scm:1187 326cd80> #<package xproto@7.0.28 gnu/packages/xorg.scm:4711 32c0240> #<package xorg-rgb@1.0.6 gnu/packages/xorg.scm:4408 32c09c0> #<package libx11@1.6.3 gnu/packages/xorg.scm:5139 32cf9c0> #<package libxdmcp@1.1.2 gnu/packages/xorg.scm:1277 326cb40> #<package libpthread-stubs@0.3 gnu/packages/xorg.scm:1160 326ce40> #<package libxrender@0.9.9 gnu/packages/xorg.scm:4577 32c0540> #<package xcb-proto@1.11 gnu/packages/xorg.scm:2061 327e600> #<package kbproto@1.0.7 gnu/packages/xorg.scm:997 325e300> […]) scheme@(guile-user)> (length $5) $6 = 119 --8<---------------cut here---------------end--------------->8--- The code above lists all the packages with more than 600 dependents. It’s inefficient (a bit less than a minute here) because ‘node-reachable-count’ does a complete graph traversal (you could have a variant of it that caches the value for each node, instead). HTH, Ludo’. ¹ All you need is to define a <node-type>, which is essentially 4 methods.