[bug#74542,v2,05/16] packages: Factorize ‘all-packages’.
Commit Message
* gnu/packages.scm (all-packages): New procedure.
* etc/source-manifest.scm (all-packages): Remove.
* guix/scripts/graph.scm (all-packages): Remove.
* guix/scripts/refresh.scm (all-packages): Remove.
* guix/scripts/weather.scm (all-packages): Remove.
Change-Id: I6072952c4b877b541037ce86402cfb7744eeb0a0
---
etc/source-manifest.scm | 13 +------------
gnu/packages.scm | 20 +++++++++++++++++++-
guix/scripts/graph.scm | 10 ----------
guix/scripts/refresh.scm | 10 ----------
guix/scripts/weather.scm | 15 ---------------
5 files changed, 20 insertions(+), 48 deletions(-)
Comments
Hi Ludovic,
Ludovic Courtès <ludo@gnu.org> writes:
> * gnu/packages.scm (all-packages): New procedure.
> * etc/source-manifest.scm (all-packages): Remove.
> * guix/scripts/graph.scm (all-packages): Remove.
> * guix/scripts/refresh.scm (all-packages): Remove.
> * guix/scripts/weather.scm (all-packages): Remove.
LGTM.
[...]
> @@ -253,6 +254,23 @@ (define* (fold-packages proc init
> init
> modules))
>
> +(define all-packages
> + (mlambda ()
> + "Return the list of all public packages, including replacements and hidden
> +packages, excluding superseded packages."
Reading the above doc made me question; are replacements always supposed
to be made public? I typically would leave them private to avoid
cluttering the CLI with duplicate packages.
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>> @@ -253,6 +254,23 @@ (define* (fold-packages proc init
>> init
>> modules))
>>
>> +(define all-packages
>> + (mlambda ()
>> + "Return the list of all public packages, including replacements and hidden
>> +packages, excluding superseded packages."
>
> Reading the above doc made me question; are replacements always supposed
> to be made public? I typically would leave them private to avoid
> cluttering the CLI with duplicate packages.
Replacements are always reachable via the ‘replacement’ field, whether
they’re public or not.
If they’re public, they’re also visible from the user interface, which
is probably nicer. Other than that, it doesn’t make a big difference.
Ludo’.
Hi Ludovic,
Ludovic Courtès <ludo@gnu.org> writes:
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>>> @@ -253,6 +254,23 @@ (define* (fold-packages proc init
>>> init
>>> modules))
>>>
>>> +(define all-packages
>>> + (mlambda ()
>>> + "Return the list of all public packages, including replacements and hidden
>>> +packages, excluding superseded packages."
>>
>> Reading the above doc made me question; are replacements always supposed
>> to be made public? I typically would leave them private to avoid
>> cluttering the CLI with duplicate packages.
>
> Replacements are always reachable via the ‘replacement’ field, whether
> they’re public or not.
>
> If they’re public, they’re also visible from the user interface, which
> is probably nicer. Other than that, it doesn’t make a big difference.
I see, thanks for explaining. Assuming they have the same name, the
interface for 'guix search $name' would now should two versions
available, while in theory if you 'guix shell $name@older-version' you'd
get the graft anyway, which is at the newer (fixed) version.
And, 'guix build $name', although the CLI would say version is Y, would
actually show version X in the store, which could be confusing in some
cases.
Both have good and bad points... I'm not too sure which one is
preferable. Probably, as you said, seeing the newest version which is
used on the CLI is preferable to seeing the same version match in the
package store file name, so I think I'll make replacements public from
now on... another thing to document some day!
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021, 2024 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -25,17 +25,6 @@
(guix packages) (guix profiles)
(gnu packages))
-(define (all-packages)
- "Return the list of all the packages, public or private, omitting only
-superseded packages."
- (fold-packages (lambda (package lst)
- (match (package-replacement package)
- (#f (cons package lst))
- (replacement
- (append (list replacement package) lst))))
- '()
- #:select? (negate package-superseded)))
-
(define (upstream-origin source)
"Return SOURCE without any patches or snippet."
(origin (inherit source)
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012-2020, 2022-2023 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012-2020, 2022-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2016, 2017 Alex Kost <alezost@gmail.com>
@@ -56,6 +56,7 @@ (define-module (gnu packages)
cache-is-authoritative?
fold-packages
+ all-packages
fold-available-packages
find-newest-available-packages
@@ -253,6 +254,23 @@ (define* (fold-packages proc init
init
modules))
+(define all-packages
+ (mlambda ()
+ "Return the list of all public packages, including replacements and hidden
+packages, excluding superseded packages."
+ (delete-duplicates
+ (fold-packages (lambda (package result)
+ (match (package-replacement package)
+ ((? package? replacement)
+ (cons* replacement package result))
+ (#f
+ (cons package result))))
+ '()
+
+ ;; Dismiss deprecated packages but keep hidden packages.
+ #:select? (negate package-superseded))
+ eq?)))
+
(define %package-cache-file
;; Location of the package cache.
"/lib/guix/package.cache")
@@ -119,16 +119,6 @@ (define %package-node-type
;;; Reverse package DAG.
;;;
-(define (all-packages) ;XXX: duplicated from (guix scripts refresh)
- "Return the list of all the distro's packages."
- (fold-packages (lambda (package result)
- ;; Ignore deprecated packages.
- (if (package-superseded package)
- result
- (cons package result)))
- '()
- #:select? (const #t))) ;include hidden packages
-
(define %reverse-package-node-type
;; For this node type we first need to compute the list of packages and the
;; list of back-edges. Since we want to do it only once, we use the
@@ -455,16 +455,6 @@ (define* (check-for-package-update update-spec updaters #:key warn?)
;;; Dependents.
;;;
-(define (all-packages)
- "Return the list of all the distro's packages."
- (fold-packages (lambda (package result)
- ;; Ignore deprecated packages.
- (if (package-superseded package)
- result
- (cons package result)))
- '()
- #:select? (const #t))) ;include hidden packages
-
(define (list-dependents packages)
"List all the things that would need to be rebuilt if PACKAGES are changed."
;; Using %BAG-NODE-TYPE is more accurate than using %PACKAGE-NODE-TYPE
@@ -55,21 +55,6 @@ (define-module (guix scripts weather)
#:use-module (ice-9 vlist)
#:export (guix-weather))
-(define (all-packages)
- "Return the list of public packages we are going to query."
- (delete-duplicates
- (fold-packages (lambda (package result)
- (match (package-replacement package)
- ((? package? replacement)
- (cons* replacement package result))
- (#f
- (cons package result))))
- '()
-
- ;; Dismiss deprecated packages but keep hidden packages.
- #:select? (negate package-superseded))
- eq?))
-
(define (call-with-progress-reporter reporter proc)
"This is a variant of 'call-with-progress-reporter' that works with monadic
scope."