diff options
author | Ludovic Courtès <ludo@gnu.org> | 2018-03-27 14:16:19 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2018-03-27 14:51:44 +0200 |
commit | 8980eea5ab6f89e7649d9abf0be2a9d49156f7d2 (patch) | |
tree | 4f9788709a42f67bd11117b4b91660454b128eca | |
parent | b06a70e05dc6252a3ecb28db5898de7ebc110973 (diff) | |
download | guix-8980eea5ab6f89e7649d9abf0be2a9d49156f7d2.tar.gz |
guix gc: Add '--derivers'.
* guix/scripts/gc.scm (show-help, %options): Add '--derivers'. (guix-gc): Handle 'list-derivers'. * tests/guix-gc.sh: Add test. * doc/guix.texi (Invoking guix gc): Document it.
-rw-r--r-- | doc/guix.texi | 18 | ||||
-rw-r--r-- | guix/scripts/gc.scm | 10 | ||||
-rw-r--r-- | tests/guix-gc.sh | 5 |
3 files changed, 31 insertions, 2 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index 2204285516..c37a87d5a1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2642,6 +2642,24 @@ of these, recursively. In other words, the returned list is the of an element. @xref{Invoking guix graph}, for a tool to visualize the graph of references. +@item --derivers +@cindex derivation +Return the derivation(s) leading to the given store items +(@pxref{Derivations}). + +For example, this command: + +@example +guix gc --derivers `guix package -I ^emacs$ | cut -f4` +@end example + +@noindent +returns the @file{.drv} file(s) leading to the @code{emacs} package +installed in your profile. + +Note that there may be zero matching @file{.drv} files, for instance +because these files have been garbage-collected. There can also be more +than one matching @file{.drv} due to fixed-output derivations. @end table Lastly, the following options allow you to check the integrity of the diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm index a31d2236b0..e4ed7227ff 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 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012, 2013, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -61,6 +61,8 @@ Invoke the garbage collector.\n")) -R, --requisites list the requisites of PATHS")) (display (G_ " --referrers list the referrers of PATHS")) + (display (G_ " + --derivers list the derivers of PATHS")) (newline) (display (G_ " --verify[=OPTS] verify the integrity of the store; OPTS is a @@ -153,6 +155,10 @@ Invoke the garbage collector.\n")) (lambda (opt name arg result) (alist-cons 'action 'list-referrers (alist-delete 'action result)))) + (option '("derivers") #f #f + (lambda (opt name arg result) + (alist-cons 'action 'list-derivers + (alist-delete 'action result)))) (option '("list-failures") #f #f (lambda (opt name arg result) (alist-cons 'action 'list-failures @@ -241,6 +247,8 @@ Invoke the garbage collector.\n")) (requisites store (list item))))) ((list-referrers) (list-relatives referrers)) + ((list-derivers) + (list-relatives valid-derivers)) ((optimize) (assert-no-extra-arguments) (optimize-store store)) diff --git a/tests/guix-gc.sh b/tests/guix-gc.sh index efbc7e759c..ef2d9543b7 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 Ludovic Courtès <ludo@gnu.org> +# Copyright © 2013, 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org> # # This file is part of GNU Guix. # @@ -54,6 +54,9 @@ guix gc --references "$out/bin/guile" if guix gc --references /dev/null; then false; else true; fi +# Check derivers. +guix gc --derivers "$out" | grep "$drv" + # Add then reclaim a .drv file. drv="`guix build idutils -d`" test -f "$drv" |