2004-02-14 23:56:51 +01:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
|
|
|
image=/tmp/disk.img
|
2004-08-06 19:22:24 +02:00
|
|
|
size=$(expr 2048 \* 1024 \* 1024)
|
2004-11-09 11:28:21 +01:00
|
|
|
storePaths=/tmp/mystorepaths
|
|
|
|
successors=/tmp/mysuccessors
|
2004-02-14 23:56:51 +01:00
|
|
|
|
|
|
|
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-08-06 15:52:39 +02:00
|
|
|
|
|
|
|
NIX_CMD_PATH=/nix/bin
|
|
|
|
|
|
|
|
storeExpr=$(echo '(import ./pkgs.nix).everything' | $NIX_CMD_PATH/nix-instantiate -)
|
|
|
|
$NIX_CMD_PATH/nix-store -rB $storeExpr
|
|
|
|
$NIX_CMD_PATH/nix-store -qn --requisites $storeExpr > $storePaths
|
2004-02-14 23:56:51 +01:00
|
|
|
|
|
|
|
(while read storepath; do
|
2004-08-06 15:52:39 +02:00
|
|
|
$NIX_CMD_PATH/nix-store -q --predecessors $storepath | (while read predecessor; do
|
2004-02-14 23:56:51 +01:00
|
|
|
echo $predecessor $storepath
|
|
|
|
done)
|
2004-02-18 11:56:07 +01:00
|
|
|
done) < $storePaths > $successors
|
|
|
|
|
|
|
|
# Location of sysvinit?
|
2004-08-06 15:52:39 +02:00
|
|
|
sysvinitPath=$($NIX_CMD_PATH/nix-store -qn $(echo '(import ./pkgs.nix).sysvinit' | $NIX_CMD_PATH/nix-instantiate -))
|
2004-02-18 11:56:07 +01:00
|
|
|
|
2004-02-18 15:56:32 +01:00
|
|
|
# Location of Nix boot scripts?
|
2004-08-06 15:52:39 +02:00
|
|
|
bootPath=$($NIX_CMD_PATH/nix-store -qn $(echo '(import ./pkgs.nix).boot' | $NIX_CMD_PATH/nix-instantiate -))
|
2004-02-14 23:56:51 +01:00
|
|
|
|
|
|
|
# Fill the disk with the minimal Nix store.
|
|
|
|
if ! test -d /tmp/mnt; then mkdir /tmp/mnt; fi
|
2004-02-18 11:56:07 +01:00
|
|
|
linux ubd0=$image root=/dev/root rootflags=/ rootfstype=hostfs \
|
2004-02-18 15:56:32 +01:00
|
|
|
init="$(pwd)/fill-disk.sh $sysvinitPath $bootPath"
|