From patchwork Fri Apr 18 02:26:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 41753 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 62D7027BC4B; Fri, 18 Apr 2025 03:28:38 +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=-4.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham 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 7143C27BC49 for ; Fri, 18 Apr 2025 03:28:36 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u5bSk-0000Gl-EP; Thu, 17 Apr 2025 22:28:18 -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 1u5bSj-0000Ga-NG for guix-patches@gnu.org; Thu, 17 Apr 2025 22:28:17 -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 1u5bSh-0003So-O0; Thu, 17 Apr 2025 22:28:15 -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:Date:From:To:Subject; bh=pv9V4x0i8yj/8uFw8lr6M7BIR7OXPuXm9SqHtJ55Ngk=; b=X2Y+WkVZVmmXuvm4rnBjEitvDgMlqOZL7hhKO2q2cv2dqnIv/Mx/ip8w9RceE4A3hPak2AZUcN/Y5m8cp4QAg2Pvc31Db3xFDGYvRD/+tS4JRu3IYG4enXSpX3LZzYg5BxXtvcs1LjGAcrZP56jtc0Wy5cD6Xz6eXbUFDqWDfQjO9NGnAbOLeu40S7dTHL3vG5G+YswQy+R0zGPdk51qJXhppBbva0PINdeQmVyWkE6e3ZzylPCVpUQy0T2mSUlFtwGcihpYEYljpBuB2WynJy4cvx+4OclsfSVbP8RSEVUzUx6MwGpadAJ/mItBlADL79W0AU9qYnmPPHaaUSBgvQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u5bSb-0006iR-MH; Thu, 17 Apr 2025 22:28:09 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77882] [PATCH] scripts: home: Support extracting home-environment from Guix System declaration. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: andrew@trop.in, guix@cbaines.net, hako@ultrarare.space, janneke@gnu.org, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, maxim.cournoyer@gmail.com, zimon.toutoune@gmail.com, tanguy@bioneland.org, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 18 Apr 2025 02:28:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 77882 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77882@debbugs.gnu.org Cc: Hilton Chain , Andrew Tropin , Christopher Baines , Hilton Chain , Janneke Nieuwenhuizen , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tanguy Le Carrour , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Andrew Tropin , Christopher Baines , Hilton Chain , Janneke Nieuwenhuizen , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tanguy Le Carrour , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.174494322925313 (code B ref -1); Fri, 18 Apr 2025 02:28:07 +0000 Received: (at submit) by debbugs.gnu.org; 18 Apr 2025 02:27:09 +0000 Received: from localhost ([127.0.0.1]:49066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u5bRW-0006ZO-1j for submit@debbugs.gnu.org; Thu, 17 Apr 2025 22:27:07 -0400 Received: from lists.gnu.org ([2001:470:142::17]:49788) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u5bRN-0006XN-FV for submit@debbugs.gnu.org; Thu, 17 Apr 2025 22:26:58 -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 1u5bRH-00009i-0y for guix-patches@gnu.org; Thu, 17 Apr 2025 22:26:47 -0400 Received: from mx.boiledscript.com ([88.99.243.112]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u5bRE-0003Ny-9y for guix-patches@gnu.org; Thu, 17 Apr 2025 22:26:45 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1744943200; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=pv9V4x0i8yj/8uFw8lr6M7BIR7OXPuXm9SqHtJ55Ngk=; b=XIlJZc0YpwYLMscWwJDEI/UbuBelUJ2HBSIlp5sjBiTVqQqjzrN8CG5zy48xGkSNmuN5Wi EQCDu1JV066ZJ4qqQqIFEOTew92u3HaEyT1HqiMNWUJOPEjv4Yy/WT/mqgxN1Jo8gLtAUc ZypIUbrksNuJ9i36YoD9ppmZM8aMirpNKuYa/tndZ5eJnwf7AQ6rlr4iCifc8qGeudV7Pl P+Bh43ITrhKQnZt4DwWKFNHoNgiCRrZJrFsRAKjMxxmLud7jjjmRHJEtyrDaoW+49FraQW eUF8AHAD+TdGxUdnbrZpGzTUTlD51COJbKmDIktf4AH7AI2DSZFiuHmzbOcmPA== Date: Fri, 18 Apr 2025 10:26:19 +0800 Message-ID: MIME-Version: 1.0 Received-SPF: pass client-ip=88.99.243.112; envelope-from=hako@ultrarare.space; helo=mx.boiledscript.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 * guix/scripts/home.scm (process-action): Handle operating-system declaration and extract home environment for current user. * doc/guix.texi (Guix Services)[Guix Home Service]: Document it. Change-Id: I995f79c2549e6edc76322542d0422159e0b79996 Reviewed-by: Maxim Cournoyer --- doc/guix.texi | 5 +++++ guix/scripts/home.scm | 31 +++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) base-commit: f3fb333f7c7827780884d2e202f215e75db527af prerequisite-patch-id: df261270810df64de08b358af11031330674eb28 prerequisite-patch-id: 3f82b9ffbffb403a77631567c4af11a2493ee8a7 diff --git a/doc/guix.texi b/doc/guix.texi index 070528667f..a58326debf 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -42255,6 +42255,11 @@ Guix Services everything consistently at once, saving users the need to run @command{guix home reconfigure} independently. +@command{guix home} can operate on the home environment configured for +current user via this service, but its effect won't last beyond the next +system activation. This can be used for quick testing and may avoid the +need of keeping a separate home configuration. + @defvar guix-home-service-type Service type for the Guix Home service. Its value must be a list of lists containing user and home environment pairs. The key of each pair diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index b4c82d275f..6d0a68166e 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -35,6 +35,8 @@ (define-module (guix scripts home) shepherd-service-requirement) #:autoload (guix modules) (source-module-closure) #:autoload (gnu build linux-container) (call-with-container %namespaces) + #:use-module ((gnu system) #:select (operating-system? + operating-system-user-services)) #:autoload (gnu system linux-container) (eval/container) #:autoload (gnu system file-systems) (file-system-mapping file-system-mapping-source @@ -478,10 +480,31 @@ (define (process-action action args opts) declaration as an argument (a file name.) OPTS is the raw alist of options resulting from command-line parsing." (define (ensure-home-environment file-or-exp obj) - (unless (home-environment? obj) - (leave (G_ "'~a' does not return a home environment~%") - file-or-exp)) - obj) + (let* ((username + (or (getenv "LOGNAME") + (passwd:name (getpwuid (getuid))))) + (os-home-env-config + (and (operating-system? obj) + (and=> (find (lambda (%service) + (eq? (service-type-name (service-kind %service)) + 'guix-home)) + (operating-system-user-services obj)) + service-value))) + (os-home-env + (and os-home-env-config + (and=> (find (lambda (home-env-config) + (string=? (first home-env-config) username)) + os-home-env-config) + second))) + (home-env + (or os-home-env obj))) + (unless (home-environment? home-env) + (if (operating-system? obj) + (leave (G_ "'~a' does not contain a home environment for user '~a'~%") + file-or-exp username) + (leave (G_ "'~a' does not return a home environment~%") + file-or-exp))) + home-env)) (let* ((file (match args (() #f)