aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020, 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2021 Leo Famulari <leo@famulari.name>
;;;
;;; 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 (gnu installer newt services)
  #:use-module (gnu installer services)
  #:use-module (gnu installer steps)
  #:use-module (gnu installer newt page)
  #:use-module (gnu installer newt utils)
  #:use-module (guix i18n)
  #:use-module (guix utils)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-35)
  #:export (run-services-page))

(define (run-desktop-environments-cbt-page)
  "Run a page allowing the user to choose between various desktop
environments."
  (let ((items (filter desktop-system-service? (%system-services))))
    (run-checkbox-tree-page
     #:info-text (if (target-hurd?)
                     (G_ "Currently, none of these is available for the Hurd.")
                     (G_ "Please select the desktop environment(s) you wish to \
install.  If you select multiple desktop environments here, you will be able \
to choose from them later when you log in."))
     #:title (G_ "Desktop environment")
     #:items items
     #:selection (map system-service-recommended? items)
     #:item->text system-service-name             ;no i18n for DE names
     #:checkbox-tree-height 9
     #:exit-button-callback-procedure
     (lambda ()
       (abort-to-prompt 'installer-step 'abort)))))

(define (run-networking-cbt-page)
  "Run a page allowing the user to select networking services."
  (let ((items (filter (lambda (service)
                         (eq? 'networking (system-service-type service)))
                       (%system-services))))
    (run-checkbox-tree-page
     #:info-text (G_ "You can now select networking services to run on your \
system.")
     #:title (G_ "Network service")
     #:items items
     #:selection (map system-service-recommended? items)
     #:item->text (compose G_ system-service-name)
     #:checkbox-tree-height 5
     #:exit-button-callback-procedure
     (lambda ()
       (abort-to-prompt 'installer-step 'abort)))))

(define (run-printing-services-cbt-page)
  "Run a page allowing the user to select document services such as CUPS."
  (let ((items (filter (lambda (service)
                         (eq? 'document
                              (system-service-type service)))
                       (%system-services))))
    (run-checkbox-tree-page
     #:info-text (G_ "You can now select the CUPS printing service to run on your \
system.")
     #:title (G_ "Printing and document services")
     #:items items
     #:selection (map system-service-recommended? items)
     #:item->text (compose G_ system-service-name)
     #:checkbox-tree-height 9
     #:exit-button-callback-procedure
     (lambda ()
       (abort-to-prompt 'installer-step 'abort)))))

(define (run-console-services-cbt-page)
  "Run a page to select various system adminstration services for non-graphical
systems."
  (let ((items (filter (lambda (service)
                         (eq? 'administration
                              (system-service-type service)))
                       (%system-services))))
    (run-checkbox-tree-page
      #:title (G_ "Console services")
      #:info-text (G_ "Select miscellaneous services to run on your \
non-graphical system.")
      #:items items
      #:selection (map system-service-recommended? items)
      #:item->text (compose G_ system-service-name)
      #:checkbox-tree-height 5
      #:exit-button-callback-procedure
      (lambda _
        (abort-to-prompt 'installer-step 'abort)))))

(define (run-network-management-page)
  "Run a page to select among several network management methods."
  (let ((title (G_ "Network management"))
        (items (filter (lambda (service)
                         (eq? 'network-management
                              (system-service-type service)))
                       (%system-services))))
    (run-listbox-selection-page
     #:title title
     #:info-text (G_ "Choose the method to manage network connections.

We recommend NetworkManager or Connman for a WiFi-capable laptop; the DHCP \
client may be enough for a server.")
     #:info-textbox-width 70
     #:listbox-height 7
     #:listbox-items `(,@items
                       ,@(if (target-hurd?)
                             (list system-service-none)
                             '()))
     #:listbox-item->text (compose G_ system-service-name)
     #:sort-listbox-items? #f
     #:button-text (G_ "Exit")
     #:button-callback-procedure
     (lambda _
       (abort-to-prompt 'installer-step 'abort)))))

(define (run-services-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)
            (if (null? desktop)
                (cons (run-network-management-page)
                      (run-console-services-cbt-page))
                '())
            (run-printing-services-cbt-page))))
efully fail on | bash....* etc/guix-install.sh (welcome): Print an error message and a hint if the first read fails. Tobias Geerinckx-Rice 2022-12-09guix-install.sh: Authorize all project build farms at once....* etc/guix-install.sh (sys_authorize_build_farms): Iterate over all hosts. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Tobias Geerinckx-Rice 2022-11-16guix-install.sh: Expand mktemp template for busybox compatibility....Fixes <https://issues.guix.gnu.org/58858>. * etc/guix-install.sh (main): Use 6 'X' characters in the template, as this is the minimum required by Busybox's mktemp (which matches glibc's mktemp behavior). Reported-by: conses <contact@conses.eu> Maxim Cournoyer 2022-11-14guix-install.sh: Remove unnecessary XDG_DATA_DIRS export....This started out as a bug-fix for a GUI login loop that was resulting from XDG_DATA_DIRS not including any of the host distro's directories. The solution was to export the vari- able (with fail-safe defaults) before source-ing GUIX_PROFILE/etc/profile. It turns out changes have already been made to ensure that XDG_DATA_DIRS, etc. are always exported before anything guix-specific. So, this export is no longer necessary. For reference, the aforementioned bug was found on a Debian 11 machine and it's guix.sh init profile for guix version 1.2. * etc/guix-install.sh (sys_create_init_profile): Remove unnecessary XDG_DATA_DIRS export. Signed-off-by: 宋文武 <iyzsong@member.fsf.org> Prafulla Giri 2022-11-08guix-install.sh: Run guix.sh script in /etc/profile.d last....* etc/guix-install.sh: Rename /etc/profile.d/guix.sh to zzz-guix.sh. This script refers to environment variables set by the host distribution. They may be set in other scripts in /etc/profile.d, which must therefore be run first. Example: in Ubuntu 20.04, XDG_DATA_DIRS is set in /etc/profile.d/xdg_dirs_desktop_session.sh Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Konrad Hinsen 2022-10-16guix-install.sh: Cosmetically tweak non-interactive output....Avoid printing Press return to continue...[1666352494.051]: Starting installation… [1666352648.869]: … when the return itself wasn't echoed on the console. * etc/guix-install.sh (welcome): Add a carriage return to the prompt, so that the next line of output may overwrite it. Tobias Geerinckx-Rice 2022-10-16guix-install.sh: Warn if we suspect dodgy automation....This doesn't affect the installation (yet), but reserves the right to default to safe values other than ‘y’ in future. * etc/guix-install.sh (welcome): Warn if the ‘return’ wasn't. Tobias Geerinckx-Rice 2022-10-16guix-install.sh: Treat all uncaught errors as fatal....* etc/guix-install.sh: Set -o pipefail. Tobias Geerinckx-Rice 2022-10-16guix-install.sh: Suggest what to do if fetching OpenPGP key(s) fails....* etc/guix-install.sh (chk_gpg_keyring): Report an _err and set the exit_flag if wget | gpg --import fails. Tobias Geerinckx-Rice 2022-10-16guix-install.sh: Time out fetching OpenPGP keys....The default 900s provide no useful backstop in interactive use. * etc/guix-install.sh (chk_gpg_keyring): Add a 30s wget --timeout. Tobias Geerinckx-Rice 2022-10-11guix-install.sh: Restore compatibility with "yes" invocation....Commit 6a2e303d3a had modified prompt_yes_no to only read a single character, aiming to ease the user experience. This was, in retrospect, a bad idea, as it makes user input error more likely and introduces complexity. This commit reverts to line-oriented input, while preserving the default yes value so that a user can simply hit 'Enter' at the prompt in place of typing "yes". * etc/guix-install.sh (_flush): Delete function. (prompt_yes_no): Restore line-oriented read. Remove loop. Make anything else than yes means no. Use Bash features to streamline definition. Reported-by: Lars-Dominik Braun <lars@6xq.net> and others. Maxim Cournoyer 2022-10-07guix-install.sh: Add Bash prompt customization option....Fixes <https://issues.guix.gnu.org/55484>. * etc/guix-install.sh (sys_customize_bashrc): New function. (main): Use it. Maxim Cournoyer 2022-10-07guix-install.sh: Introduce 'die' utility function....* etc/guix-install.sh (die): New function. (chk_sys_arch): Use it. (guix_get_bin_list, guix_get_bin, sys_create_store): Likewise. Maxim Cournoyer 2022-10-07guix-install.sh: Improve prompt_yes_no procedure....* etc/guix-install.sh (_flush): New function. (prompt_yes_no): Clear input, then only read the first character, silently. Add the [Yes/no] string to the message. When a newline is entered by the user, treat it as the default value, which is "yes". (chk_gpg_keyring): Remove "(yes/no)" from the prompt message. (configure_substitute_discovery): Likewise. (sys_authorize_build_farms): Likewise. Maxim Cournoyer 2022-07-04etc/guix-install.sh: Check for profile from 'guix home'....If "$HOME/.guix-home/profile" exists, use it for GUIX_PROFILE instead of "$HOME/.guix-profile". * etc/guix-install.sh (sys_create_init_profile): Check for 'guix home' profile. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Philip McGrath 2022-07-04etc/guix-install.sh: Initialize XDG base directories....The default values from the XDG base directory specification make little sense for Guix System, and some scripts in Guix assume that they are not "empty or unset": for example, see <https://issues.guix.gnu.org/56050>. On foreign distros, however, omitting the default values is likely to break software from the distro, perhaps even preventing the desktop environment from starting. To smooth over the difference, use the system-wide configuration to ensure the environment variables are always explicitly set on foreign distros. * etc/guix-install.sh (sys_create_init_profile): Explicitly initialize XDG base directory variables. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Philip McGrath