diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-04-11 13:38:11 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-04-11 19:08:24 +0200 |
commit | e1a87b904a7f889bf080085c2aaef035b55d111a (patch) | |
tree | fa60a434633427991b4a53213adc885e6f27ad8c /gnu | |
parent | 772d63658e4a90eb85bc07ceb9a5dd518baab270 (diff) | |
download | gnu-guix-e1a87b904a7f889bf080085c2aaef035b55d111a.tar gnu-guix-e1a87b904a7f889bf080085c2aaef035b55d111a.tar.gz |
vm: Add (guix build vm) module.
* guix/build/vm.scm: New file.
* Makefile.am (MODULES): Add it.
* gnu/system/vm.scm (expression->derivation-in-linux-vm): Use it.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/system/vm.scm | 77 |
1 files changed, 19 insertions, 58 deletions
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index a7d81feb4a..9d8ad87b88 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -119,67 +119,27 @@ made available under the /xchg CIFS share." ;; Code that launches the VM that evaluates EXP. `(let () (use-modules (guix build utils) - (srfi srfi-1) - (ice-9 rdelim)) - - (let ((out (assoc-ref %outputs "out")) - (cu (string-append (assoc-ref %build-inputs "coreutils") - "/bin")) - (qemu (string-append (assoc-ref %build-inputs "qemu") - "/bin/qemu-system-" - (car (string-split ,system #\-)))) - (img (string-append (assoc-ref %build-inputs "qemu") - "/bin/qemu-img")) - (linux (string-append (assoc-ref %build-inputs "linux") + (guix build vm)) + + (let ((linux (string-append (assoc-ref %build-inputs "linux") "/bzImage")) (initrd (string-append (assoc-ref %build-inputs "initrd") "/initrd")) - (builder (assoc-ref %build-inputs "builder"))) - - ;; XXX: QEMU uses "rm -rf" when it's done to remove the temporary SMB - ;; directory, so it really needs `rm' in $PATH. - (setenv "PATH" cu) - - ,(if make-disk-image? - `(zero? (system* img "create" "-f" "qcow2" "image.qcow2" - ,(number->string disk-image-size))) - '(begin)) - - (mkdir "xchg") - - ;; Copy the reference-graph files under xchg/ so EXP can access it. - (begin - ,@(match references-graphs - (((graph-files . _) ...) - (map (lambda (file) - `(copy-file ,file - ,(string-append "xchg/" file))) - graph-files)) - (#f '()))) - - (and (zero? - (system* qemu "-enable-kvm" "-nographic" "-no-reboot" - "-m" ,(number->string memory-size) - "-net" "nic,model=virtio" - "-virtfs" - ,(string-append "local,id=store_dev,path=" (%store-prefix) - ",security_model=none,mount_tag=store") - "-virtfs" - ,(string-append "local,id=xchg_dev,path=xchg" - ",security_model=none,mount_tag=xchg") - "-kernel" linux - "-initrd" initrd - "-append" (string-append "console=ttyS0 --load=" - builder) - ,@(if make-disk-image? - '("-hda" "image.qcow2") - '()))) - ,(if make-disk-image? - '(copy-file "image.qcow2" ; XXX: who mkdir'd OUT? - out) - '(begin - (mkdir out) - (copy-recursively "xchg" out))))))) + (builder (assoc-ref %build-inputs "builder")) + (graphs ',(match references-graphs + (((graph-files . _) ...) graph-files) + (_ #f)))) + + (set-path-environment-variable "PATH" '("bin") + (map cdr %build-inputs)) + + (load-in-linux-vm builder + #:output (assoc-ref %outputs "out") + #:linux linux #:initrd initrd + #:memory-size ,memory-size + #:make-disk-image? ,make-disk-image? + #:disk-image-size ,disk-image-size + #:references-graphs graphs)))) (mlet* %store-monad ((input-alist (sequence %store-monad input-alist)) @@ -206,6 +166,7 @@ made available under the /xchg CIFS share." #:env-vars env-vars #:modules (delete-duplicates `((guix build utils) + (guix build vm) ,@modules)) #:guile-for-build guile-for-build #:references-graphs references-graphs))) |