Commit Graph

265 Commits

Author SHA1 Message Date
Ludovic Courtès 9296a2e511
processes: Allow 'less' to properly estimate line length.
Until now, the first few lines in the output of 'guix processes' could
disappear in 'less'.

* guix/ui.scm (call-with-paginated-output-port): Add #:less-options
parameter and honor it.
(with-paginated-output-port): Allow callers to pass #:less-options.
* guix/scripts/processes.scm (guix-processes): Pass #:less-options to
'with-paginated-output-port'.
2020-07-27 12:06:35 +02:00
Ludovic Courtès d51bfe242f
Use 'formatted-message' instead of '&message' where appropriate.
* gnu.scm (%try-use-modules): Use 'formatted-message' instead of
'&message'.
* gnu/machine/digital-ocean.scm (maybe-raise-unsupported-configuration-error):
Likewise.
* gnu/machine/ssh.scm (machine-check-file-system-availability): Likewise.
(machine-check-building-for-appropriate-system): Likewise.
(deploy-managed-host): Likewise.
(maybe-raise-unsupported-configuration-error): Likewise.
* gnu/packages.scm (search-patch): Likewise.
* gnu/services.scm (%service-with-default-value): Likewise.
(files->etc-directory): Likewise.
(fold-services): Likewise.
* gnu/system.scm (locale-name->definition*): Likewise.
* gnu/system/mapped-devices.scm (check-device-initrd-modules): Likewise.
(check-luks-device): Likewise.
* guix/channels.scm (latest-channel-instance): Likewise.
* guix/cve.scm (json->cve-items): Likewise.
* guix/git-authenticate.scm (commit-signing-key): Likewise.
(commit-authorized-keys): Likewise.
(authenticate-commit): Likewise.
(verify-introductory-commit): Likewise.
* guix/remote.scm (remote-pipe-for-gexp): Likewise.
* guix/scripts/graph.scm (assert-package): Likewise.
* guix/scripts/offload.scm (private-key-from-file*): Likewise.
* guix/ssh.scm (authenticate-server*): Likewise.
(open-ssh-session): Likewise.
(remote-inferior): Likewise.
* guix/ui.scm (matching-generations): Likewise.
* guix/upstream.scm (package-update): Likewise.
* tests/channels.scm ("latest-channel-instances, missing introduction for 'guix'"):
Catch 'formatted-message?'.
("authenticate-channel, wrong first commit signer"): Likewise.
* tests/lint.scm ("patches: not found"): Adjust message string.
* tests/packages.scm ("patch not found yields a run-time error"): Catch
'formatted-message?'.
* guix/lint.scm (check-patch-file-names): Handle 'formatted-message?'.
(check-derivation): Ditto.
2020-07-25 19:11:37 +02:00
Ludovic Courtès 252a1926bc
diagnostics: Add '&formatted-message'.
This allows 'gettext' to be called on the format string at the site
where the exception is caught (rather than the site where it's thrown).
It also allows for argument highlighting.

* guix/diagnostics.scm (&formatted-message): New condition type.
(check-format-string): New procedure.
(formatted-message): New macro.
* guix/ui.scm (report-load-error): Add clause for 'formatted-message?'.
(warn-about-load-error): Likewise.
(call-with-error-handling): Likewise.
(read/eval): Likewise.
2020-07-25 19:11:36 +02:00
Ludovic Courtès efe037fc5c
ui: Factorize '&message' handling.
* guix/ui.scm (call-with-error-handling): Factorize the three
'message-condition?' clauses into one.
2020-07-25 19:11:36 +02:00
Ludovic Courtès a168c3e4f8
ui: 'with-error-handling' does not unwind the stack.
Since a07d5e558b, we've been getting
useless backtraces upon unhandled errors, like this:

  Backtrace:
	     1 (primitive-load "/home/…/bin/guix")
  In guix/ui.scm:
    1953:12  0 (run-guix-command _ . _)

  guix/ui.scm:1953:12: In procedure run-guix-command:
  In procedure struct-vtable: Wrong type argument in position 1 (expecting struct): #f

This change finally gives us real backtraces back.

* guix/ui.scm (guard*): New macro.
(call-with-error-handling): Use it instead of 'guard'.
2020-07-15 01:36:24 +02:00
Ludovic Courtès 31522dfa19
Revert "ui: Use package-description-string."
This reverts commit bd03e99f66.

Reported by Ekaitz Zarraga <ekaitz@elenq.tech> at
<https://lists.gnu.org/archive/html/guix-devel/2020-06/msg00338.html>.

That commit broke would prevent "description: " from being taken into
account by the 'texi->plain-text' paragraph filling code.
2020-07-02 23:54:02 +02:00
Ludovic Courtès 1acc5e11be
processes: Write to $PAGER.
* guix/ui.scm (with-paginated-output-port): Export.
* guix/scripts/processes.scm (guix-processes): Use it instead of writing
directly to (current-output-port).
2020-06-28 23:26:53 +02:00
Arun Isaac bd03e99f66
ui: Use package-description-string.
* guix/ui.scm (package->recutils): Use package-description-string instead of
package-description and P_.
2020-06-15 23:31:56 +05:30
Arun Isaac a1da0904a6
ui: Do not translate package synopsis a second time.
* guix/ui.scm (package->recutils): package-synopsis-string already returns a
translated string. Do not attempt to translate it again.
2020-06-15 23:31:56 +05:30
Arun Isaac e70a884706
ui: Cut off search early if any regexp does not match.
* guix/ui.scm (relevance): When one of the regexps does not match, cut off
early and return 0. Do not try to match the remaining regexps.
2020-06-15 23:31:56 +05:30
Ludovic Courtès e66f243e92
ui: Set 'LESS' environment variable unconditionally.
Fixes <https://bugs.gnu.org/41811>.
Reported by Lars-Dominik Braun <lars@6xq.net>.

* guix/ui.scm (call-with-paginated-output-port): Remove (getenv "LESS")
call.
2020-06-14 15:34:38 +02:00
Ludovic Courtès c39693d760
ui: 'display-search-results' automatically invokes the pager.
* guix/ui.scm (call-with-paginated-output-port): New procedure.
(with-paginated-output-port): New macro.
(display-search-results): Use it instead of displaying a hint.
2020-06-06 23:28:49 +02:00
Vincent Legoll 694e10af63
ui: Fix typos, 80-col & grammar in comments & docstrings.
* guix/ui.scm (load*): Fix comment line length.
(leave-on-EPIPE): Fix typo in docstring.
(substitutable-info): Fix typo in comment.
(indented-string): Fix typo in docstring.
(%package-metrics): Fix typo in comment.
(run-guix): Fix grammar in docstring.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-04-17 23:18:32 +02:00
Ludovic Courtès 5c83dd1d64
ui: Clarify "dependencies changed".
Suggested by Leo Famulari <leo@famulari.name>.

* guix/ui.scm (show-manifest-transaction): Change to "dependencies or
package changed".
2020-04-02 11:48:24 +02:00
Ludovic Courtès 8465f1f680
ui: 'show-manifest-transaction' tabulates package lists for install/remove.
It also removes the store file name from the output.

* guix/ui.scm (show-manifest-transaction)[package-strings]: Rewrite to
use 'tabulate'.  Remove 'item' parameter and adjust callers.
2020-03-24 15:44:45 +01:00
Ludovic Courtès 3e5ab0a7a9
ui: 'show-manifest-transaction' tabulates upgraded package lists.
This also changes "1.0.0 → 1.0.0" to "(dependencies changed)", which is
probably less confusing.

* guix/ui.scm (tabulate): New procedure.
(show-manifest-transaction)[upgrade-string]: Rewrite to take lists of
names, versions, and outputs instead of single elements.  Use
'tabulate'.  Adjust callers accordingly.
2020-03-24 15:44:45 +01:00
Ludovic Courtès 7b322d3c4c
ui: Add 'indented-string'.
* guix/scripts/pull.scm (display-news-entry): Remove extra space in
format string for 'indented-string'.
(indented-string): Remove.
(display-new/upgraded-packages)[pretty]: Pass #:initial-indent? to
'indented-string'.
* guix/ui.scm (indented-string): New procedure.
2020-03-23 10:48:17 +01:00
Ludovic Courtès 9b771305df
ui: 'build-notifier' invokes continuation when there's nothing to do.
* guix/ui.scm (build-notifier): Call CONTINUE when there's nothing to
build or download, even when DRY-RUN? is true.
2020-03-22 12:42:52 +01:00
Ludovic Courtès 883a1765a6
ui: 'show-what-to-build' returns two values, for builds and downloads.
* guix/ui.scm (show-what-to-build): Return two values.
2020-03-22 12:42:52 +01:00
Ludovic Courtès bec3474107
ui: 'show-what-to-build' returns true when there are grafts to build.
* guix/ui.scm (show-what-to-build): Distinguish between 'build/full' and
'build'.  Return true whe 'build/full' is non-empty, thus taking grafts
into account.
2020-03-22 12:42:52 +01:00
Ludovic Courtès 07ce23e011
ui: Add a notification build handler.
* guix/ui.scm (build-notifier): New variable.
2020-03-22 12:42:51 +01:00
Ludovic Courtès 3c1ea8dcef
ui: Restore line wrapping for 'package->recutils'.
Fixes a regression introduced when switching to Guile 3.0.0 whereby
monkey-patching 'wrap*' wouldn't have any effects due to inlining.

* guix/ui.scm (%text-width): Define in terms of the '*line-width*' fluid
when it's defined.
<top level>: Set (@@ (texinfo plain-text) wrap*) only when
'*line-width*' is undefined.
2020-03-11 18:42:08 +01:00
Ludovic Courtès c2f9ea2b50
Revert "ui: Only display link in capable terminals."
This reverts commit d7545a6b53.

The commit led to a test failure in 'tests/guix-package-net.sh'.  It
also led to disagreements discussed here:

  https://lists.gnu.org/archive/html/guix-devel/2020-02/msg00353.html

Reverting until these are addressed.
2020-02-28 00:03:34 +01:00
Pierre Neidhardt 9b7f9e6f9b
ui: Don't truncate search output when inside Emacs.
* guix/ui.scm (display-search-results): Loop over all results when
  INSIDE_EMACS is set.
2020-02-24 11:01:52 +01:00
zimoun d7545a6b53
ui: Only display link in capable terminals.
* guix/ui.scm (display-generation): Display generation path on new line.
* guix/scripts/describe.scm (channel-commit-hyperlink): Add TRANSFORMER argument.
(display-profile-content): Use TRANSFORMER argument to display URL explicitly
when terminal does not support hyperlinks.
2020-02-24 11:01:52 +01:00
Ludovic Courtès fa99c4bbc7
ui: (size->number "1.M") is correctly parsed.
Reported by Pierre Neidhardt <mail@ambrevar.xyz>.

* guix/ui.scm (size->number)[unit-pos]: Add #\. to CHAR-SET:DIGIT.
* tests/ui.scm ("size->number, 1.M"): New test.
2020-02-23 12:47:13 +01:00
Ludovic Courtès a65ffbea50
ui: Fix typo in comment.
Reported by Vincent Legoll <vincent.legoll@gmail.com>.

* guix/ui.scm (call-with-error-handling): Remove "come" in comment.
2020-02-11 17:42:10 +01:00
Ludovic Courtès a07d5e558b
ui: Do not display error messages with bare format strings.
On Guile 3, with, say, an error in ~/.guile, we'd get:

  $ guix repl
  guix repl: error: Unbound variable: ~S

* guix/ui.scm (call-with-error-handling): Add
'&exception-with-kind-and-args' case.
2020-01-24 23:56:42 +01:00
Ludovic Courtès abbb98714b
ui: Ignore 'raise-exception' frames when reporting exceptions.
* guix/ui.scm (last-frame-with-source): Check whether FRAME corresponds
to 'raise-exception' and skip it if it does.
2020-01-17 17:11:34 +01:00
Ludovic Courtès 47212fc763
records: Improve reporting of "invalid field specifier" errors.
Previously users would just see:

  error: invalid field specifier

without source location or hints.

* guix/records.scm (expand): Add optional 'parent-form' parameter and
pass it to 'syntax-violation' when it is true.
(make-syntactic-constructor): Pass S as a third argument to
'report-invalid-field-specifier'.
* guix/ui.scm (report-load-error): For 'syntax-error', show SUBFORM or
FORM in the message.
* tests/records.scm ("define-record-type* & wrong field specifier"): Add
a 'subform' parameter and adjust test accordingly.
("define-record-type* & wrong field specifier, identifier"): New test.
* tests/guix-system.sh: Add test.
2020-01-16 18:30:57 +01:00
Ludovic Courtès 5a2639f9cb
Avoid warnings for the 'delete' binding of (guix build utils).
On Guile 3, importing (guix build utils) leads to warnings such as:

  WARNING: (gnu packages embedded): imported module (guix build utils) overrides core binding `delete'

* gnu/packages/embedded.scm: Select 'alist-replace' from (guix build utils).
* guix/ui.scm: Hide 'delete' from (guix build utils).
2020-01-15 18:40:43 +01:00
Ludovic Courtès 09edf136ef
ui: It's 2020 now!
* guix/ui.scm (show-version-and-exit): Change year to 2020.
2020-01-02 19:42:59 +01:00
Ludovic Courtès 3f8e890d91
ui: 'with-profile-lock' keeps going upon ENOLCK.
* guix/build/syscalls.scm (call-with-file-lock/no-wait): Really pass
ARGS to HANDLER.  Return #f when HANDLER is called.
* guix/ui.scm (profile-lock-handler): Emit a mere warning upon ENOLCK.
2019-11-29 15:54:20 +01:00
Ludovic Courtès 55e1dfa4dd
ui: Factorize 'with-profile-lock'.
* guix/ui.scm (profile-lock-handler, profile-lock-file): New
procedures.
(with-profile-lock): New macro.
* guix/scripts/package.scm (process-actions): Use 'with-profile-lock'
instead of 'with-file-lock/no-wait'.
* guix/scripts/pull.scm (guix-pull): Likewise.
2019-11-29 15:54:20 +01:00
Ludovic Courtès 2d6bd5edbc
pull, describe: Emit hyperlinks for commit identifiers.
* guix/scripts/pull.scm (%vcs-web-views): New variable.
(channel-commit-hyperlink): New procedure.
(display-news-entry): Add 'channel' parameter.  When
'supports-hyperlinks?' returns true, call 'channel-commit-hyperlink'.
(display-profile-content): Likewise, and define CHANNEL.
(display-channel-specific-news): Pass CHANNEL to 'display-news-entry'.
* guix/ui.scm (hyperlink): Make public.
2019-11-28 18:43:54 +01:00
Ludovic Courtès 055f052574
ui: 'display-generation' emits a hyperlink for the generation.
* guix/ui.scm (supports-hyperlinks?): Make 'port' optional.
(display-generation): Use 'file-hyperlink' for the heading when
'supports-hyperlinks?' returns true.
2019-11-28 13:30:53 +01:00
Ludovic Courtès fa983b8257
ui: Add 'file-hyperlink'.
* guix/ui.scm (file-hyperlink): New procedure.
(location->hyperlink): Use it.
2019-11-28 13:30:53 +01:00
Ludovic Courtès 7f3bbfaf8e
ui: Adjust SRFI-34 exception handling to Guile 2.9.5.
* guix/ui.scm (report-load-error, warn-about-load-error)
(read/eval): Match (or 'srfi-34 '%exception) instead of just 'srfi-34 to
match what Guile 2.9.5 does.
2019-11-27 00:03:03 +01:00
Ludovic Courtès edd25a8cac
ui: Emit hyperlinks for 'license' in package search results.
* guix/ui.scm (package->recutils): When HYPERLINKS is true, call
'hyperlink' for the 'license' field.
2019-11-09 00:36:10 +01:00
Ludovic Courtès 7f0f38b54c
ui: Produce hyperlinks for the 'location' field of search results.
This affects the output of 'guix show', 'guix search', and 'guix system
search'.

* guix/ui.scm (hyperlink, supports-hyperlinks?, location->hyperlink):
New procedures.
(package->recutils): Add #:hyperlinks? and honor it.
(display-search-results): Pass #:hyperlinks? to PRINT.
* guix/scripts/system/search.scm (service-type->recutils): Add
 #:hyperlinks? and honor it.
2019-11-09 00:36:10 +01:00
Ludovic Courtès 8b4615ab54
ui: 'show-what-to-build' colorizes store file names.
* guix/ui.scm (colorize-store-file-name): New procedure.
(show-what-to-build)[colorize-store-item]: New variable.
Use it throughout.
2019-10-01 10:50:24 +02:00
Ludovic Courtès a725504a3a
ui: Add 'current-message-language'.
* guix/ui.scm (%default-message-language): New variable.
(current-message-language): New procedure.
2019-09-23 10:38:44 +02:00
zimoun d2cdef6560
ui: 'relevance' connects regexps with a logical and.
Fixes <https://bugs.gnu.org/36763>.
Previously, the logical and connecting the regexps did not output the expected
results (introduced in 8874faaaac).

* guix/ui.scm (relevance)
[score]: Change its arguments.
[regexp->score]: New procedure.
* tests/ui.scm ("package-relevance"): Add test.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2019-09-19 23:24:04 +02:00
Ludovic Courtès 723bdb8ef0
ui: 'warn-about-load-error' provides hints for unbound variables.
* guix/ui.scm (warn-about-load-error): Add 'unbound-variable' clause.
* tests/guix-build.sh: Add test.
2019-07-20 01:32:17 +02:00
Ludovic Courtès a2a94b6e58
ui: 'warn-about-load-error' warns about file/module name mismatches.
* guix/discovery.scm (scheme-modules): Rename the inner 'file' to
'relative'.  Pass FILE as an addition argument to WARN.
* guix/ui.scm (warn-about-load-error): Add 'module' argument (actually,
what was called 'file' really contained a module name.)  Call
'check-module-matches-file' in the catch-all error case.
(check-module-matches-file): New procedure.
* tests/guix-build.sh: Test it.
2019-07-20 01:32:17 +02:00
Ludovic Courtès 5c3d44303e
guix gc: Correctly handle '--delete-generations' with no arguments.
Previously, 'guix gc --delete-generations' would crash: the "" pattern
would be passed to 'matching-generations', which would return #f instead
of returning a list.

Reported by Raghav Gururajan <rvgn@disroot.org>
in <https://bugs.gnu.org/36466>.

* guix/ui.scm (matching-generations): Raise an error when passed an
invalid pattern.
* guix/scripts/gc.scm (delete-old-generations): Check if PATTERN is
true.
(%options): Leave ARG as-is for 'delete-generations'.
(guix-gc): Use 'assq' instead of 'assoc-ref' for 'delete-generations'.
* guix/scripts/package.scm (delete-matching-generations):
Replace (string-null? pattern) with (not pattern).  Remove 'else'
clause.
(%options): Leave ARG as-is for 'delete-generations'.
* guix/scripts/pull.scm (%options): Leave ARG as-is for
'list-generations'.
(process-query): Replace (string-null? pattern) with (not pattern).
* guix/scripts/system.scm (list-generations): Likewise, and remove
'else' clause.
(process-command): Use #f instead of "" when no pattern is given.
2019-07-11 23:13:26 +02:00
Ludovic Courtès d74392a85c
derivations: Simplify 'substitution-oracle'.
* guix/derivations.scm (substitution-oracle)[valid?, dependencies]:
Remove.
[closure]: New procedure.
Rename parameter from 'drv' to 'inputs-or-drv' and adjust accordingly.
(derivation-build-plan): Pass INPUTS directly to 'substitution-oracle'.
* guix/ui.scm (show-what-to-build)[substitutable-info]: Likewise.
2019-07-05 00:51:17 +02:00
Ludovic Courtès b1510fd8d2
derivations: 'derivation-build-plan' recurses on substituables.
This fixes a bug whereby "guix build texlive -n" would report:

  0.0 MB would be downloaded:
     /gnu/store/…-texlive-20180414

instead of:

  The following derivation would be built:
     /gnu/store/…-texlive-texmf-20180414.drv
  2,595.2 MB would be downloaded:
     /gnu/store/…-texlive-20180414-texmf.tar.xz
     /gnu/store/…-texlive-20180414

where 'texlive-texmf' is a non-substitutable dependency of 'texlive'.

* guix/derivations.scm (dependencies-of-substitutables): New procedure.
(derivation-build-plan): When 'input-substitutable-info' returns true,
append the subset of DEPS that corresponds to SUBSTITUABLES to the first
argument of 'loop'.
* guix/ui.scm (show-what-to-build): Remove half-baked traversal of
DOWNLOAD.
* tests/derivations.scm ("derivation-build-plan and substitutes,
non-substitutable dep"): New test.
2019-07-05 00:51:17 +02:00
Ludovic Courtès 08c95ba28d
ui: 'show-derivation-outputs' accepts <derivation-input> records.
* guix/ui.scm (show-derivation-outputs): Handle <derivation-input>
records.
2019-06-27 11:14:42 +02:00
Ludovic Courtès d38d4ffa10
ui: 'show-what-to-build' accepts derivation inputs.
This is a followup to f8a9f99cd6.

* guix/ui.scm (show-what-to-build)[inputs]: New variables.
[substitutable-info]: Build the derivation list from INPUTS.
Pass INPUTS to 'derivation-build-plan'.
2019-06-27 11:14:42 +02:00