summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-11-07 22:32:18 +0100
committerLudovic Courtès <ludo@gnu.org>2021-11-07 23:10:41 +0100
commit859122e5abeddfdfbe419713e19ed573ed2d5d78 (patch)
tree0007ea9f56a4cc922a11b0422194e3b924ec6779 /guix
parentb999c80c2e71bd4b3f26a18a321b7e7e7b580103 (diff)
shell: Actually clean up the profile cache.
Previously, most actions would leave the cache as-is because 'guix-environment*' would indirectly call 'exit', and thus its continuation was never reached. * guix/scripts/shell.scm (guix-shell): Move call to 'maybe-remove-expired-cache-entries' to EXIT-HOOK.
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/shell.scm16
1 files changed, 11 insertions, 5 deletions
diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm
index 5749485a44..bd62803cb1 100644
--- a/guix/scripts/shell.scm
+++ b/guix/scripts/shell.scm
@@ -387,8 +387,14 @@ echo ~a >> ~a
(display-hint (G_ "Consider passing the @option{--check} option once
to make sure your shell does not clobber environment variables."))) )
- (let ((result (guix-environment* opts)))
- (maybe-remove-expired-cache-entries (%profile-cache-directory)
- cache-entries
- #:entry-expiration entry-expiration)
- result))
+ ;; Clean the cache in EXIT-HOOK so that (1) it happens after potential use
+ ;; of cached profiles, and (2) cleanup actually happens, even when
+ ;; 'guix-environment*' calls 'exit'.
+ (add-hook! exit-hook
+ (lambda _
+ (maybe-remove-expired-cache-entries
+ (%profile-cache-directory)
+ cache-entries
+ #:entry-expiration entry-expiration)))
+
+ (guix-environment* opts))