Previous: select count packages on criteria, Up: Guix REPL [Contents][Index]
(→ 5 min 20 s into Simon Tournier presentation)
The arguments-vs-import.scm
file shown below demonstrate some
more sophisticated selection and grouping of packages, and can be passed
to guix repl
like so :
$ guix repl -- arguments-vs-import.scm
Its interpretation will output a table similar to the one show below the script-file content, giving the number of packages which “tweak” their arguments to the build and the number of packages which don’t, all grouped by build-system types.
arguments-vs-import.scm
file content :
(use-modules (guix) (gnu) (ice-9 match)) (define table (make-hash-table)) (fold-packages (lambda (package result) (let ((bs (build-system-name (package-build-system package))) (arg (package-arguments package))) (match (hash-ref result bs) ((tot wo wi) (if (null? arg) (hash-set! result bs (list (1+ tot) (1+ wo) wi)) (hash-set! result bs (list (1+ tot) wo (1+ wi))))) (#f (if (null? arg) (hash-set! result bs (list 1 1 0)) (hash-set! result bs (list 1 0 1)))) (_ (format #t "Error: ~s~%" (package-name package)))) result)) table) (define fmt "~13s: ~4s = ~4s = ~4s + ~4s~%") (format #t fmt 'key 'tot 'tot 'no-arguments 'arguments) (hash-for-each-handle (lambda (kv) (match kv ((key . value) (match value ((tot wo wi) (format #t fmt key (+ wo wi) tot wo wi)))))) table)
call from shell and output :
$ cd ~/tmp/10-years-of-guix $ guix repl -- guix-repl-and-beyond.scm key : tot = tot = no-arguments + arguments ocaml : 57 = 57 = 0 + 57 haskell : 721 = 721 = 504 + 217 clojure : 11 = 11 = 0 + 11 [skipping for clarity] meson : 442 = 442 = 89 + 353 texlive : 143 = 143 = 0 + 143 python : 2619 = 2619 = 797 + 1822 binary : 14 = 14 = 0 + 14