summaryrefslogtreecommitdiff
path: root/guix/scripts/system
diff options
context:
space:
mode:
Diffstat (limited to 'guix/scripts/system')
-rw-r--r--guix/scripts/system/edit.scm64
-rw-r--r--guix/scripts/system/reconfigure.scm8
-rw-r--r--guix/scripts/system/search.scm40
3 files changed, 97 insertions, 15 deletions
diff --git a/guix/scripts/system/edit.scm b/guix/scripts/system/edit.scm
new file mode 100644
index 0000000000..d966ee0aaa
--- /dev/null
+++ b/guix/scripts/system/edit.scm
@@ -0,0 +1,64 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix scripts system edit)
+ #:use-module (guix diagnostics)
+ #:use-module (guix i18n)
+ #:use-module (guix ui)
+ #:autoload (guix utils) (string-closest)
+ #:use-module (gnu services)
+ #:use-module (srfi srfi-1)
+ #:use-module (ice-9 match)
+ #:autoload (guix scripts edit) (spawn-editor)
+ #:export (guix-system-edit))
+
+(define (service-type-not-found type)
+ "Report an error about @var{type} not being found and exit."
+ (report-error (G_ "~a: no such service type~%") type)
+
+ (let* ((type (symbol->string type))
+ (available (fold-service-types (lambda (type lst)
+ (cons (symbol->string
+ (service-type-name type))
+ lst))
+ '()))
+ (closest (string-closest type available)))
+ (unless (or (not closest) (string=? closest type))
+ (display-hint (format #f (G_ "Did you mean @code{~a}?~%")
+ closest))))
+
+ (exit 1))
+
+
+(define (guix-system-edit . args)
+ (when (null? args)
+ (leave (G_ "no service types specified, nothing to edit~%")))
+
+ (let* ((types (append-map (lambda (type)
+ (let ((type (string->symbol type)))
+ (match (lookup-service-types type)
+ (() (service-type-not-found type))
+ ((one) (list one))
+ (lst
+ (warning (N_ "~a: ~a matching service type~%"
+ "~a: ~a matching service types~%"
+ (length lst))
+ type (length lst))
+ lst))))
+ args)))
+ (spawn-editor (filter-map service-type-location types))))
diff --git a/guix/scripts/system/reconfigure.scm b/guix/scripts/system/reconfigure.scm
index bf23fb06af..9ca66687ee 100644
--- a/guix/scripts/system/reconfigure.scm
+++ b/guix/scripts/system/reconfigure.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
;;; Copyright © 2016, 2017, 2018 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
@@ -134,6 +134,7 @@ return the <live-service> objects that are currently running on MACHINE."
(map (lambda (service)
(list (live-service-provision service)
(live-service-requirement service)
+ (live-service-transient? service)
(match (live-service-running service)
(#f #f)
(#t #t)
@@ -143,8 +144,9 @@ return the <live-service> objects that are currently running on MACHINE."
(mlet %store-monad ((services (eval exp)))
(return (map (match-lambda
- ((provision requirement running)
- (live-service provision requirement running)))
+ ((provision requirement transient? running)
+ (live-service provision requirement
+ transient? running)))
services))))
;; XXX: Currently, this does NOT attempt to restart running services. See
diff --git a/guix/scripts/system/search.scm b/guix/scripts/system/search.scm
index bf49ea2341..44f00194cd 100644
--- a/guix/scripts/system/search.scm
+++ b/guix/scripts/system/search.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017-2019, 2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
;;;
;;; This file is part of GNU Guix.
@@ -20,6 +20,8 @@
(define-module (guix scripts system search)
#:use-module (guix ui)
#:use-module (guix utils)
+ #:autoload (guix colors) (color-output? highlight supports-hyperlinks?)
+ #:autoload (guix diagnostics) (location->hyperlink)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:use-module (srfi srfi-1)
@@ -68,10 +70,15 @@ provided TYPE has a default value."
#:optional (width (%text-width))
#:key
(extra-fields '())
- (hyperlinks? (supports-hyperlinks? port)))
+ (hyperlinks? (supports-hyperlinks? port))
+ (highlighting identity))
"Write to PORT a recutils record of TYPE, arranging to fit within WIDTH
columns. When HYPERLINKS? is true, emit hyperlink escape sequences when
-appropriate."
+appropriate. Pass the description through HIGHLIGHTING, a one-argument
+procedure that may return a colorized version of its argument."
+ (define port*
+ (or (pager-wrapped-port port) port))
+
(define width*
;; The available number of columns once we've taken into account space for
;; the initial "+ " prefix.
@@ -85,8 +92,15 @@ appropriate."
(fill-paragraph list width*
(string-length "extends: ")))))
+ (define highlighting*
+ (if (color-output? port*)
+ highlighting
+ identity))
+
;; Note: Don't i18n field names so that people can post-process it.
- (format port "name: ~a~%" (service-type-name type))
+ (format port "name: ~a~%"
+ (highlight (symbol->string (service-type-name type))
+ port*))
(format port "location: ~a~%"
(or (and=> (service-type-location type)
(if hyperlinks? location->hyperlink location->string))
@@ -107,14 +121,15 @@ appropriate."
(when (service-type-description type)
(format port "~a~%"
- (string->recutils
- (string-trim-right
- (parameterize ((%text-width width*))
- (texi->plain-text
- (string-append "description: "
- (or (and=> (service-type-description type) P_)
- ""))))
- #\newline))))
+ (highlighting*
+ (string->recutils
+ (string-trim-right
+ (parameterize ((%text-width width*))
+ (texi->plain-text
+ (string-append "description: "
+ (or (and=> (service-type-description type) P_)
+ ""))))
+ #\newline)))))
(for-each (match-lambda
((field . value)
@@ -174,4 +189,5 @@ description matches REGEXPS sorted by relevance, and their score."
(leave-on-EPIPE
(display-search-results matches (current-output-port)
#:print service-type->recutils
+ #:regexps regexps
#:command "guix system search")))))