* [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots'
@ 2019-04-06 21:26 Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 1/5] Add (guix store roots) Ludovic Courtès
2019-04-09 19:01 ` [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots' Björn Höfling
0 siblings, 2 replies; 10+ messages in thread
From: Ludovic Courtès @ 2019-04-06 21:26 UTC (permalink / raw)
To: 35176
Hello Guix!
This patch series is mostly about making it easier to free space:
‘guix gc --delete-generations’ deletes old generations of all the
user’s profiles prior to collecting garbage.
For consistency, ‘--delete-generations’ is aliased with ‘-d’, so
‘-d’ is repurposed (until now it was an alias for ‘--delete’).
Thoughts?
Ludo’.
Ludovic Courtès (5):
Add (guix store roots).
guix gc: Add '--list-roots'.
profiles: Add 'generation-profile'.
guix gc: Add '--delete-generations'.
scripts: GC hint suggests 'guix gc -d 1m'.
Makefile.am | 6 ++-
doc/guix.texi | 22 +++++++-
guix/profiles.scm | 15 ++++++
guix/scripts.scm | 10 ++--
guix/scripts/gc.scm | 66 +++++++++++++++++++++--
guix/store/roots.scm | 120 ++++++++++++++++++++++++++++++++++++++++++
tests/guix-gc.sh | 6 ++-
tests/store-roots.scm | 53 +++++++++++++++++++
8 files changed, 282 insertions(+), 16 deletions(-)
create mode 100644 guix/store/roots.scm
create mode 100644 tests/store-roots.scm
--
2.21.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug#35176] [PATCH 1/5] Add (guix store roots).
2019-04-06 21:26 [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots' Ludovic Courtès
@ 2019-04-06 21:31 ` Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 2/5] guix gc: Add '--list-roots' Ludovic Courtès
` (3 more replies)
2019-04-09 19:01 ` [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots' Björn Höfling
1 sibling, 4 replies; 10+ messages in thread
From: Ludovic Courtès @ 2019-04-06 21:31 UTC (permalink / raw)
To: 35176
* guix/store/roots.scm, tests/store-roots.scm: New files.
* Makefile.am (STORE_MODULES): Add guix/store/roots.scm.
(SCM_TESTS): Add tests/store-roots.scm.
---
Makefile.am | 6 ++-
guix/store/roots.scm | 120 ++++++++++++++++++++++++++++++++++++++++++
tests/store-roots.scm | 53 +++++++++++++++++++
3 files changed, 177 insertions(+), 2 deletions(-)
create mode 100644 guix/store/roots.scm
create mode 100644 tests/store-roots.scm
diff --git a/Makefile.am b/Makefile.am
index c331da7267..18889bf89e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -276,7 +276,8 @@ endif BUILD_DAEMON_OFFLOAD
# Scheme implementation of the build daemon and related functionality.
STORE_MODULES = \
guix/store/database.scm \
- guix/store/deduplication.scm
+ guix/store/deduplication.scm \
+ guix/store/roots.scm
MODULES += $(STORE_MODULES)
@@ -407,7 +408,8 @@ SCM_TESTS = \
tests/pypi.scm \
tests/import-utils.scm \
tests/store-database.scm \
- tests/store-deduplication.scm
+ tests/store-deduplication.scm \
+ tests/store-roots.scm
SH_TESTS = \
tests/guix-build.sh \
diff --git a/guix/store/roots.scm b/guix/store/roots.scm
new file mode 100644
index 0000000000..4f23ae34e8
--- /dev/null
+++ b/guix/store/roots.scm
@@ -0,0 +1,120 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix store roots)
+ #:use-module (guix config)
+ #:use-module ((guix store) #:select (store-path? %gc-roots-directory))
+ #:use-module (guix sets)
+ #:use-module (guix build syscalls)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-11)
+ #:use-module (srfi srfi-26)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
+ #:re-export (%gc-roots-directory)
+ #:export (gc-roots
+ user-owned?))
+
+;;; Commentary:
+;;;
+;;; This module provides tools to list and access garbage collector roots ("GC
+;;; roots").
+;;;
+;;; Code:
+
+(define %profile-directory
+ ;; Directory where user profiles are stored.
+ ;; XXX: This is redundant with the definition in (guix profiles) and not
+ ;; entirely needed since in practice /var/guix/gcroots/profiles links to
+ ;; it.
+ (string-append %state-directory "/profiles"))
+
+(define (gc-roots)
+ "Return the list of garbage collector roots (\"GC roots\"). This includes
+\"regular\" roots fount in %GC-ROOTS-DIRECTORY as well as indirect roots that
+are user-controlled symlinks stored anywhere on the file system."
+ (define (regular? file)
+ (match file
+ (((or "." "..") . _) #f)
+ (_ #t)))
+
+ (define (file-type=? type)
+ (match-lambda
+ ((file . properties)
+ (match (assq-ref properties 'type)
+ ('unknown
+ (let ((stat (lstat file)))
+ (eq? type (stat:type stat))))
+ (actual-type
+ (eq? type actual-type))))))
+
+ (define directory?
+ (file-type=? 'directory))
+
+ (define symlink?
+ (file-type=? 'symlink))
+
+ (define canonical-root
+ (match-lambda
+ ((file . properties)
+ (let ((target (readlink file)))
+ (cond ((store-path? target)
+ ;; Regular root: FILE points to the store.
+ file)
+
+ ;; Indirect root: FILE points to a user-controlled file outside
+ ;; the store.
+ ((string-prefix? "/" target)
+ target)
+ (else
+ (string-append (dirname file) "/" target)))))))
+
+ (let loop ((directories (list %gc-roots-directory
+ %profile-directory))
+ (roots '())
+ (visited (set)))
+ (match directories
+ (()
+ roots)
+ ((directory . rest)
+ (if (set-contains? visited directory)
+ (loop rest roots visited)
+ (let*-values (((scope)
+ (cut string-append directory "/" <>))
+ ((sub-directories files)
+ (partition directory?
+ (map (match-lambda
+ ((file . properties)
+ (cons (scope file) properties)))
+ (scandir* directory regular?)))))
+ (loop (append rest (map first sub-directories))
+ (append (map canonical-root (filter symlink? files))
+ roots)
+ (set-insert directory visited))))))))
+
+(define* (user-owned? root #:optional (uid (getuid)))
+ "Return true if ROOT exists and is owned by UID, false otherwise."
+ ;; If ROOT is an indirect root, then perhaps it no longer exists. Thus,
+ ;; catch 'system-error' exceptions.
+ (catch 'system-error
+ (lambda ()
+ (define stat
+ (lstat root))
+
+ (= (stat:uid stat) uid))
+ (const #f)))
diff --git a/tests/store-roots.scm b/tests/store-roots.scm
new file mode 100644
index 0000000000..5bcf1bc87e
--- /dev/null
+++ b/tests/store-roots.scm
@@ -0,0 +1,53 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (test-store-deduplication)
+ #:use-module (guix tests)
+ #:use-module (guix store)
+ #:use-module (guix store roots)
+ #:use-module ((guix utils) #:select (call-with-temporary-directory))
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-64))
+
+(define %store
+ (open-connection))
+
+(test-begin "store-roots")
+
+(test-assert "gc-roots, regular root"
+ (let* ((item (add-text-to-store %store "something"
+ (random-text)))
+ (root (string-append %gc-roots-directory "/test-gc-root")))
+ (symlink item root)
+ (let ((result (member root (gc-roots))))
+ (delete-file root)
+ result)))
+
+(test-assert "gc-roots, indirect root"
+ (call-with-temporary-directory
+ (lambda (directory)
+ (let* ((item (add-text-to-store %store "something"
+ (random-text)))
+ (root (string-append directory "/gc-root")))
+ (symlink item root)
+ (add-indirect-root %store root)
+ (let ((result (member root (gc-roots))))
+ (delete-file root)
+ result)))))
+
+(test-end "store-roots")
--
2.21.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [bug#35176] [PATCH 2/5] guix gc: Add '--list-roots'.
2019-04-06 21:31 ` [bug#35176] [PATCH 1/5] Add (guix store roots) Ludovic Courtès
@ 2019-04-06 21:31 ` Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 3/5] profiles: Add 'generation-profile' Ludovic Courtès
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2019-04-06 21:31 UTC (permalink / raw)
To: 35176
* guix/scripts/gc.scm (show-help, %options): Add '--list-roots'.
(guix-gc)[list-roots]: New procedure.
Handle '--list-roots'.
* tests/guix-gc.sh: Test it.
* doc/guix.texi (Invoking guix gc): Document it.
---
doc/guix.texi | 6 +++++-
guix/scripts/gc.scm | 21 ++++++++++++++++++++-
tests/guix-gc.sh | 6 ++++--
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 1c82579afc..75ab2fe4f5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3385,7 +3385,7 @@ deleted. The set of garbage collector roots (``GC roots'' for short)
includes default user profiles; by default, the symlinks under
@file{/var/guix/gcroots} represent these GC roots. New GC roots can be
added with @command{guix build --root}, for example (@pxref{Invoking
-guix build}).
+guix build}). The @command{guix gc --list-roots} command lists them.
Prior to running @code{guix gc --collect-garbage} to make space, it is
often useful to remove old generations from user profiles; that way, old
@@ -3451,6 +3451,10 @@ This prints nothing unless the daemon was started with
@option{--cache-failures} (@pxref{Invoking guix-daemon,
@option{--cache-failures}}).
+@item --list-roots
+List the GC roots owned by the user; when run as root, list @emph{all} the GC
+roots.
+
@item --clear-failures
Remove the specified store items from the failed-build cache.
diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm
index 6f37b767ff..2606e20deb 100644
--- a/guix/scripts/gc.scm
+++ b/guix/scripts/gc.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -20,6 +20,7 @@
#:use-module (guix ui)
#:use-module (guix scripts)
#:use-module (guix store)
+ #:use-module (guix store roots)
#:autoload (guix build syscalls) (free-disk-space)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
@@ -48,6 +49,8 @@ Invoke the garbage collector.\n"))
-F, --free-space=FREE attempt to reach FREE available space in the store"))
(display (G_ "
-d, --delete attempt to delete PATHS"))
+ (display (G_ "
+ --list-roots list the user's garbage collector roots"))
(display (G_ "
--optimize optimize the store by deduplicating identical files"))
(display (G_ "
@@ -135,6 +138,10 @@ Invoke the garbage collector.\n"))
(alist-cons 'verify-options options
(alist-delete 'action
result))))))
+ (option '("list-roots") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'action 'list-roots
+ (alist-delete 'action result))))
(option '("list-dead") #f #f
(lambda (opt name arg result)
(alist-cons 'action 'list-dead
@@ -205,6 +212,15 @@ Invoke the garbage collector.\n"))
(info (G_ "freeing ~h MiBs~%") (/ to-free 1024. 1024.))
(collect-garbage store to-free)))))
+ (define (list-roots)
+ ;; List all the user-owned GC roots.
+ (let ((roots (filter (if (zero? (getuid)) (const #t) user-owned?)
+ (gc-roots))))
+ (for-each (lambda (root)
+ (display root)
+ (newline))
+ roots)))
+
(with-error-handling
(let* ((opts (parse-options))
(store (open-connection))
@@ -238,6 +254,9 @@ Invoke the garbage collector.\n"))
(else
(let-values (((paths freed) (collect-garbage store)))
(info (G_ "freed ~h MiBs~%") (/ freed 1024. 1024.)))))))
+ ((list-roots)
+ (assert-no-extra-arguments)
+ (list-roots))
((delete)
(delete-paths store (map direct-store-path paths)))
((list-references)
diff --git a/tests/guix-gc.sh b/tests/guix-gc.sh
index ef2d9543b7..8284287730 100644
--- a/tests/guix-gc.sh
+++ b/tests/guix-gc.sh
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
-# Copyright © 2013, 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2013, 2015, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of GNU Guix.
#
@@ -34,7 +34,7 @@ unset drv
unset out
# For some operations, passing extra arguments is an error.
-for option in "" "-C 500M" "--verify" "--optimize"
+for option in "" "-C 500M" "--verify" "--optimize" "--list-roots"
do
if guix gc $option whatever; then false; else true; fi
done
@@ -69,6 +69,8 @@ guix gc --delete "$drv"
drv="`guix build --root=guix-gc-root lsh -d`"
test -f "$drv" && test -L guix-gc-root
+guix gc --list-roots | grep "$PWD/guix-gc-root"
+
guix gc --list-live | grep "$drv"
if guix gc --delete "$drv";
then false; else true; fi
--
2.21.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [bug#35176] [PATCH 3/5] profiles: Add 'generation-profile'.
2019-04-06 21:31 ` [bug#35176] [PATCH 1/5] Add (guix store roots) Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 2/5] guix gc: Add '--list-roots' Ludovic Courtès
@ 2019-04-06 21:31 ` Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 4/5] guix gc: Add '--delete-generations' Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 5/5] scripts: GC hint suggests 'guix gc -d 1m' Ludovic Courtès
3 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2019-04-06 21:31 UTC (permalink / raw)
To: 35176
* guix/profiles.scm (%profile-generation-rx): New variable.
(generation-profile): New procedure.
---
guix/profiles.scm | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 6564526aee..dfc9ba1ca0 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -118,6 +118,7 @@
profile-search-paths
generation-number
+ generation-profile
generation-numbers
profile-generations
relative-generation-spec->number
@@ -1552,6 +1553,20 @@ already effective."
(compose string->number (cut match:substring <> 1)))
0))
+(define %profile-generation-rx
+ ;; Regexp that matches profile generation.
+ (make-regexp "(.*)-([0-9]+)-link$"))
+
+(define (generation-profile file)
+ "If FILE is a profile generation GC root such as \"guix-profile-42-link\",
+return its corresponding profile---e.g., \"guix-profile\". Otherwise return
+#f."
+ (match (regexp-exec %profile-generation-rx file)
+ (#f #f)
+ (m (let ((profile (match:substring m 1)))
+ (and (file-exists? (string-append profile "/manifest"))
+ profile)))))
+
(define (generation-numbers profile)
"Return the sorted list of generation numbers of PROFILE, or '(0) if no
former profiles were found."
--
2.21.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [bug#35176] [PATCH 4/5] guix gc: Add '--delete-generations'.
2019-04-06 21:31 ` [bug#35176] [PATCH 1/5] Add (guix store roots) Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 2/5] guix gc: Add '--list-roots' Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 3/5] profiles: Add 'generation-profile' Ludovic Courtès
@ 2019-04-06 21:31 ` Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 5/5] scripts: GC hint suggests 'guix gc -d 1m' Ludovic Courtès
3 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2019-04-06 21:31 UTC (permalink / raw)
To: 35176
* guix/scripts/gc.scm (show-help, %options): Add
'--delete-generations'. Change '--delete' shorthand to '-d'.
(delete-old-generations): New procedure.
(guix-gc)[delete-generations]: New procedure.
Call it when ACTION is 'collect-garbage' and OPTS contains
'delete-generations.
* doc/guix.texi (Invoking guix gc): Document it.
---
doc/guix.texi | 16 +++++++++++++++-
guix/scripts/gc.scm | 45 +++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 58 insertions(+), 3 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 75ab2fe4f5..e1b30f0ab1 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3438,8 +3438,22 @@ as @code{500MiB}, as described above.
When @var{free} or more is already available in @file{/gnu/store}, do
nothing and exit immediately.
+@item --delete-generations[=@var{duration}]
+@itemx -d [@var{duration}]
+Before starting the garbage collection process, delete all the generations
+older than @var{duration}, for all the user profiles; when run as root, this
+applies to all the profiles @emph{of all the users}.
+
+For example, this command deletes all the generations of all your profiles
+that are older than 2 months (except generations that are current), and then
+proceeds to free space until at least 10 GiB are available:
+
+@example
+guix gc -d 2m -F 10G
+@end example
+
@item --delete
-@itemx -d
+@itemx -D
Attempt to delete all the store files and directories specified as
arguments. This fails if some of the files are not in the store, or if
they are still live.
diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm
index 2606e20deb..635a031645 100644
--- a/guix/scripts/gc.scm
+++ b/guix/scripts/gc.scm
@@ -22,6 +22,8 @@
#:use-module (guix store)
#:use-module (guix store roots)
#:autoload (guix build syscalls) (free-disk-space)
+ #:autoload (guix profiles) (generation-profile)
+ #:autoload (guix scripts package) (delete-generations)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
#:use-module (srfi srfi-1)
@@ -48,7 +50,10 @@ Invoke the garbage collector.\n"))
(display (G_ "
-F, --free-space=FREE attempt to reach FREE available space in the store"))
(display (G_ "
- -d, --delete attempt to delete PATHS"))
+ -d, --delete-generations[=PATTERN]
+ delete profile generations matching PATTERN"))
+ (display (G_ "
+ -D, --delete attempt to delete PATHS"))
(display (G_ "
--list-roots list the user's garbage collector roots"))
(display (G_ "
@@ -98,6 +103,16 @@ Invoke the garbage collector.\n"))
lst)
'()))))
+(define (delete-old-generations store profile pattern)
+ "Remove the generations of PROFILE that match PATTERN, a duration pattern.
+Do nothing if none matches."
+ (let* ((current (generation-number profile))
+ (numbers (matching-generations pattern profile
+ #:duration-relation >)))
+
+ ;; Make sure we don't inadvertently remove the current generation.
+ (delete-generations store profile (delv current numbers))))
+
(define %options
;; Specification of the command-line options.
(list (option '(#\h "help") #f #f
@@ -123,10 +138,24 @@ Invoke the garbage collector.\n"))
(option '(#\F "free-space") #t #f
(lambda (opt name arg result)
(alist-cons 'free-space (size->number arg) result)))
- (option '(#\d "delete") #f #f
+ (option '(#\D "delete") #f #f ;used to be '-d' (lower case)
(lambda (opt name arg result)
(alist-cons 'action 'delete
(alist-delete 'action result))))
+ (option '(#\d "delete-generations") #f #t
+ (lambda (opt name arg result)
+ (if (and arg (store-path? arg))
+ (begin
+ (warning (G_ "'-d' as an alias for '--delete' \
+is deprecated; use '-D'~%"))
+ (alist-cons 'action 'delete
+ (alist-delete 'action result)))
+ (begin
+ (when (and arg (not (string->duration arg)))
+ (leave (G_ "~s does not denote a duration~%")
+ arg))
+ (alist-cons 'delete-generations (or arg "")
+ result)))))
(option '("optimize") #f #f
(lambda (opt name arg result)
(alist-cons 'action 'optimize
@@ -212,6 +241,14 @@ Invoke the garbage collector.\n"))
(info (G_ "freeing ~h MiBs~%") (/ to-free 1024. 1024.))
(collect-garbage store to-free)))))
+ (define (delete-generations store pattern)
+ ;; Delete the generations matching PATTERN of all the user's profiles.
+ (let ((profiles (delete-duplicates
+ (filter-map generation-profile (gc-roots)))))
+ (for-each (lambda (profile)
+ (delete-old-generations store profile pattern))
+ profiles)))
+
(define (list-roots)
;; List all the user-owned GC roots.
(let ((roots (filter (if (zero? (getuid)) (const #t) user-owned?)
@@ -245,6 +282,10 @@ Invoke the garbage collector.\n"))
(assert-no-extra-arguments)
(let ((min-freed (assoc-ref opts 'min-freed))
(free-space (assoc-ref opts 'free-space)))
+ (match (assoc-ref opts 'delete-generations)
+ (#f #t)
+ ((? string? pattern)
+ (delete-generations store pattern)))
(cond
(free-space
(ensure-free-space store free-space))
--
2.21.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [bug#35176] [PATCH 5/5] scripts: GC hint suggests 'guix gc -d 1m'.
2019-04-06 21:31 ` [bug#35176] [PATCH 1/5] Add (guix store roots) Ludovic Courtès
` (2 preceding siblings ...)
2019-04-06 21:31 ` [bug#35176] [PATCH 4/5] guix gc: Add '--delete-generations' Ludovic Courtès
@ 2019-04-06 21:31 ` Ludovic Courtès
3 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2019-04-06 21:31 UTC (permalink / raw)
To: 35176
* guix/scripts.scm (warn-about-disk-space): Suggest 'guix gc -d'.
---
guix/scripts.scm | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/guix/scripts.scm b/guix/scripts.scm
index e4b11d295d..77cbf12350 100644
--- a/guix/scripts.scm
+++ b/guix/scripts.scm
@@ -201,16 +201,12 @@ available."
(when (< ratio threshold)
(warning (G_ "only ~,1f% of free space available on ~a~%")
(* ratio 100) (%store-prefix))
- (if profile
- (display-hint (format #f (G_ "Consider deleting old profile
+ (display-hint (format #f (G_ "Consider deleting old profile
generations and collecting garbage, along these lines:
@example
-guix package -p ~s --delete-generations=1m
-guix gc
+guix gc --delete-generations=1m
@end example\n")
- profile))
- (display-hint (G_ "Consider running @command{guix gc} to free
-space."))))))
+ profile)))))
;;; scripts.scm ends here
--
2.21.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots'
2019-04-06 21:26 [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots' Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 1/5] Add (guix store roots) Ludovic Courtès
@ 2019-04-09 19:01 ` Björn Höfling
2019-04-09 20:02 ` Ludovic Courtès
1 sibling, 1 reply; 10+ messages in thread
From: Björn Höfling @ 2019-04-09 19:01 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 35176
[-- Attachment #1: Type: text/plain, Size: 864 bytes --]
On Sat, 6 Apr 2019 23:26:56 +0200
Ludovic Courtès <ludo@gnu.org> wrote:
> Hello Guix!
>
> This patch series is mostly about making it easier to free space:
> ‘guix gc --delete-generations’ deletes old generations of all the
> user’s profiles prior to collecting garbage.
>
> For consistency, ‘--delete-generations’ is aliased with ‘-d’, so
> ‘-d’ is repurposed (until now it was an alias for ‘--delete’).
I'm using regularly `guix gc -d /gnu/store/...` and I'm a bit concerned
about re/abusing this existing parameter. First I like the simple '-d'
to delete a store path. Second, how big is the chance I could
accidentally delete (all) older generations of my profiles? I really
like to keep them for a long time, until my disk is near-full, and it
looks like gc-roots are no longer a safe way to keep them?
Björn
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots'
2019-04-09 19:01 ` [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots' Björn Höfling
@ 2019-04-09 20:02 ` Ludovic Courtès
2019-04-09 20:58 ` Björn Höfling
0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2019-04-09 20:02 UTC (permalink / raw)
To: Björn Höfling; +Cc: 35176
Hi Björn,
Björn Höfling <bjoern.hoefling@bjoernhoefling.de> skribis:
> On Sat, 6 Apr 2019 23:26:56 +0200
> Ludovic Courtès <ludo@gnu.org> wrote:
>
>> Hello Guix!
>>
>> This patch series is mostly about making it easier to free space:
>> ‘guix gc --delete-generations’ deletes old generations of all the
>> user’s profiles prior to collecting garbage.
>>
>> For consistency, ‘--delete-generations’ is aliased with ‘-d’, so
>> ‘-d’ is repurposed (until now it was an alias for ‘--delete’).
>
> I'm using regularly `guix gc -d /gnu/store/...` and I'm a bit concerned
> about re/abusing this existing parameter. First I like the simple '-d'
> to delete a store path.
It still works actually, it just prints a warning stating that it’s
deprecated. (I’m used to ‘-d’ as well but I’m confident my muscle
memory will get used to ‘-D’. :-))
> Second, how big is the chance I could accidentally delete (all) older
> generations of my profiles?
It’s unlikely because if you do “guix gc -d /gnu/store/…”, it still
behaves like before.
Does it address your concern?
> I really like to keep them for a long time, until my disk is
> near-full, and it looks like gc-roots are no longer a safe way to keep
> them?
It’s still safe, I do the same as you! The intent is just to provide a
simple way to “remove old stuff” (currently you have to know that you
have at least two profiles, and then run ‘guix package -p … -d’, which
isn’t very convenient when all you want is to free some space.)
Thanks for your feedback!
Ludo’.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots'
2019-04-09 20:02 ` Ludovic Courtès
@ 2019-04-09 20:58 ` Björn Höfling
2019-04-10 15:19 ` bug#35176: " Ludovic Courtès
0 siblings, 1 reply; 10+ messages in thread
From: Björn Höfling @ 2019-04-09 20:58 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 35176
[-- Attachment #1: Type: text/plain, Size: 401 bytes --]
On Tue, 09 Apr 2019 22:02:07 +0200
Ludovic Courtès <ludo@gnu.org> wrote:
> Hi Björn,
>
> > Second, how big is the chance I could accidentally delete (all)
> > older generations of my profiles?
>
> It’s unlikely because if you do “guix gc -d /gnu/store/…”, it still
> behaves like before.
>
> Does it address your concern?
OK, convinced. Thanks for clarifying.
Björn
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#35176: [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots'
2019-04-09 20:58 ` Björn Höfling
@ 2019-04-10 15:19 ` Ludovic Courtès
0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2019-04-10 15:19 UTC (permalink / raw)
To: Björn Höfling; +Cc: 35176-done
Hello,
Björn Höfling <bjoern.hoefling@bjoernhoefling.de> skribis:
> On Tue, 09 Apr 2019 22:02:07 +0200
> Ludovic Courtès <ludo@gnu.org> wrote:
>
>> Hi Björn,
>>
>> > Second, how big is the chance I could accidentally delete (all)
>> > older generations of my profiles?
>>
>> It’s unlikely because if you do “guix gc -d /gnu/store/…”, it still
>> behaves like before.
>>
>> Does it address your concern?
>
> OK, convinced. Thanks for clarifying.
Cool, I’ve just pushed the patch series.
I noticed that the compatibility trick for ‘-d’ would ignore its
argument (thus it wouldn’t delete anything at all), so I’ve fixed that.
Thank you!
Ludo’.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-04-10 15:20 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-06 21:26 [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots' Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 1/5] Add (guix store roots) Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 2/5] guix gc: Add '--list-roots' Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 3/5] profiles: Add 'generation-profile' Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 4/5] guix gc: Add '--delete-generations' Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 5/5] scripts: GC hint suggests 'guix gc -d 1m' Ludovic Courtès
2019-04-09 19:01 ` [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots' Björn Höfling
2019-04-09 20:02 ` Ludovic Courtès
2019-04-09 20:58 ` Björn Höfling
2019-04-10 15:19 ` bug#35176: " Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).