From 75988317b22efee2b2719e7d559fa9ff01a9db9a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 7 Apr 2019 17:15:06 +0200 Subject: installer: Generalize desktop environments to system services. * gnu/installer/services.scm (): Rename to... (): ... this. Add a 'type' field. (%desktop-environments): Rename to... (%system-services): ... this. (desktop-system-service?): New procedure. (desktop-environments->configuration): Rename to... (system-services->configuration): ... this. Determine the base list of services based on whether SERVICES contains at least one "desktop" service. * gnu/installer/newt/services.scm (run-desktop-environments-cbt-page): Adjust accordingly. * gnu/installer.scm (installer-steps): Likewise. --- gnu/installer/services.scm | 87 +++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 36 deletions(-) (limited to 'gnu/installer/services.scm') diff --git a/gnu/installer/services.scm b/gnu/installer/services.scm index 2b6625f6af..8e482b7246 100644 --- a/gnu/installer/services.scm +++ b/gnu/installer/services.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Mathieu Othacehe +;;; Copyright © 2019 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,44 +19,58 @@ (define-module (gnu installer services) #:use-module (guix records) - #:export ( - desktop-environment - make-desktop-environment - desktop-environment-name - desktop-environment-snippet + #:use-module (srfi srfi-1) + #:export (system-service? + system-service-name + system-service-type + system-service-snippet - %desktop-environments - desktop-environments->configuration)) + desktop-system-service? -(define-record-type* - desktop-environment make-desktop-environment - desktop-environment? - (name desktop-environment-name) ;string - (snippet desktop-environment-snippet)) ;symbol + %system-services + system-services->configuration)) + +(define-record-type* + system-service make-system-service + system-service? + (name system-service-name) ;string + (type system-service-type) ;symbol + (snippet system-service-snippet)) ;sexp ;; This is the list of desktop environments supported as services. -(define %desktop-environments - (list - (desktop-environment - (name "GNOME") - (snippet '(service gnome-desktop-service-type))) - (desktop-environment - (name "Xfce") - ;; TODO: Use 'xfce-desktop-service-type' when the 'guix' package provides - ;; it with a default value. - (snippet '(xfce-desktop-service))) - (desktop-environment - (name "MATE") - (snippet '(service mate-desktop-service-type))) - (desktop-environment - (name "Enlightenment") - (snippet '(service enlightenment-desktop-service-type))))) +(define %system-services + (let-syntax ((desktop-environment (syntax-rules () + ((_ fields ...) + (system-service + (type 'desktop) + fields ...))))) + (list + (desktop-environment + (name "GNOME") + (snippet '(service gnome-desktop-service-type))) + (desktop-environment + (name "Xfce") + ;; TODO: Use 'xfce-desktop-service-type' when the 'guix' package provides + ;; it with a default value. + (snippet '(xfce-desktop-service))) + (desktop-environment + (name "MATE") + (snippet '(service mate-desktop-service-type))) + (desktop-environment + (name "Enlightenment") + (snippet '(service enlightenment-desktop-service-type)))))) + +(define (desktop-system-service? service) + "Return true if SERVICE is a desktop environment service." + (eq? 'desktop (system-service-type service))) -(define (desktop-environments->configuration desktop-environments) - "Return the configuration field for DESKTOP-ENVIRONMENTS." - (let ((snippets - (map desktop-environment-snippet desktop-environments))) - `(,@(if (null? snippets) - '() - `((services (cons* ,@snippets - %desktop-services))))))) +(define (system-services->configuration services) + "Return the configuration field for SERVICES." + (let* ((snippets (map system-service-snippet services)) + (desktop? (find desktop-system-service? services)) + (base (if desktop? + '%desktop-services + '%base-services))) + (if (null? snippets) + `((services ,base)) + `((services (cons* ,@snippets ,base)))))) -- cgit 1.4.1 From 7d1030a63592aa2f94f6617786f22cfa83fb346f Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 7 Apr 2019 18:02:39 +0200 Subject: installer: Add dialog to select networking services. * gnu/installer/newt/services.scm (run-networking-cbt-page): New procedure. (run-services-page): Call it. * gnu/installer/services.scm (%system-services): Add OpenSSH and Tor. (networking-system-service?): New procedure. * gnu/installer/steps.scm (format-configuration): Add 'networking' and 'ssh' to the service modules. --- gnu/installer/newt/services.scm | 19 ++++++++++++++++++- gnu/installer/services.scm | 19 +++++++++++++++++-- gnu/installer/steps.scm | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) (limited to 'gnu/installer/services.scm') diff --git a/gnu/installer/newt/services.scm b/gnu/installer/newt/services.scm index 2cbfc5ca36..e1faf4871d 100644 --- a/gnu/installer/newt/services.scm +++ b/gnu/installer/newt/services.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Mathieu Othacehe +;;; Copyright © 2019 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -44,5 +45,21 @@ choose the one to use on the log-in screen.") (condition (&installer-step-abort)))))) +(define (run-networking-cbt-page) + "Run a page allowing the user to select networking services." + (run-checkbox-tree-page + #:info-text (G_ "You can now select networking services to run on your +system.") + #:title (G_ "Network service") + #:items (filter networking-system-service? %system-services) + #:item->text system-service-name + #:checkbox-tree-height 5 + #:exit-button-callback-procedure + (lambda () + (raise + (condition + (&installer-step-abort)))))) + (define (run-services-page) - (run-desktop-environments-cbt-page)) + (append (run-desktop-environments-cbt-page) + (run-networking-cbt-page))) diff --git a/gnu/installer/services.scm b/gnu/installer/services.scm index 8e482b7246..cb1ddc8de8 100644 --- a/gnu/installer/services.scm +++ b/gnu/installer/services.scm @@ -26,6 +26,7 @@ system-service-snippet desktop-system-service? + networking-system-service? %system-services system-services->configuration)) @@ -34,7 +35,7 @@ system-service make-system-service system-service? (name system-service-name) ;string - (type system-service-type) ;symbol + (type system-service-type) ;'desktop | 'networking (snippet system-service-snippet)) ;sexp ;; This is the list of desktop environments supported as services. @@ -58,12 +59,26 @@ (snippet '(service mate-desktop-service-type))) (desktop-environment (name "Enlightenment") - (snippet '(service enlightenment-desktop-service-type)))))) + (snippet '(service enlightenment-desktop-service-type))) + + ;; Networking. + (system-service + (name "OpenSSH secure shell daemon (sshd)") + (type 'networking) + (snippet '(service openssh-service-type))) + (system-service + (name "Tor anonymous network router") + (type 'networking) + (snippet '(service tor-service-type)))))) (define (desktop-system-service? service) "Return true if SERVICE is a desktop environment service." (eq? 'desktop (system-service-type service))) +(define (networking-system-service? service) + "Return true if SERVICE is a desktop environment service." + (eq? 'networking (system-service-type service))) + (define (system-services->configuration services) "Return the configuration field for SERVICES." (let* ((snippets (map system-service-snippet services)) diff --git a/gnu/installer/steps.scm b/gnu/installer/steps.scm index 3f0bdad4f7..96cfdd03d1 100644 --- a/gnu/installer/steps.scm +++ b/gnu/installer/steps.scm @@ -215,7 +215,7 @@ found in RESULTS." '()))) steps)) (modules '((use-modules (gnu)) - (use-service-modules desktop)))) + (use-service-modules desktop networking ssh)))) `(,@modules () (operating-system ,@configuration)))) -- cgit 1.4.1 From 2e55f37c0c8fdfbc413edff61490161648a78dcc Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 7 Apr 2019 21:20:10 +0200 Subject: installer: Offer NM, Connman, and DHCP to non-desktop installs. * gnu/installer/services.scm (%system-services): Add NetworkManager, Connman, and the DHCP client. * gnu/installer/newt/services.scm (run-networking-cbt-page): Add 'network-management?' parameter and honor it. (run-services-page): Adjust call accordingly. --- gnu/installer/newt/services.scm | 22 ++++++++++++++++------ gnu/installer/services.scm | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 7 deletions(-) (limited to 'gnu/installer/services.scm') diff --git a/gnu/installer/newt/services.scm b/gnu/installer/newt/services.scm index e1faf4871d..76db31d9ab 100644 --- a/gnu/installer/newt/services.scm +++ b/gnu/installer/newt/services.scm @@ -45,13 +45,20 @@ choose the one to use on the log-in screen.") (condition (&installer-step-abort)))))) -(define (run-networking-cbt-page) - "Run a page allowing the user to select networking services." +(define (run-networking-cbt-page network-management?) + "Run a page allowing the user to select networking services. When +NETWORK-MANAGEMENT? is true, include network management services like +NetworkManager." (run-checkbox-tree-page - #:info-text (G_ "You can now select networking services to run on your + #:info-text (G_ "You can now select networking services to run on your \ system.") #:title (G_ "Network service") - #:items (filter networking-system-service? %system-services) + #:items (filter (let ((types (if network-management? + '(network-management networking) + '(networking)))) + (lambda (service) + (memq (system-service-type service) types))) + %system-services) #:item->text system-service-name #:checkbox-tree-height 5 #:exit-button-callback-procedure @@ -61,5 +68,8 @@ system.") (&installer-step-abort)))))) (define (run-services-page) - (append (run-desktop-environments-cbt-page) - (run-networking-cbt-page))) + (let ((desktop (run-desktop-environments-cbt-page))) + ;; When the user did not select any desktop services, and thus didn't get + ;; '%desktop-services', offer network management services. + (append desktop + (run-networking-cbt-page (null? desktop))))) diff --git a/gnu/installer/services.scm b/gnu/installer/services.scm index cb1ddc8de8..b79c2dfdc9 100644 --- a/gnu/installer/services.scm +++ b/gnu/installer/services.scm @@ -69,7 +69,21 @@ (system-service (name "Tor anonymous network router") (type 'networking) - (snippet '(service tor-service-type)))))) + (snippet '(service tor-service-type))) + + ;; Network connectivity management. + (system-service + (name "NetworkManager network connection manager") + (type 'network-management) + (snippet '(service network-manager-service-type))) + (system-service + (name "Connman network connection manager") + (type 'network-management) + (snippet '(service connman-service-type))) + (system-service + (name "DHCP client") + (type 'network-management) + (snippet '(service dhcp-client-service)))))) (define (desktop-system-service? service) "Return true if SERVICE is a desktop environment service." -- cgit 1.4.1 From 62b0f044f14569ffcaeb7a068e879a9422fdecbd Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 7 Apr 2019 21:41:51 +0200 Subject: installer: Internationalize service "names". * gnu/installer/services.scm (%system-services): Mark networking service names with 'G_'. * gnu/installer/newt/services.scm (run-networking-cbt-page): Pass 'system-service-name' through 'G_'. --- gnu/installer/newt/services.scm | 4 ++-- gnu/installer/services.scm | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'gnu/installer/services.scm') diff --git a/gnu/installer/newt/services.scm b/gnu/installer/newt/services.scm index 76db31d9ab..10c19115ca 100644 --- a/gnu/installer/newt/services.scm +++ b/gnu/installer/newt/services.scm @@ -37,7 +37,7 @@ install. If you select multiple desktops environments, you will be able to \ choose the one to use on the log-in screen.") #:title (G_ "Desktop environment") #:items (filter desktop-system-service? %system-services) - #:item->text system-service-name + #:item->text system-service-name ;no i18n for DE names #:checkbox-tree-height 5 #:exit-button-callback-procedure (lambda () @@ -59,7 +59,7 @@ system.") (lambda (service) (memq (system-service-type service) types))) %system-services) - #:item->text system-service-name + #:item->text (compose G_ system-service-name) #:checkbox-tree-height 5 #:exit-button-callback-procedure (lambda () diff --git a/gnu/installer/services.scm b/gnu/installer/services.scm index b79c2dfdc9..46ade0f8fa 100644 --- a/gnu/installer/services.scm +++ b/gnu/installer/services.scm @@ -44,7 +44,9 @@ ((_ fields ...) (system-service (type 'desktop) - fields ...))))) + fields ...)))) + (G_ (syntax-rules () ;for xgettext + ((_ str) str)))) (list (desktop-environment (name "GNOME") @@ -63,25 +65,25 @@ ;; Networking. (system-service - (name "OpenSSH secure shell daemon (sshd)") + (name (G_ "OpenSSH secure shell daemon (sshd)")) (type 'networking) (snippet '(service openssh-service-type))) (system-service - (name "Tor anonymous network router") + (name (G_ "Tor anonymous network router")) (type 'networking) (snippet '(service tor-service-type))) ;; Network connectivity management. (system-service - (name "NetworkManager network connection manager") + (name (G_ "NetworkManager network connection manager")) (type 'network-management) (snippet '(service network-manager-service-type))) (system-service - (name "Connman network connection manager") + (name (G_ "Connman network connection manager")) (type 'network-management) (snippet '(service connman-service-type))) (system-service - (name "DHCP client") + (name (G_ "DHCP client (dynamic IP address assignment)")) (type 'network-management) (snippet '(service dhcp-client-service)))))) -- cgit 1.4.1