all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Jelle Licht <jlicht@fsfe.org>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Package graph queries
Date: Sun, 31 Jul 2016 00:19:44 +0200	[thread overview]
Message-ID: <87twf6ahvj.fsf_-_@gnu.org> (raw)
In-Reply-To: <CAPsKtfL5YT3Jz0WJOEk3gz=V5ANvBYc6L8sBeeNJeu+XbuUjUQ@mail.gmail.com> (Jelle Licht's message of "Fri, 29 Jul 2016 17:26:53 +0200")

Jelle Licht <jlicht@fsfe.org> skribis:

> On Jul 29, 2016 16:53, "Catonano" <catonano@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.

  reply	other threads:[~2016-07-30 22:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-24  1:06 [GSoC update] Npm & guix Jelle Licht
2016-07-25  8:41 ` Andy Wingo
2016-07-25 11:33 ` Jan Nieuwenhuizen
2016-07-25 21:26 ` Ludovic Courtès
2016-07-29 14:53   ` Catonano
2016-07-29 15:26     ` Jelle Licht
2016-07-30 22:19       ` Ludovic Courtès [this message]
2016-08-11  4:37         ` Package graph queries Catonano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87twf6ahvj.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=jlicht@fsfe.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.