From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <bug-guix-bounces+larch=yhetil.org@gnu.org>
Received: from mp10.migadu.com ([2001:41d0:8:6d80::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms5.migadu.com with LMTPS
	id SCb9DF8OnmIZ8wAAbAwnHQ
	(envelope-from <bug-guix-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 06 Jun 2022 16:25:35 +0200
Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp10.migadu.com with LMTPS
	id ABoHDF8OnmJLKQEAG6o9tA
	(envelope-from <bug-guix-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 06 Jun 2022 16:25:35 +0200
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by aspmx1.migadu.com (Postfix) with ESMTPS id A493E3D2C5
	for <larch@yhetil.org>; Mon,  6 Jun 2022 16:25:29 +0200 (CEST)
Received: from localhost ([::1]:45230 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-guix-bounces+larch=yhetil.org@gnu.org>)
	id 1nyDfU-0004ZT-TH
	for larch@yhetil.org; Mon, 06 Jun 2022 10:25:22 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:45618)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1nyDXS-0000XT-IO
 for bug-guix@gnu.org; Mon, 06 Jun 2022 10:17:03 -0400
Received: from debbugs.gnu.org ([209.51.188.43]:42514)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1nyDXS-0004pY-8q
 for bug-guix@gnu.org; Mon, 06 Jun 2022 10:17:02 -0400
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1nyDXS-0005H0-4U
 for bug-guix@gnu.org; Mon, 06 Jun 2022 10:17:02 -0400
X-Loop: help-debbugs@gnu.org
Subject: bug#55806: [PATCH] gnu: install: Add uvesafb service only on targets
 that support v86d.
Resent-From: Josselin Poiret <dev@jpoiret.xyz>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-guix@gnu.org
Resent-Date: Mon, 06 Jun 2022 14:17:02 +0000
Resent-Message-ID: <handler.55806.B55806.165452500219335@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 55806
X-GNU-PR-Package: guix
X-GNU-PR-Keywords: 
To: Josselin Poiret <dev@jpoiret.xyz>, Pavel Shlyak <p.shlyak@pantherx.org>,
 55806@debbugs.gnu.org
Received: via spool by 55806-submit@debbugs.gnu.org id=B55806.165452500219335
 (code B ref 55806); Mon, 06 Jun 2022 14:17:02 +0000
Received: (at 55806) by debbugs.gnu.org; 6 Jun 2022 14:16:42 +0000
Received: from localhost ([127.0.0.1]:36411 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1nyDX7-000516-GG
 for submit@debbugs.gnu.org; Mon, 06 Jun 2022 10:16:42 -0400
Received: from jpoiret.xyz ([206.189.101.64]:49790)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dev@jpoiret.xyz>) id 1nyDX4-0004yZ-VZ
 for 55806@debbugs.gnu.org; Mon, 06 Jun 2022 10:16:39 -0400
Received: from authenticated-user (jpoiret.xyz [206.189.101.64])
 by jpoiret.xyz (Postfix) with ESMTPA id 40D54183B27;
 Mon,  6 Jun 2022 14:16:37 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim;
 t=1654524997;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=7KCBIKOtt1kaqLN6g6MU/dhkkaGQKPGVNYeeoNwgGdc=;
 b=m8ZS/s/sNSQuBrEdnB9/D2hu3rO9FLZsPI6RtDXgEg8zYXeRNI65UEs6Aezp67KXNziZHe
 9ylbyZAosLec+cCnHl9tayFOQZQsvImgU88A9HI1sVhfqc010tlSsxT/2kkoi1oBqzzAEn
 MpwTMFn6jDGh0ov+Vg1bYevuKS4mI30Ig5Fby0zUbDg1UryZs91hxHiLag1HGfOHYUxAp+
 zj2iC6mNy4UzMolc/alFbJNZos9QRH5t4rYuXT/fqTOsgHb16XdKfLkTz5VV/DF79X8gR+
 k6f2i4z7g/hnUfWrb6c5u6fCunBlqSDVPvOYXnmcEQdPy0JRJKXoT5pGNDDfgA==
Date: Mon,  6 Jun 2022 16:16:34 +0200
Message-Id: <20220606141634.16295-1-dev@jpoiret.xyz>
In-Reply-To: <87czflx6o0.fsf@jpoiret.xyz>
References: <87czflx6o0.fsf@jpoiret.xyz>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spamd-Bar: /
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: bug-guix@gnu.org
List-Id: Bug reports for GNU Guix <bug-guix.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-guix>,
 <mailto:bug-guix-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-guix>
List-Post: <mailto:bug-guix@gnu.org>
List-Help: <mailto:bug-guix-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-guix>,
 <mailto:bug-guix-request@gnu.org?subject=subscribe>
Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org
Sender: "bug-Guix" <bug-guix-bounces+larch=yhetil.org@gnu.org>
Reply-to:  Josselin Poiret <dev@jpoiret.xyz>
From:  Josselin Poiret via Bug reports for GNU Guix <bug-guix@gnu.org>
X-Migadu-Flow: FLOW_IN
X-Migadu-To: larch@yhetil.org
X-Migadu-Country: US
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1654525529;
	h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:resent-cc:
	 resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to:
	 references:references:list-id:list-help:list-unsubscribe:
	 list-subscribe:list-post:dkim-signature;
	bh=7KCBIKOtt1kaqLN6g6MU/dhkkaGQKPGVNYeeoNwgGdc=;
	b=d/eccj9hkTeARffzpWLiqWtJE0MHoFX9igWLDjOd3yjTEKugfLuJyUp64jHSpjilM3rYvh
	4imCzH03Gy0uY5Gmcf+As0kNhxMcoKjaS1EwbjKL1yUeIV8//Gh0jY2ALiaNfelvQt62gx
	y/ZNWVJY/5Gk4a8b3IQgnPa/oxCFLeGqrlZkGsCJdEmI+sqZzYXbqRDb+efpMOSUg1+cmN
	zn0WVAjL88dA8MfQpmjv9rN98rfv2CDVeHV54PkPniL3k1zAfl2LkKjB1rhhvR48c9Fc+C
	MldOFhb6MkEwuznMjigfD2/vzskyL62eleBn1uwpdewNFLgNobbOgVnQviioFA==
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654525529; a=rsa-sha256; cv=none;
	b=G3Gt4z7UJaK9d7QWt7iIkJdBOY7UY/NH0vikIig6g8lz50bZjLSmGmNg5iTA87JfUpWi3T
	qJnFsQMqBv93/h1WjPRd274wwxXWhediFUk13R+c2/P+6j9jkJhdYMhaArSAaTAggUYSh3
	OcFyMc8f4ejewynic5Z+YClO5INotolO0SXQWK3UeBe++S0EDBOO715lDB2vKmW6KE2x+F
	qTAU72BNbyXFs+Ju6CZZ9wWTCZoSjB9c9DJC4VoHGr6oEurBXH/Vcd9RkDrl1Fhh73EldX
	Hk/qzatfvUkXKRM5DccZAoo4DYZm3ZBCRrVjfAVUZaw+Y3YvNJW9ki598Tr4jw==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b="m8ZS/s/s";
	dmarc=pass (policy=none) header.from=gnu.org;
	spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"
X-Migadu-Spam-Score: -2.61
Authentication-Results: aspmx1.migadu.com;
	dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b="m8ZS/s/s";
	dmarc=pass (policy=none) header.from=gnu.org;
	spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"
X-Migadu-Queue-Id: A493E3D2C5
X-Spam-Score: -2.61
X-Migadu-Scanner: scn0.migadu.com
X-TUID: 0DKJ/qFuDLZS

* gnu/system/install.scm (%installation-services): Refactor into a
procedure, so that it can capture the system it's installing for.
Conditionally add uvesafb-service-type based on whether v86d is
supported by the target architecture.
(installation-os)[services]: Use the %installation-service procedure.
---
 gnu/system/install.scm | 245 +++++++++++++++++++++--------------------
 1 file changed, 128 insertions(+), 117 deletions(-)

diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index e46c1d34dd..5e4215864e 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -31,8 +31,10 @@ (define-module (gnu system install)
   #:use-module (guix store)
   #:use-module (guix monads)
   #:use-module (guix modules)
-  #:use-module ((guix packages) #:select (package-version))
+  #:use-module ((guix packages) #:select (package-version supported-package?))
+  #:use-module (guix platform)
   #:use-module ((guix store) #:select (%store-prefix))
+  #:use-module (guix utils)
   #:use-module (gnu installer)
   #:use-module (gnu system locale)
   #:use-module (gnu services avahi)
@@ -305,7 +307,10 @@ (define uvesafb-service-type
     "Load the @code{uvesafb} kernel module with the right options.")
    (default-value #t)))
 
-(define %installation-services
+(define* (%installation-services #:key (system (or (and=>
+                                                    (%current-target-system)
+                                                    platform-target->system)
+                                                   (%current-system))))
   ;; List of services of the installation system.
   (let ((motd (plain-file "motd" "
 \x1b[1;37mWelcome to the installation of GNU Guix!\x1b[0m
@@ -322,120 +327,126 @@ (define (normal-tty tty)
     (define bare-bones-os
       (load "examples/bare-bones.tmpl"))
 
-    (list (service virtual-terminal-service-type)
-
-          (service kmscon-service-type
-                   (kmscon-configuration
-                    (virtual-terminal "tty1")
-                    (login-program (installer-program))))
-
-          (login-service (login-configuration
-                          (motd motd)))
-
-          ;; Documentation.  The manual is in UTF-8, but
-          ;; 'console-font-service' sets up Unicode support and loads a font
-          ;; with all the useful glyphs like em dash and quotation marks.
-          (service documentation-service-type "tty2")
-
-          ;; Documentation add-on.
-          %configuration-template-service
-
-          ;; A bunch of 'root' ttys.
-          (normal-tty "tty3")
-          (normal-tty "tty4")
-          (normal-tty "tty5")
-          (normal-tty "tty6")
-
-          ;; The usual services.
-          (syslog-service)
-
-          ;; Use the Avahi daemon to discover substitute servers on the local
-          ;; network.  It can be faster than fetching from remote servers.
-          (service avahi-service-type)
-
-          ;; The build daemon.  Register the default substitute server key(s)
-          ;; as trusted to allow the installation process to use substitutes by
-          ;; default.
-          (service guix-service-type
-                   (guix-configuration (authorize-key? #t)
-                                       (guix (current-guix))))
-
-          ;; Start udev so that useful device nodes are available.
-          ;; Use device-mapper rules for cryptsetup & co; enable the CRDA for
-          ;; regulations-compliant WiFi access.
-          (udev-service #:rules (list lvm2 crda))
-
-          ;; Add the 'cow-store' service, which users have to start manually
-          ;; since it takes the installation directory as an argument.
-          (cow-store-service)
-
-          ;; Install Unicode support and a suitable font.
-          (service console-font-service-type
-                   (map (match-lambda
-                          ("tty2"
-                           ;; Use a font that contains characters such as
-                           ;; curly quotes as found in the manual.
-                           '("tty2" . "LatGrkCyr-8x16"))
-                          (tty
-                           ;; Use a font that doesn't have more than 256
-                           ;; glyphs so that we can use colors with varying
-                           ;; brightness levels (see note in setfont(8)).
-                           `(,tty . "lat9u-16")))
-                        '("tty1" "tty2" "tty3" "tty4" "tty5" "tty6")))
-
-          ;; To facilitate copy/paste.
-          (service gpm-service-type)
-
-          ;; Add an SSH server to facilitate remote installs.
-          (service openssh-service-type
-                   (openssh-configuration
-                    (port-number 22)
-                    (permit-root-login #t)
-                    ;; The root account is passwordless, so make sure
-                    ;; a password is set before allowing logins.
-                    (allow-empty-passwords? #f)
-                    (password-authentication? #t)
-
-                    ;; Don't start it upfront.
-                    (%auto-start? #f)))
-
-          ;; Since this is running on a USB stick with a overlayfs as the root
-          ;; file system, use an appropriate cache configuration.
-          (nscd-service (nscd-configuration
-                         (caches %nscd-minimal-caches)))
-
-          ;; Having /bin/sh is a good idea.  In particular it allows Tramp
-          ;; connections to this system to work.
-          (service special-files-service-type
-                   `(("/bin/sh" ,(file-append bash "/bin/sh"))))
-
-          ;; Loopback device, needed by OpenSSH notably.
-          (service static-networking-service-type
-                   (list %loopback-static-networking))
-
-          (service wpa-supplicant-service-type)
-          (dbus-service)
-          (service connman-service-type
-                   (connman-configuration
-                    (disable-vpn? #t)))
-
-          ;; Keep a reference to BARE-BONES-OS to make sure it can be
-          ;; installed without downloading/building anything.  Also keep the
-          ;; things needed by 'profile-derivation' to minimize the amount of
-          ;; download.
-          (service gc-root-service-type
-                   (append
-                    (list bare-bones-os
-                          glibc-utf8-locales
-                          texinfo
-                          guile-3.0)
-                    %default-locale-libcs))
-
-          ;; Machines without Kernel Mode Setting (those with many old and
-          ;; current AMD GPUs, SiS GPUs, ...) need uvesafb to show the GUI
-          ;; installer.  Some may also need a kernel parameter like nomodeset
-          ;; or vga=793, but we leave that for the user to specify in GRUB.
-          (service uvesafb-service-type))))
+    (append
+     ;; Generic services
+     (list (service virtual-terminal-service-type)
+
+           (service kmscon-service-type
+                    (kmscon-configuration
+                     (virtual-terminal "tty1")
+                     (login-program (installer-program))))
+
+           (login-service (login-configuration
+                           (motd motd)))
+
+           ;; Documentation.  The manual is in UTF-8, but
+           ;; 'console-font-service' sets up Unicode support and loads a font
+           ;; with all the useful glyphs like em dash and quotation marks.
+           (service documentation-service-type "tty2")
+
+           ;; Documentation add-on.
+           %configuration-template-service
+
+           ;; A bunch of 'root' ttys.
+           (normal-tty "tty3")
+           (normal-tty "tty4")
+           (normal-tty "tty5")
+           (normal-tty "tty6")
+
+           ;; The usual services.
+           (syslog-service)
+
+           ;; Use the Avahi daemon to discover substitute servers on the local
+           ;; network.  It can be faster than fetching from remote servers.
+           (service avahi-service-type)
+
+           ;; The build daemon.  Register the default substitute server key(s)
+           ;; as trusted to allow the installation process to use substitutes by
+           ;; default.
+           (service guix-service-type
+                    (guix-configuration (authorize-key? #t)
+                                        (guix (current-guix))))
+
+           ;; Start udev so that useful device nodes are available.
+           ;; Use device-mapper rules for cryptsetup & co; enable the CRDA for
+           ;; regulations-compliant WiFi access.
+           (udev-service #:rules (list lvm2 crda))
+
+           ;; Add the 'cow-store' service, which users have to start manually
+           ;; since it takes the installation directory as an argument.
+           (cow-store-service)
+
+           ;; Install Unicode support and a suitable font.
+           (service console-font-service-type
+                    (map (match-lambda
+                           ("tty2"
+                            ;; Use a font that contains characters such as
+                            ;; curly quotes as found in the manual.
+                            '("tty2" . "LatGrkCyr-8x16"))
+                           (tty
+                            ;; Use a font that doesn't have more than 256
+                            ;; glyphs so that we can use colors with varying
+                            ;; brightness levels (see note in setfont(8)).
+                            `(,tty . "lat9u-16")))
+                         '("tty1" "tty2" "tty3" "tty4" "tty5" "tty6")))
+
+           ;; To facilitate copy/paste.
+           (service gpm-service-type)
+
+           ;; Add an SSH server to facilitate remote installs.
+           (service openssh-service-type
+                    (openssh-configuration
+                     (port-number 22)
+                     (permit-root-login #t)
+                     ;; The root account is passwordless, so make sure
+                     ;; a password is set before allowing logins.
+                     (allow-empty-passwords? #f)
+                     (password-authentication? #t)
+
+                     ;; Don't start it upfront.
+                     (%auto-start? #f)))
+
+           ;; Since this is running on a USB stick with a overlayfs as the root
+           ;; file system, use an appropriate cache configuration.
+           (nscd-service (nscd-configuration
+                          (caches %nscd-minimal-caches)))
+
+           ;; Having /bin/sh is a good idea.  In particular it allows Tramp
+           ;; connections to this system to work.
+           (service special-files-service-type
+                    `(("/bin/sh" ,(file-append bash "/bin/sh"))))
+
+           ;; Loopback device, needed by OpenSSH notably.
+           (service static-networking-service-type
+                    (list %loopback-static-networking))
+
+           (service wpa-supplicant-service-type)
+           (dbus-service)
+           (service connman-service-type
+                    (connman-configuration
+                     (disable-vpn? #t)))
+
+           ;; Keep a reference to BARE-BONES-OS to make sure it can be
+           ;; installed without downloading/building anything.  Also keep the
+           ;; things needed by 'profile-derivation' to minimize the amount of
+           ;; download.
+           (service gc-root-service-type
+                    (append
+                     (list bare-bones-os
+                           glibc-utf8-locales
+                           texinfo
+                           guile-3.0)
+                     %default-locale-libcs)))
+
+     ;; Specific system services
+
+     ;; Machines without Kernel Mode Setting (those with many old and
+     ;; current AMD GPUs, SiS GPUs, ...) need uvesafb to show the GUI
+     ;; installer.  Some may also need a kernel parameter like nomodeset
+     ;; or vga=793, but we leave that for the user to specify in GRUB.
+     `(,@(if (supported-package? v86d system)
+             (list (service uvesafb-service-type))
+             '())))))
 
 (define %issue
   ;; Greeting.
@@ -499,7 +510,7 @@ (define installation-os
                   (comment "Guest of GNU"))))
 
     (issue %issue)
-    (services %installation-services)
+    (services (%installation-services))
 
     ;; We don't need setuid programs, except for 'passwd', which can be handy
     ;; if one is to allow remote SSH login to the machine being installed.
-- 
2.36.1