packages: Add 'hidden-package'.

* guix/packages.scm (hidden-package, hidden-package?): New procedures.
* gnu/packages.scm (fold-packages): Filter out 'hidden-package?'.
* tests/packages.scm ("hidden-package"): New test.
This commit is contained in:
Ludovic Courtès 2016-07-28 18:50:43 +02:00
parent cb55f9c652
commit 6980511b73
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
3 changed files with 21 additions and 1 deletions

View File

@ -200,7 +200,8 @@ same package twice."
(fold2 (lambda (module result seen) (fold2 (lambda (module result seen)
(fold2 (lambda (var result seen) (fold2 (lambda (var result seen)
(if (and (package? var) (if (and (package? var)
(not (vhash-assq var seen))) (not (vhash-assq var seen))
(not (hidden-package? var)))
(values (proc var result) (values (proc var result)
(vhash-consq var #t seen)) (vhash-consq var #t seen))
(values result seen))) (values result seen)))

View File

@ -81,6 +81,8 @@
package-maintainers package-maintainers
package-properties package-properties
package-location package-location
hidden-package
hidden-package?
package-field-location package-field-location
package-direct-sources package-direct-sources
@ -290,6 +292,19 @@ name of its URI."
package) package)
16))))) 16)))))
(define (hidden-package p)
"Return a \"hidden\" version of P--i.e., one that 'fold-packages' and thus,
user interfaces, ignores."
(package
(inherit p)
(properties `((hidden? . #t)
,@(package-properties p)))))
(define (hidden-package? p)
"Return true if P is \"hidden\"--i.e., must not be visible to user
interfaces."
(assoc-ref (package-properties p) 'hidden?))
(define (package-field-location package field) (define (package-field-location package field)
"Return the source code location of the definition of FIELD for PACKAGE, or "Return the source code location of the definition of FIELD for PACKAGE, or
#f if it could not be determined." #f if it could not be determined."

View File

@ -79,6 +79,10 @@
(write (write
(dummy-package "foo" (location #f))))))) (dummy-package "foo" (location #f)))))))
(test-assert "hidden-package"
(and (hidden-package? (hidden-package (dummy-package "foo")))
(not (hidden-package? (dummy-package "foo")))))
(test-assert "package-field-location" (test-assert "package-field-location"
(let () (let ()
(define (goto port line column) (define (goto port line column)