2004-02-14 22:56:51 +00:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
|
|
|
image=/tmp/disk.img
|
|
|
|
size=$(expr 256 \* 1024 \* 1024)
|
2004-02-18 10:56:07 +00:00
|
|
|
storePaths=/tmp/storepaths
|
2004-02-14 22:56:51 +00:00
|
|
|
successors=/tmp/successors
|
|
|
|
|
|
|
|
if ! test -f $image; then
|
|
|
|
|
|
|
|
echo creating empty disk of $size bytes in $image...
|
|
|
|
# Note: this is a sparse file.
|
|
|
|
dd if=/dev/zero of=$image bs=1 seek=$(expr $size - 1) count=1
|
|
|
|
|
|
|
|
echo creating disk image in $image...
|
|
|
|
/sbin/mke2fs -F $image
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# What to copy?
|
2004-02-18 10:56:07 +00:00
|
|
|
storeExpr=$(echo '(import ./pkgs.nix).everything' | nix-instantiate -)
|
|
|
|
nix-store -rB $storeExpr
|
|
|
|
nix-store -qn --requisites $storeExpr > $storePaths
|
2004-02-14 22:56:51 +00:00
|
|
|
|
|
|
|
(while read storepath; do
|
|
|
|
nix-store -q --predecessors $storepath | (while read predecessor; do
|
|
|
|
echo $predecessor $storepath
|
|
|
|
done)
|
2004-02-18 10:56:07 +00:00
|
|
|
done) < $storePaths > $successors
|
|
|
|
|
|
|
|
# Location of sysvinit?
|
|
|
|
sysvinitPath=$(nix-store -qn $(echo '(import ./pkgs.nix).sysvinit' | nix-instantiate -))
|
|
|
|
|
|
|
|
# Location of Nix init?
|
|
|
|
initPath=$(nix-store -qn $(echo '(import ./pkgs.nix).init' | nix-instantiate -))
|
2004-02-14 22:56:51 +00:00
|
|
|
|
|
|
|
# Fill the disk with the minimal Nix store.
|
|
|
|
if ! test -d /tmp/mnt; then mkdir /tmp/mnt; fi
|
2004-02-18 10:56:07 +00:00
|
|
|
linux ubd0=$image root=/dev/root rootflags=/ rootfstype=hostfs \
|
|
|
|
init="$(pwd)/fill-disk.sh $sysvinitPath $initPath"
|