From patchwork Mon Mar 31 16:25:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 41085 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 A4F0527BBE9; Mon, 31 Mar 2025 17:27:27 +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=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 6BF7227BBEA for ; Mon, 31 Mar 2025 17:27:26 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tzHyb-0004Uy-10; Mon, 31 Mar 2025 12:27:05 -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 1tzHyZ-0004Ua-Sa for guix-patches@gnu.org; Mon, 31 Mar 2025 12:27:04 -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 1tzHyZ-0001Ej-8T; Mon, 31 Mar 2025 12:27:03 -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=YVrTHTt0bqEnc1myNa4SyNS1/6XW0Rs08CYO5WINEKA=; b=l79r6hpbTpFdL1HWq4KAvLheM9j7Wc59ELLX/OsaAUzVy90GxxOgrUek/ntEbU0Ht0nwguo/2J7P3TJUijInuQx/2wsSRGv6pXSX585IGAkLQE3iBwG3DE1u679E67VMnqfJZSSSawOhvGDExHldwYcg21wvhnI1zsuoE+PsfGGQhTR1Jf9AqtMsgDJYlonWO+pyi0/YBZLjzswh/+peqD6sCYtwU8WAgJr43PJxO1vlMUFQwSS5CKQbTt0jdbBK6a34jUL2gnoK9QSbgF1Y2CPFKfi7E3CpPxEFW46ktVYniOD2ETJLCsIp8Z9qaV/UB9iZtyb7SLrgTK7OQ+Q3/g==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tzHyZ-0005v6-1m; Mon, 31 Mar 2025 12:27:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77035] [PATCH v2 1/3] system: /etc/profile: Take care of all default profiles. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, ludo@gnu.org, guix-patches@gnu.org Resent-Date: Mon, 31 Mar 2025 16:27:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77035 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77035@debbugs.gnu.org Cc: Hilton Chain , Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= X-Debbugs-Original-Xcc: Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 77035-submit@debbugs.gnu.org id=B77035.174343841822712 (code B ref 77035); Mon, 31 Mar 2025 16:27:03 +0000 Received: (at 77035) by debbugs.gnu.org; 31 Mar 2025 16:26:58 +0000 Received: from localhost ([127.0.0.1]:42590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tzHyT-0005uE-Cp for submit@debbugs.gnu.org; Mon, 31 Mar 2025 12:26:58 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:43272) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tzHyG-0005sC-KA for 77035@debbugs.gnu.org; Mon, 31 Mar 2025 12:26:46 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1743438402; 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=YVrTHTt0bqEnc1myNa4SyNS1/6XW0Rs08CYO5WINEKA=; b=KoT5+ybHxOcDevicXU9pcqrUWsJA7/rNogqIqAOQD/GDH8cYAttwktivKXhSwlYZ4OvHdb pJn6c/FSkww1ZKAw5WHM96ktehozQgyL9dZg6X4PJumnGwjYbPY4O9b2v6j/QPRqRcxul7 Y5pObNuxpNNfrhfB6HP39xPn8Pi5C1BQPRVP+zRsKZrs9mJvbALMD66NZvSePbKK0pSUC5 NmYEyM1kM3ilFOQn3qs+J5Paq0kftlC05VhoTKgNRjoy5JrKLyHzeIC/yBK3RAa1FQSFKY Mvl4eJZqtG/rOxt70hjmov4YBHwhtXrgq7FMUMQLiprH7zDWvQeaiZV6APJeNA== Date: Tue, 1 Apr 2025 00:25:56 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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 * gnu/system.scm (operating-system-etc-service)[/etc/profile]: Merge search paths. Take care of all default profiles. Address some issues reported by ‘shellcheck’. * gnu/system/shadow.scm (%default-bash-profile): Remove duplicated exports. Change-Id: I0e14d7c0266742e0abf07779e501de0e257c1329 --- gnu/system.scm | 155 ++++++++++++++++++++++++++++-------------- gnu/system/shadow.scm | 10 --- 2 files changed, 104 insertions(+), 61 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 0d98e5a036..e05f5938bc 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -1060,71 +1060,124 @@ (define* (operating-system-etc-service os) ;; Startup file for POSIX-compliant login shells, which set system-wide ;; environment variables. (profile (mixed-text-file "profile" "\ -# Crucial variables that could be missing in the profiles' 'etc/profile' -# because they would require combining both profiles. -# FIXME: See . -export MANPATH=$HOME/.guix-profile/share/man:/run/current-system/profile/share/man -export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info -export XDG_DATA_DIRS=$HOME/.guix-profile/share:/run/current-system/profile/share -export XDG_CONFIG_DIRS=$HOME/.guix-profile/etc/xdg:/run/current-system/profile/etc/xdg - -# Make sure libXcursor finds cursors installed into user or system profiles. See -export XCURSOR_PATH=$HOME/.icons:$HOME/.guix-profile/share/icons:/run/current-system/profile/share/icons +# Set the umask, notably for users logging in via 'lsh'. +# See . +umask 022 # Ignore the default value of 'PATH'. unset PATH -# Load the system profile's settings. -GUIX_PROFILE=/run/current-system/profile ; \\ -. /run/current-system/profile/etc/profile - # Since 'lshd' does not use pam_env, /etc/environment must be explicitly # loaded when someone logs in via SSH. See . -# We need 'PATH' to be defined here, for 'cat' and 'cut'. Do this before -# reading the user's 'etc/profile' to allow variables to be overridden. -if [ -f /etc/environment -a -n \"$SSH_CLIENT\" \\ - -a -z \"$LINUX_MODULE_DIRECTORY\" ] +# Do this before reading the user's 'etc/profile' to allow variables to be +# overridden. +if [ -f /etc/environment ] && [ -n \"$SSH_CLIENT\" ] && + [ -z \"$LINUX_MODULE_DIRECTORY\" ] then . /etc/environment - export `cat /etc/environment | cut -d= -f1` + export \"$(/run/current-system/profile/bin/cut -d= -f1 < /etc/environment)\" fi -# Arrange so that ~/.config/guix/current comes first, -# and guix-home comes before guix-profile. -for profile in \"$HOME/.guix-profile\" \\ - \"$HOME/.guix-home/profile\" \\ - \"$HOME/.config/guix/current\" -do - if [ -f \"$profile/etc/profile\" ] - then - # Load the user profile's settings. - GUIX_PROFILE=\"$profile\" ; \\ - . \"$profile/etc/profile\" - else - # At least define this one so that basic things just work - # when the user installs their first package. - export PATH=\"$profile/bin:$PATH\" - fi -done +# Merge search paths and set up environment for all default profiles. +eval \"$(/run/current-system/profile/bin/guix package \\ + --search-paths=prefix \\ + --profile=\"$HOME/.config/guix/current\" \\ + --profile=\"$HOME/.guix-profile\" \\ + --profile=\"$HOME/.guix-home/profile\" \\ + --profile=/run/current-system/profile)\" + +# Make ‘guix pull’ profile work out of the box. +GUIX_PROFILE=\"$HOME/.config/guix/current\" +case $PATH in + *$GUIX_PROFILE/bin*) ;; + *) export PATH=\"$GUIX_PROFILE/bin${PATH:+:}$PATH\" ;; +esac +# Expose the latest Guix modules to Guile so guix shell and repls spawned by +# e.g. Geiser work out of the box. +case $GUILE_LOAD_PATH in + *$GUIX_PROFILE/share/guile/site/3.0*) ;; + *) export GUILE_LOAD_PATH=\"$GUIX_PROFILE/share/guile/site/3.0${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH\" ;; +esac +case $GUILE_LOAD_COMPILED_PATH in + *$GUIX_PROFILE/lib/guile/3.0/site-ccache*) ;; + *) export GUILE_LOAD_COMPILED_PATH=\"$GUIX_PROFILE/lib/guile/3.0/site-ccache${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH\" ;; +esac +unset GUIX_PROFILE # Prepend privileged programs. -export PATH=/run/privileged/bin:$PATH - -# Arrange so that ~/.config/guix/current/share/info comes first. -export INFOPATH=\"$HOME/.config/guix/current/share/info:$INFOPATH\" - -# Set the umask, notably for users logging in via 'lsh'. -# See . -umask 022 - -# Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to -# find dictionaries. -export DICPATH=\"$HOME/.guix-profile/share/hunspell:/run/current-system/profile/share/hunspell\" - +export PATH=\"/run/privileged/bin:$PATH\" + +# Crucial variables that could be missing in the profiles' 'etc/profile'. +if [ -z \"$XDG_DATA_DIRS\" ]; then + export XDG_DATA_DIRS=\"` + `$HOME/.guix-profile/share:` + `$HOME/.guix-home/profile/share:` + `/run/current-system/profile/share\" +fi +if [ -z \"$XDG_CONFIG_DIRS\" ]; then + export XDG_CONFIG_DIRS=\"` + `$HOME/.guix-profile/etc/xdg:` + `$HOME/.guix-home/profile/etc/xdg:` + `/run/current-system/profile/etc/xdg\" +fi +# When MANPATH is unset, add a trailing colon so the system default search path +# is used. +if [ -z \"$MANPATH\" ]; then + export MANPATH=\"` + `$HOME/.guix-profile/share/man:` + `$HOME/.guix-home/profile/share/man:` + `/run/current-system/profile/share/man:\" +fi +# When INFOPATH is unset, add a trailing colon so Emacs searches +# 'Info-default-directory-list'. +if [ -z \"$INFOPATH\" ]; then + export INFOPATH=\"` + `$HOME/.config/guix/current/share/info:` + `$HOME/.guix-profile/share/info:` + `$HOME/.guix-home/profile/share/info:` + `/run/current-system/profile/share/info:\" +else + case $INFOPATH in + *$HOME/.config/guix/current/share/info*) ;; + *) export INFOPATH=\"$HOME/.config/guix/current/share/info:$INFOPATH\" ;; + esac +fi +# Make sure libXcursor finds cursors installed into user or system profiles. +# See +if [ -z \"$XCURSOR_PATH\" ]; then + export XCURSOR_PATH=\"` + `$HOME/.icons:` + `$HOME/.guix-profile/share/icons:` + `$HOME/.guix-home/profile/share/icons:` + `/run/current-system/profile/share/icons\" +else + case $XCURSOR_PATH in + *$HOME/.icons*) ;; + *) export XCURSOR_PATH=\"$HOME/.icons:$XCURSOR_PATH\" ;; + esac +fi +# Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to find +# dictionaries. +if [ -z \"$DICPATH\" ]; then + export DICPATH=\"` + `$HOME/.guix-profile/share/hunspell:` + `$HOME/.guix-home/profile/share/hunspell:` + `/run/current-system/profile/share/hunspell\" +fi # Allow GStreamer-based applications to find plugins. -export GST_PLUGIN_PATH=\"$HOME/.guix-profile/lib/gstreamer-1.0\" +if [ -z \"$GST_PLUGIN_PATH\" ]; then + export GST_PLUGIN_PATH=\"` + `$HOME/.guix-profile/lib/gstreamer-1.0:` + `$HOME/.guix-home/profile/lib/gstreamer-1.0:` + `/run/current-system/profile/lib/gstreamer-1.0\" +fi + +# Set up extra environment variables for Guix Home. +HOME_ENVIRONMENT=\"$HOME/.guix-home\" +[ -L \"$HOME_ENVIRONMENT\" ] && . \"$HOME_ENVIRONMENT/setup-environment\" +unset HOME_ENVIRONMENT -if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ] +if [ -n \"$BASH_VERSION\" ] && [ -f /etc/bashrc ] then # Load Bash-specific initialization code. . /etc/bashrc diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index b68a818871..cdb804da18 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -179,16 +179,6 @@ (define %default-bash-profile # Honor per-interactive-shell startup file if [ -f ~/.bashrc ]; then . ~/.bashrc; fi - -# Merge search-paths from multiple profiles, the order matters. -eval \"$(guix package --search-paths \\ --p $HOME/.config/guix/current \\ --p $HOME/.guix-home/profile \\ --p $HOME/.guix-profile \\ --p /run/current-system/profile)\" - -# Prepend setuid programs. -export PATH=/run/setuid-programs:$PATH ")) (define %default-zprofile From patchwork Mon Mar 31 16:25:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 41086 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 0F4AD27BBE9; Mon, 31 Mar 2025 17:27:28 +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=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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=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 4666C27BBE2 for ; Mon, 31 Mar 2025 17:27:26 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tzHyi-0004lo-Nt; Mon, 31 Mar 2025 12:27:12 -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 1tzHyh-0004gT-8x for guix-patches@gnu.org; Mon, 31 Mar 2025 12:27:11 -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 1tzHyf-0001FV-Od; Mon, 31 Mar 2025 12:27:10 -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=uaRJtr4Oimk15LlT3xQw2nloVJ56z2EOx+qIeINJmeA=; b=PAFB/vbPEEwrKcHajSI0u/s5y48ccW3MF3aYcRwssP7tWc6fcFfQRXvNa2RNlJxncu6H3klTyr6HeG0kqNwINIH5vW0/vV0MysPZdulYelNJb9b2HchKBRVsw4q+yHgEPJQARgsQozBomc4m6PtFBluSVBFnAs0Ys8PUvz0ToSBx0Da6sxa2SIf9dt5exTEC0CUd0cpY7FUh8IfTNXZt6zMihrJtelr9Z0xh3nywU1XTg5F5u/wnf3TlqRx4BRlses8Boh386JvWnHJy1dfd3oT44m0DdEreXsNm/c5eO2tUDTpUxRW2XsUZjDBOKq7onXoUXENRR1TEaDQHDag06A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tzHyZ-0005vE-HS; Mon, 31 Mar 2025 12:27:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77035] [PATCH v2 2/3] home: setup-environment: Skip if already initialized. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, ludo@gnu.org, andrew@trop.in, janneke@gnu.org, tanguy@bioneland.org, guix-patches@gnu.org Resent-Date: Mon, 31 Mar 2025 16:27:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77035 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77035@debbugs.gnu.org Cc: Hilton Chain , Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin , Janneke Nieuwenhuizen , Tanguy Le Carrour X-Debbugs-Original-Xcc: Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin , Janneke Nieuwenhuizen , Tanguy Le Carrour Received: via spool by 77035-submit@debbugs.gnu.org id=B77035.174343841822721 (code B ref 77035); Mon, 31 Mar 2025 16:27:03 +0000 Received: (at 77035) by debbugs.gnu.org; 31 Mar 2025 16:26:58 +0000 Received: from localhost ([127.0.0.1]:42592 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tzHyU-0005uH-36 for submit@debbugs.gnu.org; Mon, 31 Mar 2025 12:26:58 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:55954) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tzHyM-0005t9-Eo for 77035@debbugs.gnu.org; Mon, 31 Mar 2025 12:26:51 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1743438409; 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=uaRJtr4Oimk15LlT3xQw2nloVJ56z2EOx+qIeINJmeA=; b=N/J+jkq1NGrSwXzTVfXRuV/7vY8/rVnaV6tf3mpXG+mDik9MMeYoqc19syVjUFYMH3FisG ZCsjkCHMmVwnnvzCe5IxLFq+KaiFkPHxYVswf4CAx+4AzF+pwVXMEnG0JRDQ0ZH2755ky7 1xJOi3ytut7w0gVD1ahOzLqx2D4uPeunqv81opM6O7Rclg/tohqTfUVi2EyHJ2v0hpVwVr 7FbNO4s1wX+XWkNWXqtE+Vs2ohThH/F1/jS0SXAHXcaNPqE2eimvsI9+S042WF6Jx2OSp0 /5VJliCsVUP8gUSqFecrk+vvRwZOx7txusVLQsuzcaY0e3rK2WS1yQw+E+lw4A== Date: Tue, 1 Apr 2025 00:25:57 +0800 Message-ID: <70536e22ec65aeb8f27f140417c43b075e774a92.1743438266.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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 * gnu/home/services.scm (environment-variables->setup-environment-script): Skip initializing home profile if already finished. Address some issues reported by ‘shellcheck’. * gnu/home/services/shells.scm (add-shell-profile-file): Skip setup-environment if already finished. Address some issues reported by ‘shellcheck’. Change-Id: Ife4100c6b19f61272525eebc82931c81784fe9e0 --- gnu/home/services.scm | 18 +++++++++++------- gnu/home/services/shells.scm | 10 +++++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/gnu/home/services.scm b/gnu/home/services.scm index 85a43f80ca..39ad31515c 100644 --- a/gnu/home/services.scm +++ b/gnu/home/services.scm @@ -279,31 +279,35 @@ (define (environment-variables->setup-environment-script vars) # ~/.profile does) GUIX_PROFILE=\"$HOME_ENVIRONMENT/profile\" PROFILE_FILE=\"$GUIX_PROFILE/etc/profile\" -[ -f $PROFILE_FILE ] && . $PROFILE_FILE +# Skip if already initialized. +case $INFOPATH in + *$GUIX_PROFILE/share/info*) ;; + *) [ -f \"$PROFILE_FILE\" ] && . \"$PROFILE_FILE\" ;; +esac case $GUIX_LOCPATH in *$GUIX_PROFILE/lib/locale*) ;; - *) export GUIX_LOCPATH=$GUIX_PROFILE/lib/locale:$GUIX_LOCPATH ;; + *) export GUIX_LOCPATH=\"$GUIX_PROFILE/lib/locale:$GUIX_LOCPATH\" ;; esac case $XDG_DATA_DIRS in *$GUIX_PROFILE/share*) ;; - *) export XDG_DATA_DIRS=$GUIX_PROFILE/share:$XDG_DATA_DIRS ;; + *) export XDG_DATA_DIRS=\"$GUIX_PROFILE/share:$XDG_DATA_DIRS\" ;; esac case $MANPATH in *$GUIX_PROFILE/share/man*) ;; - *) export MANPATH=$GUIX_PROFILE/share/man:$MANPATH + *) export MANPATH=\"$GUIX_PROFILE/share/man:$MANPATH\" ;; esac case $INFOPATH in *$GUIX_PROFILE/share/info*) ;; - *) export INFOPATH=$GUIX_PROFILE/share/info:$INFOPATH ;; + *) export INFOPATH=\"$GUIX_PROFILE/share/info:$INFOPATH\" ;; esac case $XDG_CONFIG_DIRS in *$GUIX_PROFILE/etc/xdg*) ;; - *) export XDG_CONFIG_DIRS=$GUIX_PROFILE/etc/xdg:$XDG_CONFIG_DIRS ;; + *) export XDG_CONFIG_DIRS=\"$GUIX_PROFILE/etc/xdg:$XDG_CONFIG_DIRS\" ;; esac case $XCURSOR_PATH in *$GUIX_PROFILE/share/icons*) ;; - *) export XCURSOR_PATH=$GUIX_PROFILE/share/icons:$XCURSOR_PATH ;; + *) export XCURSOR_PATH=\"$GUIX_PROFILE/share/icons:$XCURSOR_PATH\" ;; esac # Keep the shell environment clean. diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm index bab5730c3d..ce61eaa4b0 100644 --- a/gnu/home/services/shells.scm +++ b/gnu/home/services/shells.scm @@ -87,9 +87,13 @@ (define (add-shell-profile-file config) ,(mixed-text-file "shell-profile" "\ -HOME_ENVIRONMENT=$HOME/.guix-home -. $HOME_ENVIRONMENT/setup-environment -$HOME_ENVIRONMENT/on-first-login +HOME_ENVIRONMENT=\"$HOME/.guix-home\" +# Skip if already sourced. +case $GUIX_LOCPATH in + *$HOME_ENVIRONMENT/profile/lib/locale*) ;; + *) . \"$HOME_ENVIRONMENT/setup-environment\" ;; +esac +\"$HOME_ENVIRONMENT/on-first-login\" unset HOME_ENVIRONMENT\n" (serialize-configuration config From patchwork Mon Mar 31 16:25:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 41084 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 CC14727BBEA; Mon, 31 Mar 2025 17:27:21 +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=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 C8F9C27BBE2 for ; Mon, 31 Mar 2025 17:27:19 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tzHyd-0004Vb-19; Mon, 31 Mar 2025 12:27:07 -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 1tzHyb-0004VP-8Q for guix-patches@gnu.org; Mon, 31 Mar 2025 12:27:05 -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 1tzHya-0001Ew-TP; Mon, 31 Mar 2025 12:27:04 -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=fbZvvBXbHWjJEHnEZj38fBMgpGPNTGYJv8k22tAAn3g=; b=ufkez5RNMK9/+ptWf/x5ymyiG7lAWhsvSN3Nlf2sLK8QP1lpRuZ0wJV88mpcgBBa7ynyxhWCAwlmiFduNU4j6FJVgKeuy4gbHv/GOKndgoIbimU5FdKUcv8rR1DgE7IcqShHiiDtbzBRFEIFptwOPkTd8dpl042THic12zrcAmAPr4mVFZWEJbExH/4dos7SObvgwARsmo4IyMShtZdPjLWArGhUPIhXTyqxOd5yGxEL7sdo4ZY2aa1x+tOlbA4GEgnTDZ9jllC+/rcLx0w9HtMZ0mtOOV9wsKffjcce3WXSiRJyGMrCmcad/21bN/0VgKVqhLpN0WNhI09QYL8MIw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tzHya-0005vM-1i; Mon, 31 Mar 2025 12:27:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77035] [PATCH v2 3/3] guix-install.sh: /etc/profile.d/zzz-guix.sh: Handle Guix Home profile. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, ludo@gnu.org, guix-patches@gnu.org Resent-Date: Mon, 31 Mar 2025 16:27:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77035 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77035@debbugs.gnu.org Cc: Hilton Chain , Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= X-Debbugs-Original-Xcc: Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 77035-submit@debbugs.gnu.org id=B77035.174343841922730 (code B ref 77035); Mon, 31 Mar 2025 16:27:04 +0000 Received: (at 77035) by debbugs.gnu.org; 31 Mar 2025 16:26:59 +0000 Received: from localhost ([127.0.0.1]:42594 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tzHyU-0005uS-RK for submit@debbugs.gnu.org; Mon, 31 Mar 2025 12:26:59 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:43448) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tzHyQ-0005tr-UP for 77035@debbugs.gnu.org; Mon, 31 Mar 2025 12:26:55 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1743438413; 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=fbZvvBXbHWjJEHnEZj38fBMgpGPNTGYJv8k22tAAn3g=; b=jF56LrTft5hGfJvRU+QhYhZDCMytQYN+h74jLqdQksuT508wKWiwpL3lRuV5cGl/ovHQTG Mk5x/z9umNm7Aw5Wwn3whyQbpyVl9szZlEuo1XJ6FelQXvGxK9ffU9GG6E14TkC0ONhdAu P45E9JW2indBgZGK21YcsrpJ3Jk0M6tYPZnBrLqE1JwSfyg3apSZ3kPeXMvt+VvSXo+T// GEgcag4OmNoi0d1IjF8XLyWfhHfkUVmWQms2Vgj5D5FfR/jdt5ogLbglO9K5U8ZqnRpAC4 NvsC+LkZKa74mPXYba6/ot3DBXE7ob3kNaumrcccs2ZmdFwxrg+zlqmLIuBr2A== Date: Tue, 1 Apr 2025 00:25:58 +0800 Message-ID: <043b31de365ae667a9d7d5588f228b94eb27e267.1743438266.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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 * etc/guix-install.sh (sys_create_init_profile): Handle Guix Home profile. Arrange so that imperative profiles order first. Change-Id: I60057c071d1d29f7930e027720f6f86a0c6b4254 --- etc/guix-install.sh | 86 +++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 34 deletions(-) diff --git a/etc/guix-install.sh b/etc/guix-install.sh index b5d833cd64..2010dab4d0 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -749,47 +749,65 @@ export XDG_CONFIG_DIRS="${XDG_CONFIG_DIRS:-/etc/xdg}" export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" # no default for XDG_RUNTIME_DIR (depends on foreign distro for semantics) -# `guix pull` profile -GUIX_PROFILE="$HOME/.config/guix/current" -export PATH="$GUIX_PROFILE/bin${PATH:+:}$PATH" -# Add to INFOPATH and MANPATH so the latest Guix documentation is available to -# info and man readers. When INFOPATH is unset, add a trailing colon so Emacs -# searches 'Info-default-directory-list'. When MANPATH is unset, add a -# trailing colon so the system default search path is used. -export INFOPATH="$GUIX_PROFILE/share/info:$INFOPATH" -export MANPATH="$GUIX_PROFILE/share/man:$MANPATH" -# Expose the latest Guix modules to Guile so guix shell and repls spawned by -# e.g. Geiser work out of the box. -export GUILE_LOAD_PATH="$GUIX_PROFILE/share/guile/site/3.0${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH" -export GUILE_LOAD_COMPILED_PATH="$GUIX_PROFILE/lib/guile/3.0/site-ccache${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" +# Merge search paths and set up environment for all default profiles. +eval "$(guix package \ + --search-paths=prefix \ + --profile="$HOME/.config/guix/current" \ + --profile="$HOME/.guix-profile" \ + --profile="$HOME/.guix-home/profile")" + +for profile in "$HOME/.guix-home/profile" \ + "$HOME/.guix-profile" \ + "$HOME/.config/guix/current" +do + GUIX_PROFILE="$profile" + if [ -L "$GUIX_PROFILE" ]; then + # Documentation search paths may be handled by $GUIX_PROFILE/etc/profile if + # the user installs info and man readers via Guix. If the user doesn’t, + # explicitly add to them so documentation for software from ‘guix install’ + # is available to the system info and man readers. When INFOPATH is unset, + # add a trailing colon so Emacs searches 'Info-default-directory-list'. + # When MANPATH is unset, add a trailing colon so the system default search + # path is used. + case $INFOPATH in + *$GUIX_PROFILE/share/info*) ;; + *) export INFOPATH="$GUIX_PROFILE/share/info:$INFOPATH" ;; + esac + case $MANPATH in + *$GUIX_PROFILE/share/man*) ;; + *) export MANPATH="$GUIX_PROFILE/share/man:$MANPATH" + esac + fi +done -# User's default profile, if it exists +# See info '(guix) Application Setup'. GUIX_PROFILE="$HOME/.guix-profile" if [ -L "$GUIX_PROFILE" ]; then - . "$GUIX_PROFILE/etc/profile" - - # see info '(guix) Application Setup' export GUIX_LOCPATH="$GUIX_PROFILE/lib/locale${GUIX_LOCPATH:+:}$GUIX_LOCPATH" - - # Documentation search paths may be handled by $GUIX_PROFILE/etc/profile if - # the user installs info and man readers via Guix. If the user doesn’t, - # explicitly add to them so documentation for software from ‘guix install’ - # is available to the system info and man readers. - case $INFOPATH in - *$GUIX_PROFILE/share/info*) ;; - *) export INFOPATH="$GUIX_PROFILE/share/info:$INFOPATH" ;; - esac - case $MANPATH in - *$GUIX_PROFILE/share/man*) ;; - *) export MANPATH="$GUIX_PROFILE/share/man:$MANPATH" - esac fi -# NOTE: Guix Home handles its own profile initialization in ~/.profile. See -# info '(guix) Configuring the Shell'. - -# Clean up after ourselves. +# Make ‘guix pull’ profile work out of the box. +GUIX_PROFILE="$HOME/.config/guix/current" +case $PATH in + *$GUIX_PROFILE/bin*) ;; + *) export PATH="$GUIX_PROFILE/bin${PATH:+:}$PATH" ;; +esac +# Expose the latest Guix modules to Guile so guix shell and repls spawned by +# e.g. Geiser work out of the box. +case $GUILE_LOAD_PATH in + *$GUIX_PROFILE/share/guile/site/3.0*) ;; + *) export GUILE_LOAD_PATH="$GUIX_PROFILE/share/guile/site/3.0${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH" ;; +esac +case $GUILE_LOAD_COMPILED_PATH in + *$GUIX_PROFILE/lib/guile/3.0/site-ccache*) ;; + *) export GUILE_LOAD_COMPILED_PATH="$GUIX_PROFILE/lib/guile/3.0/site-ccache${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" ;; +esac unset GUIX_PROFILE + +# Set up extra environment variables for Guix Home. +HOME_ENVIRONMENT="$HOME/.guix-home" +[ -L "$HOME_ENVIRONMENT" ] && . "$HOME_ENVIRONMENT/setup-environment" +unset HOME_ENVIRONMENT EOF }