From ebe0ec02715d15a78d4d1da6b66dde92f6d6d69d Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Date: Mon, 10 Jan 2022 15:07:50 -0500
Subject: [PATCH] build: Use guix shell.

The recently introduced 'guix shell' command automatically manages a
cached profile for us; prefer it to 'guix environment', and do away
with a channels file, given fixes in Guix have now been incorporated
in the main branch.

* Makefile (portable-release-tarball)<guix environment>: Replace by
'guix shell'.
* build.py (run_dependencies)[guix]: Likewise, and do not use a
channels.scm file.
(run_install): Likewise, and provide a hint when TARBALLS is not set.
* guix/channels.scm: Delete file.
* guix/manifest.scm: Adjust comment.

Change-Id: I50ca99e51f0ebca136c9bbc5a0ca3063075432b4
---
 Makefile          |  2 +-
 build.py          | 21 ++++++++++-----------
 guix/channels.scm |  8 --------
 guix/manifest.scm |  2 +-
 4 files changed, 12 insertions(+), 21 deletions(-)
 delete mode 100644 guix/channels.scm

diff --git a/Makefile b/Makefile
index 67943ae4..9f577aba 100644
--- a/Makefile
+++ b/Makefile
@@ -96,7 +96,7 @@ has-guix-p:
 # /etc/ssl/certs.
 guix-share-tarball-arg = $${TARBALLS:+"--share=$$TARBALLS"}
 portable-release-tarball: has-guix-p
-	guix environment --container --network \
+	guix shell --container --network \
           --preserve=TARBALLS $(guix-share-tarball-arg) \
           --expose=/usr/bin/env \
           --expose=$$SSL_CERT_DIR=/etc/ssl/certs \
diff --git a/build.py b/build.py
index 25a4939b..d2d7f0ff 100755
--- a/build.py
+++ b/build.py
@@ -306,11 +306,8 @@ def run_dependencies(args):
         print("The win32 version does not install dependencies with this script.\nPlease continue with the --install instruction.")
         sys.exit(1)
     elif args.distribution == 'guix':
-        print("Building the environment defined in 'guix/manifest.scm'...")
-        execute_script(['mkdir -p ~/.config/guix/profiles',
-                        ('guix time-machine  --channels=guix/channels.scm -- '
-                         'package --manifest=guix/manifest.scm '
-                         '--profile=$HOME/.config/guix/profiles/jami')])
+        print("Building the profile defined in 'guix/manifest.scm'...")
+        execute_script(['guix shell --manifest=guix/manifest.scm -- true'])
 
     else:
         print("Not yet implemented for current distribution (%s). Please continue with the --install instruction. Note: You may need to install some dependencies manually." %
@@ -421,11 +418,14 @@ def run_install(args):
         share_tarballs_args = []
         if 'TARBALLS' in os.environ:
             share_tarballs_args = ['--preserve=TARBALLS',
-                             f'--share={os.environ["TARBALLS"]}']
+                                   f'--share={os.environ["TARBALLS"]}']
+        else:
+            print('info: consider setting the TARBALLS environment variable '
+                  'to a stable writable location to avoid loosing '
+                  'cached tarballs')
         # Note: we must expose /gnu/store because /etc/ssl/certs
         # contains certs that are symlinks to store items.
-        command = ['guix', 'time-machine', '-C', 'guix/channels.scm', '--',
-                   'environment', '--manifest=guix/manifest.scm',
+        command = ['guix', 'shell', '--manifest=guix/manifest.scm',
                    '--expose=/gnu/store', '--expose=/etc/ssl/certs',
                    '--expose=/usr/bin/env',
                    '--container', '--network'] + share_tarballs_args \
@@ -727,13 +727,12 @@ def main():
                 print('FIXME: Qt fails loading QML modules due to '
                       'https://issues.guix.gnu.org/47655')
             # Relaunch this script, this time in a pure Guix environment.
-            guix_args = ['time-machine', '--channels=guix/channels.scm',
-                         '--', 'environment', '--pure',
+            guix_args = ['shell', '--pure',
                          # to allow pulseaudio to connect to an existing server
                          "-E", "XAUTHORITY", "-E", "XDG_RUNTIME_DIR",
                          '--manifest=guix/manifest.scm', '--']
             args = sys.argv + ['--distribution=guix']
-            print('Running in a guix environment spawned with: guix {}'
+            print('Running in a guix shell spawned with: guix {}'
                   .format(str.join(' ', guix_args + args)))
             os.execlp('guix', 'guix', *(guix_args + args))
         else:
diff --git a/guix/channels.scm b/guix/channels.scm
deleted file mode 100644
index b31ce8db..00000000
--- a/guix/channels.scm
+++ /dev/null
@@ -1,8 +0,0 @@
-(list (channel
-       (inherit %default-guix-channel)
-       ;; Use the staging branch for now, as it includes more debug
-       ;; symbols and fixes a propagation conflict between
-       ;; gdk-pixbuf+svg and gdk-pixbuf.
-       (branch "staging")
-       (commit
-        "42231bc15df441d6426dec57283aca9ae7a03fcf")))
diff --git a/guix/manifest.scm b/guix/manifest.scm
index cf000c3b..cc6e44c3 100644
--- a/guix/manifest.scm
+++ b/guix/manifest.scm
@@ -19,7 +19,7 @@
 ;;;
 ;;; It can also be invoked directly to spawn a development environment, like so:
 ;;;
-;;; $ guix environment --pure --manifest=guix/manifest.scm
+;;; $ guix shell --pure --manifest=guix/manifest.scm
 
 (specifications->manifest
  (list
-- 
GitLab