3
0
Fork 0
forked from mirrors/nixpkgs

* A module for generating a disk image suitable for use with Amazon's

Elastic Compute Cloud (EC2).  TODO: run ec2-bundle-image here.

svn path=/nixos/trunk/; revision=19580
This commit is contained in:
Eelco Dolstra 2010-01-20 18:10:02 +00:00
parent 6d21e00776
commit 590acc193c

View file

@ -0,0 +1,43 @@
{ config, pkgs, ... }:
with pkgs.lib;
{
system.build.ext2Image =
pkgs.vmTools.runInLinuxVM (
pkgs.runCommand "amazon-image"
{ preVM =
''
mkdir $out
diskImage=$out/nixos.img
qemu-img create -f raw $diskImage "1024M"
'';
buildInputs = [ pkgs.utillinux pkgs.perl pkgs.rsync ];
exportReferencesGraph =
[ "closure" config.system.build.toplevel ];
}
''
# Create an empty filesysten and mount it.
${pkgs.e2fsprogs}/sbin/mkfs.ext3 /dev/vda
mkdir /mnt
mount /dev/vda /mnt
# Copy all paths in the closure to the filesystem.
storePaths=$(perl ${pkgs.pathsFromGraph} $ORIG_TMPDIR/closure)
mkdir -p /mnt/nix/store
rsync -av $storePaths /mnt/nix/store/
# Amazon assumes that there is a /sbin/init, so symlink it
# to the stage 2 init script. Since we cannot set the path
# to the system configuration via the systemConfig kernel
# parameter, use a /system symlink.
mkdir -p /mnt/sbin
ln -s ${config.system.build.bootStage2} /mnt/sbin/init
ln -s ${config.system.build.toplevel} /mnt/system
umount /mnt
''
);
}