[bug#77819] guix-install.sh: spin-off zzz-guix.sh script out of the installer.

Message ID ef4d7602b74edd74f64934a4a629e9d3a78133f9.1744705193.git.csantosb@inventati.org
State New
Headers
Series [bug#77819] guix-install.sh: spin-off zzz-guix.sh script out of the installer. |

Commit Message

Cayetano Santos April 15, 2025, 8:19 a.m. UTC
  The functionality in the install script remains the same, while this
change will contribute to follow upgrades in zzz-guix.sh.

Change-Id: Ieed963cccb445034532ec08ee2731926c791d26a
---

When using guix on a foreign distribution, the zzz-guix.sh is copied to /etc/profile.d.

When this file is renamed or updated, this modification remains unnoticed, as guix pull does not have any effect on that. This is a source of potential issues.

Spinning-off the zzz-guix.sh out of the installer script mitigates this situation, as users will be able to manually update it, following changes.

In current situation, users need to follow changes in the whole installer, searching for modifications in the relevant section, which is unfriendly.

 etc/guix-install.sh | 55 +--------------------------------------------
 etc/zzz-guix.sh     | 52 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 54 deletions(-)
 create mode 100644 etc/zzz-guix.sh


base-commit: 287aec56a53fbd66492711c375d0b39ccb6c1590
--
2.49.0
  

Patch

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index b5d833cd64..388d2cc9be 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -737,60 +737,7 @@  sys_create_init_profile()
 { # Define for better desktop integration
   # This will not take effect until the next shell or desktop session!
     [ -d "/etc/profile.d" ] || mkdir /etc/profile.d # Just in case
-    cat <<"EOF" > /etc/profile.d/zzz-guix.sh
-# Explicitly initialize XDG base directory variables to ease compatibility
-# with Guix System: see <https://issues.guix.gnu.org/56050#3>.
-export XCURSOR_PATH="${XCURSOR_PATH:-/usr/local/share/icons:/usr/share/icons}"
-export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
-export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
-export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
-export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}"
-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"
-
-# User's default profile, if it exists
-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.
-unset GUIX_PROFILE
-EOF
+    cp zzz-guix.sh /etc/profile.d
 }
 
 sys_create_shell_completion()
diff --git a/etc/zzz-guix.sh b/etc/zzz-guix.sh
new file mode 100644
index 0000000000..2d635433bc
--- /dev/null
+++ b/etc/zzz-guix.sh
@@ -0,0 +1,52 @@ 
+# Explicitly initialize XDG base directory variables to ease compatibility
+# with Guix System: see <https://issues.guix.gnu.org/56050#3>.
+export XCURSOR_PATH="${XCURSOR_PATH:-/usr/local/share/icons:/usr/share/icons}"
+export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
+export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
+export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
+export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}"
+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"
+
+# User's default profile, if it exists
+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.
+unset GUIX_PROFILE