Subject: guix-cookbook : (Basic setup with mafinests)

From: Fulbert <[email-masked]>
Date: Tue, 23 Mar 2021 15:44:59 +0100

… with the patch this time !

Hello,

I propose those changes to (Basic setup with mafinests) as they
are more likely to produce the exptected result. Probably the
`combined` search-paths profiles were not available at the time of
writing this section ?!

Although It works well for me, I'm not 100% sure it should make it
to live guix-cookbook. Not sure either if filtering-out
$HOME/.config/guix/current is necessary.

Anyway, I thought it was worth proposing :)

Best regards,
Fulbert
>From 352b4bbbec7acd51d01a05f11b0e59bbe8b2b2cb Mon Sep 17 00:00:00 2001
From: Fulbert <[email-masked]>
Date: Tue, 23 Mar 2021 14:26:15 +0100
Subject: [PATCH] =?UTF-8?q?doc:=20cookbook:=20modify=20=E2=80=9Cenable=20a?=
 =?UTF-8?q?ll=20profiles=20on=20login=E2=80=9D=20examples.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* doc/guix-cookbook.texi (Basic setup with mafinests): “enable all
  profiles on login” examples changed from etc/profile sourcing to
  combined profiles eval's.
---
 doc/guix-cookbook.texi | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi
index 1cddaa7faf..81339f16b3 100644
--- a/doc/guix-cookbook.texi
+++ b/doc/guix-cookbook.texi
@@ -2531,14 +2531,13 @@ although you'll probably have to filter out @file{~/.config/guix/current}.
 To enable all profiles on login, add this to your @file{~/.bash_profile} (or similar):
 
 @example
-for i in $GUIX_EXTRA_PROFILES/*; do
-  profile=$i/$(basename "$i")
-  if [ -f "$profile"/etc/profile ]; then
-    GUIX_PROFILE="$profile"
-    . "$GUIX_PROFILE"/etc/profile
-  fi
-  unset profile
-done
+search_paths_profiles() @{
+  for p in $(guix package --list-profiles); do
+    [[ "$p" != "$HOME/.config/guix/current" ]] \
+      && echo -n "-p $p "
+  done
+@}
+eval $(guix package $(search_paths_profiles) --search-paths=suffix)
 @end example
 
 Note to Guix System users: the above reflects how your default profile
@@ -2548,14 +2547,13 @@ Note to Guix System users: the above reflects how your default profile
 You can obviously choose to only enable a subset of them:
 
 @example
-for i in "$GUIX_EXTRA_PROFILES"/my-project-1 "$GUIX_EXTRA_PROFILES"/my-project-2; do
-  profile=$i/$(basename "$i")
-  if [ -f "$profile"/etc/profile ]; then
-    GUIX_PROFILE="$profile"
-    . "$GUIX_PROFILE"/etc/profile
-  fi
-  unset profile
-done
+search_paths_profiles() @{
+  for p in $(guix package --list-profiles); do
+    [[ "$p" =~ (my-project-1)|(my-project-2)|(…) ]] \
+      && echo -n "-p $p "
+  done
+@}
+eval $(guix package $(search_paths_profiles) --search-paths=suffix)
 @end example
 
 When a profile is off, it's straightforward to enable it for an individual shell
@@ -2575,8 +2573,11 @@ It contains the same variables you would get if you ran:
 guix package --search-paths=prefix --profile=$my_profile"
 @end example
 
-Once again, see (@pxref{Invoking guix package,,, guix, GNU Guix Reference Manual})
-for the command line options.
+Note that you can also use this option to compute
+@emph{combined --search-paths} of several profiles, as illustrated in the
+previous @samp{~/.bash_profile} example.
+
+Once again, see (@pxref{Invoking guix package,,, guix, GNU Guix Reference Manual}) for the command line options.
 
 To upgrade a profile, simply install the manifest again:
 
-- 
2.31.0