diff --git a/doc/guix.texi b/doc/guix.texi index ddca6e5a1a79af7b3ac12c81bab1a78244ff1b0d..150747f4450c3106692025764fb40c05003a03d6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1903,6 +1903,13 @@ instead of offloading builds to remote machines. When the build or substitution process remains silent for more than @var{seconds}, terminate it and report a build failure. +@item --timeout=@var{seconds} +Likewise, when the build or substitution process lasts for more than +@var{seconds}, terminate it and report a build failure. + +By default there is no timeout. This behavior can be restored with +@code{--timeout=0}. + @item --verbosity=@var{level} Use the given verbosity level. @var{level} must be an integer between 0 and 5; higher means more verbose output. Setting a level of 4 or more diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 14b8f2d6bd08db2e80088ee2cb869184c8246225..618015e9ba0a123d0951c54b97be1a2f328e58af 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -126,6 +126,8 @@ (define (show-build-options-help) (display (_ " --max-silent-time=SECONDS mark the build as failed after SECONDS of silence")) + (display (_ " + --timeout=SECONDS mark the build as failed after SECONDS of activity")) (display (_ " --verbosity=LEVEL use the given verbosity LEVEL")) (display (_ " @@ -142,6 +144,7 @@ (define (set-build-options-from-command-line store opts) #:use-substitutes? (assoc-ref opts 'substitutes?) #:use-build-hook? (assoc-ref opts 'build-hook?) #:max-silent-time (assoc-ref opts 'max-silent-time) + #:timeout (assoc-ref opts 'timeout) #:verbosity (assoc-ref opts 'verbosity))) (define %standard-build-options @@ -175,6 +178,11 @@ (define %standard-build-options (alist-cons 'max-silent-time (string->number* arg) result) rest))) + (option '("timeout") #t #f + (lambda (opt name arg result . rest) + (apply values + (alist-cons 'timeout (string->number* arg) result) + rest))) (option '("verbosity") #t #f (lambda (opt name arg result . rest) (let ((level (string->number arg)))