From unknown Thu Aug 14 18:39:22 2025 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 Content-Transfer-Encoding: 8bit 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-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * 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 --- doc/guix.texi | 5 +++++ guix/scripts/home.scm | 31 +++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) 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) base-commit: f3fb333f7c7827780884d2e202f215e75db527af prerequisite-patch-id: df261270810df64de08b358af11031330674eb28 prerequisite-patch-id: 3f82b9ffbffb403a77631567c4af11a2493ee8a7 -- 2.49.0 From unknown Thu Aug 14 18:39:22 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#77882] [PATCH] scripts: home: Support extracting home-environment from Guix System declaration. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 21 Apr 2025 01:34:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77882 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Hilton Chain Cc: Josselin Poiret , Tobias Geerinckx-Rice , Tanguy Le Carrour , Simon Tournier , Mathieu Othacehe , Ludovic =?UTF-8?Q?Court=C3=A8s?= , 77882@debbugs.gnu.org, Andrew Tropin , Christopher Baines , Janneke Nieuwenhuizen Received: via spool by 77882-submit@debbugs.gnu.org id=B77882.174519920919019 (code B ref 77882); Mon, 21 Apr 2025 01:34:03 +0000 Received: (at 77882) by debbugs.gnu.org; 21 Apr 2025 01:33:29 +0000 Received: from localhost ([127.0.0.1]:57312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u6g2K-0004wg-QP for submit@debbugs.gnu.org; Sun, 20 Apr 2025 21:33:29 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:56490) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u6g2F-0004vg-OD for 77882@debbugs.gnu.org; Sun, 20 Apr 2025 21:33:26 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-225477548e1so33603365ad.0 for <77882@debbugs.gnu.org>; Sun, 20 Apr 2025 18:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199198; x=1745803998; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=j5mRk4NUoj+yC8pkGgmUKmsrN12+iphcWQkoLvYkX1c=; b=Pohul+/EjOsw2DeA8uNJYC3+GGc5cIrbJ69Jl8wXcj3nFbAA/FhSAusMIx4kiwoeFZ zLPJZCEE8OnmrQAN8Qiy1h14oesPx/N+srFwdHXaYfOWJlfcH4SFxIYYFm2P+LvWk3wo WeBnMfyGVSXWeAa4THUMB3EynBXow1k6COyYdbE7+YSryi6SYTXhVyLZkRDKaH2uHJu3 FnJcQMtCM3cH/Fq9m0+jRdq8cUrpveNWS9EULYr3wFj+dmTJRXVD7EQVcyNGL53rcqj/ zh4uxIem/P/CkWvklnYoZ+KDgouslfaqFeCpa1CZoOIDgkOzxgeeQnHdKnK8J8ivYzsy aKDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199198; x=1745803998; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=j5mRk4NUoj+yC8pkGgmUKmsrN12+iphcWQkoLvYkX1c=; b=TL1Tm081djdtXQftMAWo7CmfN/Oy5nine6UoXCgDtMiMi8SDdDtQZxAak7YzXwexRu W4X+jjotJfcid0S2GFR5Zgo/G1rSrUBdUAVP4x1R+DDBX4TETvgZURKupCoztnCQfU/E 0DnYZbFfpzyjCbV34cUvVxkyZUPKGm7YinEC0OOJ0u5H2/jLOi5kjwtlS0Q5gkTlAqDa UNw+flaV/QZjXbueIKtiPLeWB626UNwBl5ZtO+14aVsETgAuxGIGjr20uJz4kGZKocVE n8t0HgJNha3lMHM9M7a6i3aNDarDuenESagkGdJznEw//hQNEa5xqqY+c/6GgkvkmOfG /3mg== X-Gm-Message-State: AOJu0Yx82FKWbsECcLnqXWKMG9TSIx2Mmz27QjG7Y4z1PDrbLRfrJFST DlgN053kNyy9bfD389lVgh7frBerFGhtBYW+/8M/1XmJToz41HjE X-Gm-Gg: ASbGnctPAwAZP8DedOpp6I4btE5SJp7+cqDHXDLY0q0wfhnPAFCWBaQopsnUiqg+NvJ akuPxnMXj+2+/NzYOE75CIqQloU58pqYUyfI3SGj0qzU95wsjqYQNDXKGebJRcN8x0lUIsxOdee nOx6RNe5L/lzo8gqWoL/b4MJAKHAsHaa1ZEQueXE1XwV8H1k1sDhPEYEGCvPQ/1OcFvMiSuIsCa x055XlIX3fP8EV2ZCLjWRkk+zM6hZ94l9wtJ0M9Bk598vnVlL0fkojHM40hiFxEfo6rfsWjkHeo gD3xaZyVUbQ79KdUd7AxeRMpJl+yQ8/HpEyPsIY= X-Google-Smtp-Source: AGHT+IElqtcIdiiHmJuYTv70aYHzDexahTgD5eAt8zJK8w1vHKGqBw6Xiw80C4dKTbnaFepvpqFmhQ== X-Received: by 2002:a17:902:e5cf:b0:223:5525:6239 with SMTP id d9443c01a7336-22c53600e34mr157930305ad.38.1745199197674; Sun, 20 Apr 2025 18:33:17 -0700 (PDT) Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73dbf8e4912sm5542409b3a.60.2025.04.20.18.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Apr 2025 18:33:17 -0700 (PDT) From: Maxim Cournoyer In-Reply-To: (Hilton Chain's message of "Fri, 18 Apr 2025 10:26:19 +0800") References: Date: Mon, 21 Apr 2025 10:33:12 +0900 Message-ID: <875xiynvs7.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 3.0 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, Hilton Chain writes: > * 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. Content analysis details: (3.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.0 MANY_TO_CC Sent to 10+ recipients 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (maxim.cournoyer[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:629 listed in] [list.dnswl.org] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, Hilton Chain writes: > * 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. Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:629 listed in] [list.dnswl.org] 3.0 MANY_TO_CC Sent to 10+ recipients 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (maxim.cournoyer[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager Hi, Hilton Chain writes: > * 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. The use case is a bit unclear for me, despite reading... > Change-Id: I995f79c2549e6edc76322542d0422159e0b79996 > --- > doc/guix.texi | 5 +++++ > guix/scripts/home.scm | 31 +++++++++++++++++++++++++++---- > 2 files changed, 32 insertions(+), 4 deletions(-) > > 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. ... this. How do you declare a home environment in an `operating-system' declaration? Is this already supported? Oh! 'guix-home-service-type'. It seems I'm late in the news. That's cool! > @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))))) First time I've heard of LOGNAME :-). Typically I see 'USER' used in its place; shouldn't that be consulted as well, or used instead? As for the second clause of the above or, it can be simplified to just '(getpwnam (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)) LGTM. Reviewed-by: Maxim Cournoyer -- Thanks, Maxim From unknown Thu Aug 14 18:39:22 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Hilton Chain Subject: bug#77882: closed (Re: [bug#77882] [PATCH] scripts: home: Support extracting home-environment from Guix System declaration.) Message-ID: References: <87v7qhncda.wl-hako@ultrarare.space> X-Gnu-PR-Message: they-closed 77882 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 77882@debbugs.gnu.org Date: Sat, 03 May 2025 11:50:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1746273002-5926-1" This is a multi-part message in MIME format... ------------=_1746273002-5926-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #77882: [PATCH] scripts: home: Support extracting home-environment from Gui= x System declaration. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 77882@debbugs.gnu.org. --=20 77882: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D77882 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1746273002-5926-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 77882-done) by debbugs.gnu.org; 3 May 2025 11:49:33 +0000 Received: from localhost ([127.0.0.1]:38966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uBBN6-0001WY-Hn for submit@debbugs.gnu.org; Sat, 03 May 2025 07:49:32 -0400 Received: from mail.boiledscript.com ([2a01:4f8:242:4aeb::42]:45634) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uBBN3-0001WM-Jv for 77882-done@debbugs.gnu.org; Sat, 03 May 2025 07:49:30 -0400 Date: Sat, 03 May 2025 19:48:49 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1746272967; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IAhA8l35McUhJhDutx+9KAGWKA2h/Uq7i58AndvYbv4=; b=TPSXvhJ1znGWwfWz00ZI8X4ZdKBeHOqZzLT9CKJU+VTzgRkWP2eBIZRABPSqvbX5EJvAXX 8wzh47Ms+a3k6xup8mrQ1Pkbppy1x2/tb+w2Az1ryRq5WfPamJD02RPgAbkO5pjlRrNPqN wT1ECPRuS4uyIcVN8mnBbKAqCgFVy9felmn3ybE3SXElJqkUKl7cUDB3+LtXpPAUHv2lTX rFCtsjdNEbxvj/zD+A+54Yx/kXVrR4AvBjkFJjQjTnGP9qXS7hhothw7Ki3lEwvQsNVABq Chn0C6JAhG3ddq9PjweS6rENcN1XXzig5SwTEIqiu3Y2p6rSGqT1fY9FVHiqrA== Message-ID: <87v7qhncda.wl-hako@ultrarare.space> From: Hilton Chain To: Maxim Cournoyer Subject: Re: [bug#77882] [PATCH] scripts: home: Support extracting home-environment from Guix System declaration. In-Reply-To: <875xiynvs7.fsf@gmail.com> References: <875xiynvs7.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 3.0 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Mon, 21 Apr 2025 09:33:12 +0800, Maxim Cournoyer wrote: > > Hi, > > Hilton Chain writes: > > > * guix/scripts/home.scm (process-action): Handle operating-system declaration > [...] Content analysis details: (3.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.0 MANY_TO_CC Sent to 10+ recipients -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Debbugs-Envelope-To: 77882-done Cc: Josselin Poiret , Tanguy Le Carrour , Simon Tournier , Mathieu Othacehe , Ludovic =?ISO-8859-1?Q?Court=E8s?= , Tobias Geerinckx-Rice , 77882-done@debbugs.gnu.org, Andrew Tropin , Christopher Baines , Janneke Nieuwenhuizen X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Mon, 21 Apr 2025 09:33:12 +0800, Maxim Cournoyer wrote: > > Hi, > > Hilton Chain writes: > > > * guix/scripts/home.scm (process-action): Handle operating-system declaration > [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.0 MANY_TO_CC Sent to 10+ recipients -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager On Mon, 21 Apr 2025 09:33:12 +0800, Maxim Cournoyer wrote: > > Hi, > > Hilton Chain writes: > > > * guix/scripts/home.scm (process-action): Handle operating-system decla= ration > > and extract home environment for current user. > > * doc/guix.texi (Guix Services)[Guix Home Service]: Document it. > > The use case is a bit unclear for me, despite reading... > > > Change-Id: I995f79c2549e6edc76322542d0422159e0b79996 > > --- > > doc/guix.texi | 5 +++++ > > guix/scripts/home.scm | 31 +++++++++++++++++++++++++++---- > > 2 files changed, 32 insertions(+), 4 deletions(-) > > > > 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 ne= xt > > +system activation. This can be used for quick testing and may avoid t= he > > +need of keeping a separate home configuration. > > ... this. > > How do you declare a home environment in an `operating-system' > declaration? Is this already supported? > > Oh! 'guix-home-service-type'. It seems I'm late in the news. That's > cool! > > > @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-requirem= ent) > > #:autoload (guix modules) (source-module-closure) > > #:autoload (gnu build linux-container) (call-with-container %names= paces) > > + #: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 op= tions > > 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))))) > > First time I've heard of LOGNAME :-). Typically I see 'USER' used in > its place; shouldn't that be consulted as well, or used instead? OK, I have changed to use USER instead. > As for the second clause of the above or, it can be simplified to just > '(getpwnam (getuid))'. Tried it in REPL, the result is the same as =A1(getpwuid (getuid))=A2. So = I left it unchanged. > > + (os-home-env-config > > + (and (operating-system? obj) > > + (and=3D> (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=3D> (find (lambda (home-env-config) > > + (string=3D? (first home-env-config) us= ername)) > > + 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 u= ser '~a'~%") > > + file-or-exp username) > > + (leave (G_ "'~a' does not return a home environment~%") > > + file-or-exp))) > > + home-env)) > > LGTM. > > Reviewed-by: Maxim Cournoyer Thanks for the review! Applied as 415e3d98d6faf5fd3d1b7b3daa2f20636e4ff822. ------------=_1746273002-5926-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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== To: guix-patches@gnu.org Subject: [PATCH] scripts: home: Support extracting home-environment from Guix System declaration. Date: Fri, 18 Apr 2025 10:26:19 +0800 Message-ID: MIME-Version: 1.0 X-Debbugs-Cc: Andrew Tropin , Christopher Baines , Hilton Chain , Janneke Nieuwenhuizen , Josselin Poiret , Ludovic Courtès , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tanguy Le Carrour , Tobias Geerinckx-Rice Content-Transfer-Encoding: 8bit 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-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: Hilton Chain X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * 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 --- doc/guix.texi | 5 +++++ guix/scripts/home.scm | 31 +++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) 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) base-commit: f3fb333f7c7827780884d2e202f215e75db527af prerequisite-patch-id: df261270810df64de08b358af11031330674eb28 prerequisite-patch-id: 3f82b9ffbffb403a77631567c4af11a2493ee8a7 -- 2.49.0 ------------=_1746273002-5926-1--