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