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.
This commit is contained in:
Ludovic Courtès 2021-11-07 22:32:18 +01:00
parent b999c80c2e
commit 859122e5ab
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 11 additions and 5 deletions

View File

@ -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))