guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

guix system delete-generations -- advice?


From: Thomas Danckaert
Subject: guix system delete-generations -- advice?
Date: Tue, 14 Feb 2017 21:04:45 +0100 (CET)

Hi Guix,
I added `guix system delete-generations' in my git checkout, WIP patch
attached.  I had started to adapt the corresponding code from `guix
package delete-generations', but then realized that
`delete-matching-generations` from (guix scripts package) contains
everything that's needed (could it be moved to (guix ui)?).
One thing I'm not satisfied with is this: `reinstall-grub' does not
reproduce custom grub menu entries added in the (grub-configuration)
section of a system's bootloader configuration.  So users with a
dual boot system, who run =?utf-8?B?4oCcZ3VpeA==?= system
 =?utf-8?B?ZGVsZXRlLWdlbmVyYXRpb25z4oCd?= will lose
their non-GuixSD grub entries, until they run =?utf-8?B?4oCcZ3VpeA==?=
 system reconfigure
...” again.  The existing =?utf-8?B?4oCcZ3VpeA==?= system
 =?utf-8?B?c3dpdGNoLWdlbmVyYXRpb27igJ0=?= has the same problem.
Is there a way to retrieve the current custom grub entries, other than
 providing a system configuration, or, I hardly dare say it out loud,
 parsing grub.cfg? How could this be improved?
cheers,
Thomas
ps I also noticed that passing an empty string ("") as a command line
 argument to many guix commands returns a guile backtrace, e.g. guix system
 list-generations "". I find this a little messy, or is it a feature?
Mime-Version: 1.0
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0001-WIP-guix-system-delete-generations.patch"

>From 9dc5a9bfee970e24fd2e65615220f80fb8436c6b Mon Sep 17 00:00:00 2001
From: Thomas Danckaert <address@hidden>
Date: Sat, 11 Feb 2017 18:32:42 +0100
Subject: [PATCH] WIP guix system delete-generations.

TODO: how to properly generate grub.cfg?
---
 guix/scripts/package.scm |  2 +-
 guix/scripts/system.scm  | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 9e5b7f3c7..49233708f 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -152,7 +152,7 @@ GENERATIONS is a list of generation numbers."
   (for-each (cut delete-generation* store profile <>)
             generations))
 
-(define (delete-matching-generations store profile pattern)
+(define-public (delete-matching-generations store profile pattern)
   "Delete from PROFILE all the generations matching PATTERN.  PATTERN must be
 a string denoting a set of generations: the empty list means \"all generations
 but the current one\", a number designates a generation, and other patterns
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 144a7fd37..a4e219d70 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -31,6 +31,7 @@
   #:use-module (guix records)
   #:use-module (guix profiles)
   #:use-module (guix scripts)
+  #:use-module ((guix scripts package) #:prefix package:)
   #:use-module (guix scripts build)
   #:use-module (guix graph)
   #:use-module (guix scripts graph)
@@ -548,6 +549,12 @@ PATTERN, a string.  When PATTERN is #f, display all the 
system generations."
         (else
          (leave (_ "invalid syntax: ~a~%") pattern))))
 
+(define* (delete-generations store pattern #:optional (profile 
%system-profile))
+  "Delete all system generations matching PATTERN, a string, but never delete
+the current generation.  Regenerate grub.cfg if we have deleted something."
+  (package:delete-matching-generations store profile pattern)
+  (reinstall-grub store (generation-number profile))) ; TODO: this removes 
custom grub menu entries.
+
 
 ;;;
 ;;; Action.
@@ -712,6 +719,8 @@ Some ACTIONS support additional ARGS.\n"))
   (display (_ "\
    list-generations list the system generations\n"))
   (display (_ "\
+   delete-generations delete system generations\n"))
+  (display (_ "\
    build            build the operating system without installing anything\n"))
   (display (_ "\
    container        build a container that shares the host's store\n"))
@@ -880,6 +889,12 @@ argument list and OPTS is the option alist."
        (list-generations pattern)))
     ;; The following commands need to use the store, but they do not need an
     ;; operating system configuration file.
+    ((delete-generations)
+     (let ((pattern (match args
+                      ((pattern) pattern)
+                      (x (leave (_ "wrong number of arguments~%"))))))
+       (with-store store
+         (delete-generations store pattern))))
     ((switch-generation)
      (let ((pattern (match args
                       ((pattern) pattern)
@@ -906,8 +921,8 @@ argument list and OPTS is the option alist."
         (let ((action (string->symbol arg)))
           (case action
             ((build container vm vm-image disk-image reconfigure init
-              extension-graph shepherd-graph list-generations roll-back
-              switch-generation)
+              extension-graph shepherd-graph list-generations 
delete-generations
+              roll-back switch-generation)
              (alist-cons 'action action result))
             (else (leave (_ "~a: unknown action~%") action))))))
 
-- 
2.11.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]