* Use exportReferencesGraph everywhere.

svn path=/nixu/trunk/; revision=7063
This commit is contained in:
Eelco Dolstra 2006-11-17 14:13:21 +00:00
parent 82ce465751
commit 78b2ed263e
9 changed files with 50 additions and 44 deletions

View file

@ -62,15 +62,15 @@ rec {
# The closure of the init script of boot stage 1 is what we put in # The closure of the init script of boot stage 1 is what we put in
# the initial RAM disk. # the initial RAM disk.
initialRamdisk = import ./make-initrd.nix { initialRamdisk = import ./make-initrd.nix {
inherit (pkgs) stdenv cpio nix; inherit (pkgs) stdenv cpio;
packages = [];
init = bootStage1; init = bootStage1;
}; };
# The installer. # The installer.
nixosInstaller = import ./installer.nix { nixosInstaller = import ./installer.nix {
inherit (pkgs) stdenv genericSubstituter nix; inherit (pkgs) stdenv genericSubstituter;
nix = pkgs.nixUnstable; # needs the exportReferencesGraph feature
shell = pkgs.bash + "/bin/sh"; shell = pkgs.bash + "/bin/sh";
}; };

View file

@ -7,16 +7,11 @@ genericSubstituter {
isExecutable = true; isExecutable = true;
inherit shell nix; inherit shell nix;
pathsFromGraph = ./paths-from-graph.sh;
nixClosure = stdenv.mkDerivation { nixClosure = stdenv.mkDerivation {
name = "closure"; name = "closure";
exportReferencesGraph = ["refs" nix]; exportReferencesGraph = ["refs" nix];
builder = builtins.toFile "builder.sh" " builder = builtins.toFile "builder.sh" "source $stdenv/setup; cp refs $out";
source $stdenv/setup
if ! test -e refs; then
echo 'Your Nix installation is too old!'
exit 1
fi
cp refs $out
";
}; };
} }

View file

@ -74,16 +74,7 @@ mkdir -m 0755 -p \
# Get the store paths to copy from the references graph. # Get the store paths to copy from the references graph.
storePaths="" storePaths=$(@shell@ @pathsFromGraph@ @nixClosure@)
while read storePath; do
storePaths="$storePaths $storePath"
read deriver
read count
for ((i = 0; i < $count; i++)); do
read ref
done
done < @nixClosure@
# Copy Nix to the Nix store on the target device. # Copy Nix to the Nix store on the target device.
echo "copying Nix to $targetDevice...." echo "copying Nix to $targetDevice...."

View file

@ -1,20 +1,25 @@
# Create an initial ramdisk containing the specified set of packages. # Create an initial ramdisk containing the closure of the specified
# An initial ramdisk is used during the initial stages of booting a # `init' package. An initial ramdisk is used during the initial
# Linux system. It is loaded by the boot loader along with the kernel # stages of booting a Linux system. It is loaded by the boot loader
# image. It's supposed to contain everything (such as kernel modules) # along with the kernel image. It's supposed to contain everything
# necessary to allow us to mount the root file system. Once the root # (such as kernel modules) necessary to allow us to mount the root
# file system is mounted, the `real' boot script can be called. # file system. Once the root file system is mounted, the `real' boot
# script can be called.
# #
# An initrd is really just a gzipped cpio archive. # An initrd is really just a gzipped cpio archive.
# #
# A symlink `/init' is made to the store path passed in the `init' # A symlink `/init' is made to the store path passed in the `init'
# argument. # argument.
{stdenv, cpio, packages, init, nix}: {stdenv, cpio, init}:
stdenv.mkDerivation { stdenv.mkDerivation {
name = "initrd"; name = "initrd";
builder = ./make-initrd.sh; builder = ./make-initrd.sh;
buildInputs = [cpio nix]; buildInputs = [cpio];
inherit packages init; inherit init;
# For obtaining the closure of `init'.
exportReferencesGraph = ["init-closure" init];
pathsFromGraph = ./paths-from-graph.sh;
} }

View file

@ -2,17 +2,18 @@ source $stdenv/setup
set -o pipefail set -o pipefail
# Get the paths in the closure of `packages'. Unfortunately, the only # Get the paths in the closure of `init'.
# way to get the closure is to call Nix, which is strictly speaking if ! test -e ./init-closure; then
# forbidden. But we do it anyway. In time, we should add a feature echo 'Your Nix installation is too old! Upgrade to nix-0.11pre7038 or newer.'
# to Nix to let Nix pass closures to builders. exit 1
packagesClosure=$(nix-store -qR $packages $init) fi
storePaths=$($SHELL $pathsFromGraph ./init-closure)
# Paths in cpio archives *must* be relative, otherwise the kernel # Paths in cpio archives *must* be relative, otherwise the kernel
# won't unpack 'em. # won't unpack 'em.
mkdir root mkdir root
cd root cd root
cp -prd --parents $packagesClosure . cp -prd --parents $storePaths .
# Put the closure in a gzipped cpio archive. # Put the closure in a gzipped cpio archive.
ensureDir $out ensureDir $out

View file

@ -1,4 +1,4 @@
{ stdenv, cdrtools, nix { stdenv, cdrtools
# The file name of the resulting ISO image. # The file name of the resulting ISO image.
, isoName ? "cd.iso" , isoName ? "cd.iso"
@ -9,9 +9,11 @@
# grafted in the file system at path `target'. # grafted in the file system at path `target'.
contents contents
/*
, # In addition to `contents', the closure of the store paths listed , # In addition to `contents', the closure of the store paths listed
# in `packages' are also placed in the file system. # in `packages' are also placed in the file system.
packages ? [] packages ? []
*/
, # `init' should be a store path, the closure of which is added to , # `init' should be a store path, the closure of which is added to
# the image, just like `packages'. However, in addition, a symlink # the image, just like `packages'. However, in addition, a symlink
@ -31,8 +33,12 @@ assert bootable -> bootImage != "";
stdenv.mkDerivation { stdenv.mkDerivation {
name = "iso9660-image"; name = "iso9660-image";
builder = ./make-iso9660-image.sh; builder = ./make-iso9660-image.sh;
buildInputs = [cdrtools nix]; buildInputs = [cdrtools];
inherit isoName packages init bootable bootImage; inherit isoName init bootable bootImage;
sources = map ({source, target}: source) contents; sources = map ({source, target}: source) contents;
targets = map ({source, target}: target) contents; targets = map ({source, target}: target) contents;
# For obtaining the closure of `init'.
exportReferencesGraph = ["init-closure" init];
pathsFromGraph = ./paths-from-graph.sh;
} }

View file

@ -11,11 +11,9 @@ for ((i = 0; i < ${#targets_[@]}; i++)); do
graftList="$graftList ${targets_[$i]}=$(readlink -f ${sources_[$i]})" graftList="$graftList ${targets_[$i]}=$(readlink -f ${sources_[$i]})"
done done
# !!! Just as with make-initrd.nix, the call to Nix here needs to be storePaths=$($SHELL $pathsFromGraph ./init-closure)
# fixed.
packagesClosure=$(nix-store -qR $packages $init)
for i in $packagesClosure; do for i in $storePaths; do
graftList="$graftList ${i:1}=$i" graftList="$graftList ${i:1}=$i"
done done

10
test/paths-from-graph.sh Normal file
View file

@ -0,0 +1,10 @@
graph="$1"
while read storePath; do
echo $storePath
read deriver
read count
for ((i = 0; i < $count; i++)); do
read ref
done
done < $graph

View file

@ -36,7 +36,7 @@ rec {
# kernel, the initrd produced above, and the closure of the stage 2 # kernel, the initrd produced above, and the closure of the stage 2
# init. # init.
rescueCD = import ./make-iso9660-image.nix { rescueCD = import ./make-iso9660-image.nix {
inherit (pkgs) stdenv cdrtools nix; inherit (pkgs) stdenv cdrtools;
isoName = "nixos.iso"; isoName = "nixos.iso";
contents = [ contents = [