summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Buddelmeijer <hugo@buddelmeijer.nl>2026-08-18 21:39:21 +0200
committerLudovic Courtès <ludo@gnu.org>2026-09-02 12:16:03 +0200
commit84b0e85c3ce82e904389a5b77cbfc383215829e9 (patch)
tree73c97de824e4f0f679d133780e99fbb49931002a
parent925c116b46941fcd41e9fa35f3fdc8a526b674a0 (diff)
scripts: lint: Add --manifest option.
* guix/scrips/lint.scm (show-help): Describe option. (%options): Add 'manifest'option. (guix-lint): Run checkers on packages defined in manifest. * doc/guix.texi (Invoking guix lint): Document option. * tests/guix-lint.sh: Test option. Normalize whitespace. * guix/scripts/refresh.scm: Export packages-from-manifest. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Modified-by: Ludovic Courtès <ludo@gnu.org> Merges: #10653
-rw-r--r--doc/guix.texi10
-rw-r--r--guix/scripts/lint.scm22
-rw-r--r--guix/scripts/refresh.scm3
-rw-r--r--tests/guix-lint.sh12
4 files changed, 38 insertions, 9 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 73d616aa1b6..8f09adf9506 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -16927,6 +16927,12 @@ guix lint @var{options} @var{package}@dots{}
16927@end example 16927@end example
16928 16928
16929If no package is given on the command line, then all packages are checked. 16929If no package is given on the command line, then all packages are checked.
16930To check packages in a particular manifest, use:
16931
16932@example
16933guix lint @var{options} --manifest=@var{file} @dots{}
16934@end example
16935
16930To check packages in particular source files, the syntax is: 16936To check packages in particular source files, the syntax is:
16931 16937
16932@example 16938@example
@@ -16961,6 +16967,10 @@ This is useful to unambiguously designate packages, as in this example:
16961guix lint -c archival -e '(@@ (gnu packages guile) guile-3.0)' 16967guix lint -c archival -e '(@@ (gnu packages guile) guile-3.0)'
16962@end example 16968@end example
16963 16969
16970@item --manifest=@var{file}
16971@itemx -m @var{file}
16972Run checkers on packages in manifest @var{file} (@pxref{Writing Manifests}).
16973
16964@item --no-network 16974@item --no-network
16965@itemx -n 16975@itemx -n
16966Only enable the checkers that do not depend on Internet access. 16976Only enable the checkers that do not depend on Internet access.
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 6a317bf64d5..40df87e5234 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -37,6 +37,8 @@
37 #:use-module (guix store) 37 #:use-module (guix store)
38 #:use-module (guix scripts) 38 #:use-module (guix scripts)
39 #:use-module (guix scripts build) 39 #:use-module (guix scripts build)
40 #:autoload (guix scripts refresh) (packages-from-manifest)
41 #:use-module (guix scripts refresh)
40 #:use-module (gnu packages) 42 #:use-module (gnu packages)
41 #:use-module (ice-9 match) 43 #:use-module (ice-9 match)
42 #:use-module (ice-9 format) 44 #:use-module (ice-9 format)
@@ -137,6 +139,9 @@ run the checkers on all packages.\n"))
137 -e, --expression=EXPR consider the package EXPR evaluates to")) 139 -e, --expression=EXPR consider the package EXPR evaluates to"))
138 140
139 (display (G_ " 141 (display (G_ "
142 -m, --manifest=FILE build the packages that the manifest given in FILE
143 evaluates to"))
144 (display (G_ "
140 -L, --load-path=DIR prepend DIR to the package module search path")) 145 -L, --load-path=DIR prepend DIR to the package module search path"))
141 (newline) 146 (newline)
142 (display (G_ " 147 (display (G_ "
@@ -198,6 +203,9 @@ run the checkers on all packages.\n"))
198 (option '(#\e "expression") #t #f 203 (option '(#\e "expression") #t #f
199 (lambda (opt name arg result) 204 (lambda (opt name arg result)
200 (alist-cons 'expression arg result))) 205 (alist-cons 'expression arg result)))
206 (option '(#\m "manifest") #t #f
207 (lambda (opt name arg result)
208 (alist-cons 'manifest arg result)))
201 209
202 (option '(#\V "version") #f #f 210 (option '(#\V "version") #f #f
203 (lambda args 211 (lambda args
@@ -219,16 +227,18 @@ run the checkers on all packages.\n"))
219 227
220 (let* ((opts (parse-options)) 228 (let* ((opts (parse-options))
221 (whole-file? (assoc-ref opts 'whole-file?)) 229 (whole-file? (assoc-ref opts 'whole-file?))
222 (args (filter-map (if whole-file? 230 (args (append-map (if whole-file?
223 (match-lambda 231 (match-lambda
224 (('argument . file) file) 232 (('argument . file) (list file))
225 (_ #f)) 233 (_ '()))
226 (match-lambda 234 (match-lambda
227 (('argument . spec) 235 (('argument . spec)
228 (specification->package spec)) 236 (list (specification->package spec)))
229 (('expression . exp) 237 (('expression . exp)
230 (read/eval-package-expression exp)) 238 (list (read/eval-package-expression exp)))
231 (_ #f))) 239 (('manifest . man)
240 (packages-from-manifest man))
241 (_ '())))
232 (reverse opts))) 242 (reverse opts)))
233 (no-checkers (or (assoc-ref opts 'exclude) '())) 243 (no-checkers (or (assoc-ref opts 'exclude) '()))
234 (the-checkers (filter (lambda (checker) 244 (the-checkers (filter (lambda (checker)
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 60fba71c3ef..4b0044d0ea2 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -52,7 +52,8 @@
52 #:use-module (srfi srfi-26) 52 #:use-module (srfi srfi-26)
53 #:use-module (srfi srfi-37) 53 #:use-module (srfi srfi-37)
54 #:use-module (srfi srfi-71) 54 #:use-module (srfi srfi-71)
55 #:export (guix-refresh)) 55 #:export (guix-refresh
56 packages-from-manifest))
56 57
57 58
58;;; 59;;;
diff --git a/tests/guix-lint.sh b/tests/guix-lint.sh
index 4a77315b3a2..2b36649a8b2 100644
--- a/tests/guix-lint.sh
+++ b/tests/guix-lint.sh
@@ -52,6 +52,10 @@ cat > "$module_dir/foo.scm"<<EOF
52 (name "bar"))) 52 (name "bar")))
53EOF 53EOF
54 54
55cat > "${module_dir}/foomanifest.scm"<<EOF
56(specifications->manifest '("dummy"))
57EOF
58
55GUIX_PACKAGE_PATH="$module_dir" 59GUIX_PACKAGE_PATH="$module_dir"
56export GUIX_PACKAGE_PATH 60export GUIX_PACKAGE_PATH
57 61
@@ -64,8 +68,8 @@ grep_warning ()
64# Issues with the dummy package: 68# Issues with the dummy package:
65# 1) the synopsis starts with the package name; 69# 1) the synopsis starts with the package name;
66# 2) the synopsis starts with a lower-case letter; 70# 2) the synopsis starts with a lower-case letter;
67# 3) the description has a single space following the end-of-sentence period; 71# 3) the description has a single space following the end-of-sentence period;
68# 4) the alphabetically lesser bar package succeeds it. 72# 4) the alphabetically lesser bar package succeeds it.
69 73
70out=`guix lint -c synopsis,description dummy 2>&1` 74out=`guix lint -c synopsis,description dummy 2>&1`
71test `grep_warning "$out"` -eq 3 75test `grep_warning "$out"` -eq 3
@@ -79,6 +83,10 @@ test `grep_warning "$out"` -eq 1
79out=`guix lint -c description,synopsis dummy 2>&1` 83out=`guix lint -c description,synopsis dummy 2>&1`
80test `grep_warning "$out"` -eq 3 84test `grep_warning "$out"` -eq 3
81 85
86# Test specifying a manifest.
87out=`guix lint -c synopsis,description -m ${module_dir}/foomanifest.scm 2>&1`
88test `grep_warning "$out"` -eq 3
89
82working_dir="$(pwd)" 90working_dir="$(pwd)"
83cd "$module_dir" 91cd "$module_dir"
84out=`guix lint -c name -f foo.scm 2>&1` 92out=`guix lint -c name -f foo.scm 2>&1`