mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-15 06:14:57 +01:00
1f7a8c8ae9
svn path=/nixu/trunk/; revision=785
34 lines
911 B
Bash
Executable file
34 lines
911 B
Bash
Executable file
#! /bin/sh -e
|
|
|
|
image=/tmp/disk.img
|
|
size=$(expr 256 \* 1024 \* 1024)
|
|
storepaths=/tmp/storepaths
|
|
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?
|
|
storeexpr=$(echo '(import ./pkgs.nix).init' | nix-instantiate -)
|
|
nix-store -rB $storeexpr
|
|
nix-store -qn --requisites $storeexpr > $storepaths
|
|
|
|
(while read storepath; do
|
|
nix-store -q --predecessors $storepath | (while read predecessor; do
|
|
echo $predecessor $storepath
|
|
done)
|
|
done) < $storepaths > $successors
|
|
|
|
# Fill the disk with the minimal Nix store.
|
|
if ! test -d /tmp/mnt; then mkdir /tmp/mnt; fi
|
|
linux ubd0=$image root=/dev/root rootflags=/ rootfstype=hostfs init="$(pwd)/fill-disk.sh $storeexpr"
|
|
|