From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id kFawLBNoG2d/0QAAe85BDQ:P1 (envelope-from ) for ; Fri, 25 Oct 2024 09:42:43 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id kFawLBNoG2d/0QAAe85BDQ (envelope-from ) for ; Fri, 25 Oct 2024 11:42:43 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=JJxksrWN; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=OQehZTuT; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1729849363; a=rsa-sha256; cv=none; b=qPW8SWk6dp01JwcrnltqUNlbJeczW8yGfUOQLki98pXUmskC+lCtLpylIURIZZQOjAdF0Z Nw3oMJaz418jZFxO3h5yhC4hFOF5vscoDbxiw2UFjh0eLP/7IMmAtEUyxMfcrsA3rYEJcj rHL/Sd4Dj4CzFz6EwIa2gykQj1uMGlboEpjzg45cRtb4zaoHsv/ILIBMqytvay/FMCE9G+ zSn7e9tf4Wu/sfD7JtAcfzTZN0elkryrzK5BVQASWvHP70zChE+ZOfPm9EdkfClKSzWH2x 0ZwrEutS//m4wtrEtPZe0u8CeN+Z3U7QnD4lJwp8vuncwGg4ZI2UH2+M0Gd43g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=JJxksrWN; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=OQehZTuT; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1729849363; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: 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=+STQwkKh3SyvccoJDqQkts7U4WNa17HyCQ6CzqURmME=; b=ldnUw+87h3tsc/kxqy92BtDKYTvYqK8AWX3yLlcIICeklSGYYJGO5hTjfUMRiivjznwAMi 6AmkI+7MJLL8lwCSByTQNVJnyP1bRMs+5JwjlZctE4c3Cpb6C1pgJQIuFHwEfVTVZesSbx uWOsrCbEmfRzenzCGOMvJGnJYLYudTmzsxSve3Kl9BqQX0nnq6VOrGu841EY5MrOMrhL29 WIyFYnOVI3NOOi/ddhokJ35lTnJaFy1tD+Xnk4SgAtxzQBcK9yMIM78N78cD/DM6FXiZXb LNJcNztGXqyzAWYoYt7lwHAASQQOSCifgdXQ49G6NvycJT5mvYOwroag+QuQDA== 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 7C44D85684 for ; Fri, 25 Oct 2024 11:42:43 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4GpA-0002VQ-03; Fri, 25 Oct 2024 05:41:40 -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 1t4Gp8-0002UH-Uu for guix-patches@gnu.org; Fri, 25 Oct 2024 05:41:38 -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 1t4Gp8-0003uT-Fe for guix-patches@gnu.org; Fri, 25 Oct 2024 05:41:38 -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=+STQwkKh3SyvccoJDqQkts7U4WNa17HyCQ6CzqURmME=; b=JJxksrWNt+hd6DQdJvyE+TsALCGIymeeH9zE5Iiq2rcLRPovTYuagxZ228jkurKswi/2UA9pSsEGsxs5fMwwiSDqtpIuvec386a8HLnAkLnCGeGSRu+9uP6zpkf4vJJzciLAT3+qfKEA97fVsTYVOgPhbH7NhEP1D3eNR9qQGq7JZ8H+tyNeXz3iR80nj6vraZeIKGA0LeCqNR8piPY1YsTiquJY+qxYg/OM3PbTD1wGEYhL1yvwgIsP0PTDVDfLDK+mzp2sJtl1rXMF8VsOmIy6lP7fivKwMU4VnZhrNPxVZKOt5z67HXvqg9yTo9sw3WZkJOTOezKnRq28x+jmiw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t4Gpe-00027e-7T for guix-patches@gnu.org; Fri, 25 Oct 2024 05:42:10 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73927] [PATCH v3 17/17] installer: Support dry-run from Guile via store. Resent-From: Janneke Nieuwenhuizen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 25 Oct 2024 09:42:10 +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 Received: via spool by 73927-submit@debbugs.gnu.org id=B73927.17298492947978 (code B ref 73927); Fri, 25 Oct 2024 09:42:10 +0000 Received: (at 73927) by debbugs.gnu.org; 25 Oct 2024 09:41:34 +0000 Received: from localhost ([127.0.0.1]:37349 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4Gp3-00024X-DO for submit@debbugs.gnu.org; Fri, 25 Oct 2024 05:41:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36476) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4Gou-00022N-Je for 73927@debbugs.gnu.org; Fri, 25 Oct 2024 05:41:25 -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 1t4GoJ-0003pg-Gi; Fri, 25 Oct 2024 05:40:47 -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=+STQwkKh3SyvccoJDqQkts7U4WNa17HyCQ6CzqURmME=; b=OQehZTuTw7uxEuBS48+D nwHksk2R5cQodiWMNecm4VmGEXSe6c4wyv+roLPO0MN563lXS2gDCHWjC/26eQlOn50oqiXBIjbrp GTxZw2HbEhp3N/PTg5QJugtQBt92u4xAlvKYSavd5qcwoNqlRNWvSWF1QzstcPrf8rQxgcHW5o2Oh TrdO7CL8mJiVA7xfF9DeXWozHXqFB71YadS+EDFLLJb7lo/VA4PChPHj7GgKnw51wv/bN09lY+JIN ILc4fiQdBQgSZQyVRzQuoDx1ij1SGPdWu4rNxeUOZoI1NaBLJqjijJ2IEVm18o6hbGe2qC8xtgIAl 5UAbD6gHRC2ymA==; From: Janneke Nieuwenhuizen Date: Fri, 25 Oct 2024 11:40:09 +0200 Message-ID: <20241025094011.8540-18-janneke@gnu.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241025094011.8540-1-janneke@gnu.org> References: <20241025094011.8540-1-janneke@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.72 X-Spam-Score: -2.72 X-Migadu-Queue-Id: 7C44D85684 X-Migadu-Scanner: mx10.migadu.com X-TUID: mLG2K8QprXIn 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)' or and BE VERY CAREFUL WHEN NOT USING #:DRY-RUN #T! sudo -E ./pre-inst-env guile -c '((@ (gnu installer) run-installer))' for this to work, you also need connman. * 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 31c0ff7ff4..981687990a 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 action (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))) -- 2.46.0