From patchwork Mon Oct 21 08:17:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janneke Nieuwenhuizen X-Patchwork-Id: 32290 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 19A5627BBEA; Mon, 21 Oct 2024 09:18:48 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9DAF927BBE2 for ; Mon, 21 Oct 2024 09:18:46 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2ncg-0000Wl-OJ; Mon, 21 Oct 2024 04:18:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2ncf-0000VH-2H for guix-patches@gnu.org; Mon, 21 Oct 2024 04:18:41 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t2nce-0003bI-MY; Mon, 21 Oct 2024 04:18:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=UD0FCWC596sW0UY4a+ZDml1YISyYWhbrNqPqCxOOTZc=; b=d8zBQ38wcZ4CngG3gWCJBI6jbIjcfm/a6M7livNrJU/XEnC92rNpvSKIH8L7A7ix4Wx1AKJUwYuDd5JqH4tQjUnzT4T51ZLQm75LSvFp2bwN0crf129Ow2+j2ftTA8JZ57IxOvFzPIrZmBwixy6uSJbV/hnY+iAk4y7obLQIYTk1A8eTWGyXsMJktzYMIcZtwMQS2y0R3C4C6H/uDT8IepGWoHpFpNzqZts6n/r3L7eKdsoHViXfm+sg+b601woL+9fBS9cjyK8glUSm3584WWqvfdam6hqCdZqkZ21yiWeVHgLQaVg1tZXb6Jn7IqT2d6HHG4B6NCdJg53PSa0dkQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t2nd4-0003kL-Rh; Mon, 21 Oct 2024 04:19:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73927] [PATCH 16/16] DRAFT installer: Support dry-run from Guile via store. Resent-From: Janneke Nieuwenhuizen Original-Sender: "Debbugs-submit" Resent-CC: dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, guix-patches@gnu.org Resent-Date: Mon, 21 Oct 2024 08:19:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73927 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73927@debbugs.gnu.org Cc: Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe X-Debbugs-Original-Xcc: Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe Received: via spool by 73927-submit@debbugs.gnu.org id=B73927.172949870314280 (code B ref 73927); Mon, 21 Oct 2024 08:19:06 +0000 Received: (at 73927) by debbugs.gnu.org; 21 Oct 2024 08:18:23 +0000 Received: from localhost ([127.0.0.1]:50043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t2ncN-0003iE-4N for submit@debbugs.gnu.org; Mon, 21 Oct 2024 04:18:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t2ncB-0003gA-5n for 73927@debbugs.gnu.org; Mon, 21 Oct 2024 04:18:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2nbf-0003UF-Lb; Mon, 21 Oct 2024 04:17:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=UD0FCWC596sW0UY4a+ZDml1YISyYWhbrNqPqCxOOTZc=; b=jYl/1++HaL2ndP6wfaAs Bh3vqYFB6Zbz3CVsUofnu4iRFO+/nl99siAF7dYK238R1TOObuYWI+DeOhYyQXXFxrSJncYaabmht zBfWajI1eHiQHML25egl1h3I/HZElotEA9i4Dgtk2whhJPM3pbUJZMjoS+z+3f4rFD3hkcI/by3Kr PB4OePEyY0NLsZW8HZHtSknNdxnFCFQW1UN6+oGoqAy77PgaX+VL4XO1I7qTb3eAAY6UV8glCc8ia xyQwn/66BvtLcQ3fxJ0TkOvVcwCizEEP26iiqEo7jHDlumXxnGqwrZI9t94xicKdbn5Iu6IB8rXTh d0w9oZimvGkS0g==; From: Janneke Nieuwenhuizen Date: Mon, 21 Oct 2024 10:17:12 +0200 Message-ID: <623ba69960b842b24ec321b155ea722221c75ea8.1729494414.git.janneke@gnu.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This supports running the installer quasi-directly from Guile by only building a Guile installer-script in the store. Do something like: ./pre-inst-env guile -c '((@ (gnu installer) run-installer) #:dry-run? #t)' sudo -E ./pre-inst-env guile -c '((@ (gnu installer) run-installer))' * gnu/installer.scm (installer-script, run-installer): New procedures. Change-Id: I8cc1746845ec99f738e35fa91bb2342a674cfa88 --- gnu/installer.scm | 84 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/gnu/installer.scm b/gnu/installer.scm index 64f6273c55..617578665e 100644 --- a/gnu/installer.scm +++ b/gnu/installer.scm @@ -21,10 +21,14 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu installer) + #:use-module (guix build utils) + #:use-module (guix derivations) #:use-module (guix discovery) - #:use-module (guix packages) #:use-module (guix gexp) #:use-module (guix modules) + #:use-module (guix monads) + #:use-module (guix packages) + #:use-module (guix store) #:use-module (guix utils) #:use-module (guix ui) #:use-module ((guix self) #:select (make-config.scm)) @@ -56,7 +60,9 @@ (define-module (gnu installer) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (web uri) - #:export (installer-program)) + #:export (installer-program + installer-steps + run-installer)) (define module-to-import? ;; Return true for modules that should be imported. For (gnu system …) and @@ -562,3 +568,77 @@ (define* (installer-program #:key dry-run?) (execl #$(program-file "installer-real" installer-builder #:guile guile-3.0-latest) "installer-real")))) + +(define* (installer-script #:key dry-run? + (steps (installer-steps #:dry-run? dry-run?))) + (program-file + "installer-script" + #~(begin + (use-modules (gnu installer) + (gnu installer record) + (gnu installer keymap) + (gnu installer steps) + (gnu installer dump) + (gnu installer final) + (gnu installer hostname) + (gnu installer kernel) + (gnu installer locale) + (gnu installer parted) + (gnu installer services) + (gnu installer timezone) + (gnu installer user) + (gnu installer utils) + (gnu installer newt) + ((gnu installer newt keymap) + #:select (keyboard-layout->configuration)) + (gnu services herd) + (guix i18n) + (guix build utils) + (guix utils) + ((system repl debug) + #:select (terminal-width)) + (ice-9 match) + (ice-9 textual-ports)) + (terminal-width 200) + (let* ((current-installer newt-installer) + (steps (#$steps current-installer))) + (catch #t + (lambda _ + ((installer-init current-installer)) + (parameterize ((%run-command-in-installer + (if #$dry-run? + dry-run-command + (installer-run-command current-installer))) + (%installer-configuration-file + (if #$dry-run? + "config.scm" + (%installer-configuration-file)))) + (let ((results (run-installer-steps + #:rewind-strategy 'menu + #:menu-proc + (installer-menu-page current-installer) + #:steps steps + #:dry-run? #$dry-run?))) + (result-step results 'final)))) + (const #f) + (lambda (key . args) + (sleep 10) + ((installer-exit current-installer)) + (display-backtrace (make-stack #t) (current-error-port)) + (apply throw key args))))))) + +(define* (run-installer #:key dry-run?) + "To run the installer from Guile without building it: + ./pre-inst-env guile -c '((@ (gnu installer) run-installer) #:dry-run? #t)' +when using #:dry-run? #t, no root access is required and the LOCALE, KEYMAP, +and PARTITION pages are skipped." + (let* ((script (installer-script #:dry-run? dry-run?)) + (store (open-connection)) + (drv (run-with-store store + (lower-object script))) + (program (match (derivation->output-paths drv) + ((("out" . program)) program))) + (outputs (build-derivations store (list drv)))) + (close-connection store) + (format #t "running installer: ~a\n" program) + (invoke "./pre-inst-env" "guile" program)))