* Counting Packages yields wrong result
@ 2016-08-22 21:10 Björn Höfling
2016-08-23 10:56 ` Alex Kost
0 siblings, 1 reply; 3+ messages in thread
From: Björn Höfling @ 2016-08-22 21:10 UTC (permalink / raw)
To: Guix-Help
I tried to count the number of packages in GuixSD for myself, but my
result differs from the package list on the home page
(https://www.gnu.org/software/guix/packages/). Why?
Here is how I did it:
#!/run/current-system/profile/bin/guile -s
!#
; Counting number of packages in current system.
; This also includes packages with the same name,
; but different version string.
(use-modules (gnu))
(use-modules (guix))
(display "Number of packages: ")
(define cnt
(fold-packages
(lambda (pkg ctr)
(+ 1 ctr))
0))
(display cnt)
(newline)
Is that the correct way to walk through the list of packages anyway?
I always get the number 3747 back, even after a guix pull. The homepage
gives me 3881, and counting.
guix --version give me:
20160822.18
Looking at %load-path I figured out that
/run/current-system/profile/share/guile/site/2.0/guix
points to the ...guix-0.11.0-1 store path.
Is that my problem? How can I script over the newest pull?
Thank you,
Björn
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Counting Packages yields wrong result
2016-08-22 21:10 Counting Packages yields wrong result Björn Höfling
@ 2016-08-23 10:56 ` Alex Kost
2016-08-25 20:01 ` Björn Höfling
0 siblings, 1 reply; 3+ messages in thread
From: Alex Kost @ 2016-08-23 10:56 UTC (permalink / raw)
To: Björn Höfling; +Cc: Guix-Help
Björn Höfling (2016-08-23 00:10 +0300) wrote:
> I tried to count the number of packages in GuixSD for myself, but my
> result differs from the package list on the home page
> (https://www.gnu.org/software/guix/packages/). Why?
>
> Here is how I did it:
>
> #!/run/current-system/profile/bin/guile -s
> !#
>
> ; Counting number of packages in current system.
> ; This also includes packages with the same name,
> ; but different version string.
>
> (use-modules (gnu))
> (use-modules (guix))
Only (use-modules (gnu packages)) is needed.
> (display "Number of packages: ")
> (define cnt
> (fold-packages
> (lambda (pkg ctr)
> (+ 1 ctr))
> 0))
> (display cnt)
> (newline)
>
> Is that the correct way to walk through the list of packages anyway?
Yes (btw it gives me 3886 on the latest guix master).
Also note that it will also count your packages placed in
GUIX_PACKAGE_PATH. So to make a pure experiment you need to unset this
environment variable at first (if you use it of course).
> I always get the number 3747 back, even after a guix pull. The homepage
> gives me 3881, and counting.
>
> guix --version give me:
>
> 20160822.18
>
>
> Looking at %load-path I figured out that
>
> /run/current-system/profile/share/guile/site/2.0/guix
>
> points to the ...guix-0.11.0-1 store path.
>
> Is that my problem? How can I script over the newest pull?
"guix pull" updates "~/.config/guix/latest" link, and when you run
"guix" command, it uses the packages from that directory. So after
"guix pull" you'll get the latest package recipes for "guix ..."
commands.
But "guix pull" doesn't influence your guile script that uses guix
modules from some directories that come from GUILE_LOAD_PATH and
GUILE_LOAD_COMPILED_PATH. So to make your script use those fresh
"guix-pulled" modules, you can modify these environment variables to
include "/home/<you>/.config/guix/latest".
An alternative is to use guix directly from a git checkout.
See (info "(guix) Building from Git") for details.
Finally, note that 'fold-packages' folds over package objects, while
packages may have multiple outputs (for example "git" has 4 outputs),
which can be installed separately, so if you consider each output as a
separate package, then the number is bigger. The following blatant
violation of functional style gives me 4078 outputs:
(use-modules
(gnu packages)
(guix packages))
(define number-of-packages 0)
(define number-of-outputs 0)
(fold-packages
(lambda (package _)
(set! number-of-packages (1+ number-of-packages))
(set! number-of-outputs (+ number-of-outputs
(length (package-outputs package)))))
#f)
(format #t "Number of packages: ~d~%" number-of-packages)
(format #t "Number of outputs: ~d~%" number-of-outputs)
--
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Counting Packages yields wrong result
2016-08-23 10:56 ` Alex Kost
@ 2016-08-25 20:01 ` Björn Höfling
0 siblings, 0 replies; 3+ messages in thread
From: Björn Höfling @ 2016-08-25 20:01 UTC (permalink / raw)
To: Guix-Help
On Tue, 23 Aug 2016 13:56:39 +0300
Alex Kost <alezost@gmail.com> wrote:
> Björn Höfling (2016-08-23 00:10 +0300) wrote:
> > Is that my problem? How can I script over the newest pull?
>
> "guix pull" updates "~/.config/guix/latest" link, and when you run
> "guix" command, it uses the packages from that directory. So after
> "guix pull" you'll get the latest package recipes for "guix ..."
> commands.
>
> But "guix pull" doesn't influence your guile script that uses guix
> modules from some directories that come from GUILE_LOAD_PATH and
> GUILE_LOAD_COMPILED_PATH. So to make your script use those fresh
> "guix-pulled" modules, you can modify these environment variables to
> include "/home/<you>/.config/guix/latest".
Yes, when setting the GUILE_LOAD_PATH that way, counting will increase
witha guix pull.
> An alternative is to use guix directly from a git checkout.
> See (info "(guix) Building from Git") for details.
Will try that also at a later time.
Thank you,
Björn
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-08-25 20:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-22 21:10 Counting Packages yields wrong result Björn Höfling
2016-08-23 10:56 ` Alex Kost
2016-08-25 20:01 ` Björn Höfling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).