diff options
| author | Hilton Chain <hako@ultrarare.space> | 2025-05-11 01:08:40 +0800 |
|---|---|---|
| committer | Hilton Chain <hako@ultrarare.space> | 2025-05-15 21:22:42 +0800 |
| commit | 38d420fa5ae4b69e8ef118ffffba50a68d3d9893 (patch) | |
| tree | b28cbaaf62bc5c94add1ad47f5a8ed1fcbeb077e | |
| parent | 457b17de16d599f27c279a322ac820eaf15704e9 (diff) | |
nongnu: Add all-nongnu-packages.
* nongnu/packages.scm (%nongnu-package-module-path): New variable.
(all-nongnu-packages): New procedure.
| -rw-r--r-- | nongnu/packages.scm | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/nongnu/packages.scm b/nongnu/packages.scm index 756f6cf..f2a2b71 100644 --- a/nongnu/packages.scm +++ b/nongnu/packages.scm | |||
| @@ -5,12 +5,18 @@ | |||
| 5 | (define-module (nongnu packages) | 5 | (define-module (nongnu packages) |
| 6 | #:use-module (gnu packages) | 6 | #:use-module (gnu packages) |
| 7 | #:use-module (guix diagnostics) | 7 | #:use-module (guix diagnostics) |
| 8 | #:use-module (guix discovery) | ||
| 8 | #:use-module (guix i18n) | 9 | #:use-module (guix i18n) |
| 10 | #:use-module (guix memoization) | ||
| 11 | #:use-module (guix packages) | ||
| 12 | #:use-module (guix ui) | ||
| 9 | #:use-module (ice-9 match) | 13 | #:use-module (ice-9 match) |
| 10 | #:use-module (srfi srfi-34) | 14 | #:use-module (srfi srfi-34) |
| 11 | #:replace (%patch-path | 15 | #:replace (%patch-path |
| 12 | search-patch) | 16 | search-patch) |
| 13 | #:export (nongnu-patches)) | 17 | #:export (nongnu-patches |
| 18 | %nongnu-package-module-path | ||
| 19 | all-nongnu-packages)) | ||
| 14 | 20 | ||
| 15 | ;;; Commentary: | 21 | ;;; Commentary: |
| 16 | ;;; | 22 | ;;; |
| @@ -40,6 +46,9 @@ | |||
| 40 | (try ("nongnu/packages/firmware.scm" nongnu/ packages/) | 46 | (try ("nongnu/packages/firmware.scm" nongnu/ packages/) |
| 41 | ("nongnu/ci.scm" nongnu/)))) | 47 | ("nongnu/ci.scm" nongnu/)))) |
| 42 | 48 | ||
| 49 | (define %nongnu-package-module-path | ||
| 50 | `((,%nongnu-root-directory . "nongnu/packages"))) | ||
| 51 | |||
| 43 | (define %patch-path | 52 | (define %patch-path |
| 44 | ;; Define it after '%package-module-path' so that '%load-path' contains user | 53 | ;; Define it after '%package-module-path' so that '%load-path' contains user |
| 45 | ;; directories, allowing patches in $GUIX_PACKAGE_PATH to be found. | 54 | ;; directories, allowing patches in $GUIX_PACKAGE_PATH to be found. |
| @@ -64,3 +73,29 @@ | |||
| 64 | "Return the list of absolute file names corresponding to each | 73 | "Return the list of absolute file names corresponding to each |
| 65 | FILE-NAME found in %PATCH-PATH." | 74 | FILE-NAME found in %PATCH-PATH." |
| 66 | (list (search-patch file-name) ...)) | 75 | (list (search-patch file-name) ...)) |
| 76 | |||
| 77 | ;; Adapted from (@ (gnu packages) all-packages). | ||
| 78 | (define all-nongnu-packages | ||
| 79 | (mlambda () | ||
| 80 | "Return the list of all public packages, including replacements and hidden | ||
| 81 | packages, excluding superseded packages." | ||
| 82 | ;; Note: 'fold-packages' never traverses the same package twice but | ||
| 83 | ;; replacements break that (they may or may not be visible to | ||
| 84 | ;; 'fold-packages'), hence this hash table to track visited packages. | ||
| 85 | (define visited (make-hash-table)) | ||
| 86 | |||
| 87 | (fold-packages (lambda (package result) | ||
| 88 | (if (hashq-ref visited package) | ||
| 89 | result | ||
| 90 | (begin | ||
| 91 | (hashq-set! visited package #t) | ||
| 92 | (match (package-replacement package) | ||
| 93 | ((? package? replacement) | ||
| 94 | (hashq-set! visited replacement #t) | ||
| 95 | (cons* replacement package result)) | ||
| 96 | (#f | ||
| 97 | (cons package result)))))) | ||
| 98 | '() | ||
| 99 | (all-modules %nongnu-package-module-path #:warn warn-about-load-error) | ||
| 100 | ;; Dismiss deprecated packages but keep hidden packages. | ||
| 101 | #:select? (negate package-superseded)))) | ||
