summary refs log tree commit diff
path: root/gnu/system/vm.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-09-24 22:40:33 +0200
committerLudovic Courtès <ludo@gnu.org>2013-09-24 23:40:50 +0200
commit30f25b033c7fbcdcc7050b1655fc832252255c7e (patch)
tree8fdfdf73d4cd5fdf6812a4fb78269a5ac35991f0 /gnu/system/vm.scm
parent2d195e677562f34e00137561911a5b84796059f6 (diff)
downloadguix-30f25b033c7fbcdcc7050b1655fc832252255c7e.tar.gz
gnu: vm: Initialize the image's store.
* gnu/system/vm.scm (qemu-image): Add 'initialize-store?' keyword
  parameter.  Use 'guix-register' when INITIALIZE-STORE? is true.
  (system-qemu-image): Pass #:initialize-store? #t.
Diffstat (limited to 'gnu/system/vm.scm')
-rw-r--r--gnu/system/vm.scm23
1 files changed, 21 insertions, 2 deletions
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index df55f7c94e..a864ab3de3 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -31,6 +31,7 @@
   #:use-module (gnu packages grub)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages linux-initrd)
+  #:use-module (gnu packages package-management)
   #:use-module ((gnu packages make-bootstrap)
                 #:select (%guile-static-stripped))
   #:use-module (gnu packages system)
@@ -191,6 +192,7 @@ made available under the /xchg CIFS share."
                      (system (%current-system))
                      (disk-image-size (* 100 (expt 2 20)))
                      grub-configuration
+                     (initialize-store? #f)
                      (populate #f)
                      (inputs '())
                      (inputs-to-copy '()))
@@ -199,7 +201,8 @@ disk image, with a GRUB installation that uses GRUB-CONFIGURATION as its
 configuration file.
 
 INPUTS-TO-COPY is a list of inputs (as for packages) whose closure is copied
-into the image being built.
+into the image being built.  When INITIALIZE-STORE? is true, initialize the
+store database in the image so that Guix can be used in the image.
 
 When POPULATE is true, it must be the store file name of a Guile script to run
 in the disk image partition once it has been populated with INPUTS-TO-COPY.
@@ -298,6 +301,20 @@ It can be used to provide additional files, such as /etc files."
                       ;; Populate /dev.
                       (make-essential-device-nodes #:root "/fs")
 
+                      ;; Optionally, register the inputs in the image's store.
+                      (let* ((guix     (assoc-ref %build-inputs "guix"))
+                             (register (string-append guix
+                                                      "/sbin/guix-register")))
+                        ,@(if initialize-store?
+                              (match inputs-to-copy
+                                (((graph-files . _) ...)
+                                 (map (lambda (closure)
+                                        `(system* register "--prefix" "/fs"
+                                                  ,(string-append "/xchg/"
+                                                                  closure)))
+                                      graph-files)))
+                              '(#f)))
+
                       (and=> (assoc-ref %build-inputs "populate")
                              (lambda (populate)
                                (chdir "/fs")
@@ -415,7 +432,8 @@ It can be used to provide additional files, such as /etc files."
       (qemu-image store
                   #:grub-configuration grub.cfg
                   #:populate populate
-                  #:disk-image-size (* 400 (expt 2 20))
+                  #:disk-image-size (* 500 (expt 2 20))
+                  #:initialize-store? #t
                   #:inputs-to-copy `(("boot" ,boot)
                                      ("linux" ,linux-libre)
                                      ("initrd" ,gnu-system-initrd)
@@ -424,6 +442,7 @@ It can be used to provide additional files, such as /etc files."
                                      ("guile" ,guile-2.0)
                                      ("mingetty" ,mingetty)
                                      ("dmd" ,dmd)
+                                     ("guix" ,guix-0.4)
 
                                      ;; Configuration.
                                      ("dmd.conf" ,dmd-conf)