* 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 initial RAM disk.
initialRamdisk = import ./make-initrd.nix {
inherit (pkgs) stdenv cpio nix;
packages = [];
inherit (pkgs) stdenv cpio;
init = bootStage1;
};
# The installer.
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";
};

View file

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

View file

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

View file

@ -1,20 +1,25 @@
# Create an initial ramdisk containing the specified set of packages.
# An initial ramdisk is used during the initial stages of booting a
# Linux system. It is loaded by the boot loader along with the kernel
# image. It's supposed to contain everything (such as kernel modules)
# necessary to allow us to mount the root file system. Once the root
# file system is mounted, the `real' boot script can be called.
# Create an initial ramdisk containing the closure of the specified
# `init' package. An initial ramdisk is used during the initial
# stages of booting a Linux system. It is loaded by the boot loader
# along with the kernel image. It's supposed to contain everything
# (such as kernel modules) necessary to allow us to mount the root
# 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.
#
# A symlink `/init' is made to the store path passed in the `init'
# argument.
{stdenv, cpio, packages, init, nix}:
{stdenv, cpio, init}:
stdenv.mkDerivation {
name = "initrd";
builder = ./make-initrd.sh;
buildInputs = [cpio nix];
inherit packages init;
buildInputs = [cpio];
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
# Get the paths in the closure of `packages'. Unfortunately, the only
# way to get the closure is to call Nix, which is strictly speaking
# forbidden. But we do it anyway. In time, we should add a feature
# to Nix to let Nix pass closures to builders.
packagesClosure=$(nix-store -qR $packages $init)
# Get the paths in the closure of `init'.
if ! test -e ./init-closure; then
echo 'Your Nix installation is too old! Upgrade to nix-0.11pre7038 or newer.'
exit 1
fi
storePaths=$($SHELL $pathsFromGraph ./init-closure)
# Paths in cpio archives *must* be relative, otherwise the kernel
# won't unpack 'em.
mkdir root
cd root
cp -prd --parents $packagesClosure .
cp -prd --parents $storePaths .
# Put the closure in a gzipped cpio archive.
ensureDir $out

View file

@ -1,4 +1,4 @@
{ stdenv, cdrtools, nix
{ stdenv, cdrtools
# The file name of the resulting ISO image.
, isoName ? "cd.iso"
@ -9,9 +9,11 @@
# grafted in the file system at path `target'.
contents
/*
, # In addition to `contents', the closure of the store paths listed
# in `packages' are also placed in the file system.
packages ? []
*/
, # `init' should be a store path, the closure of which is added to
# the image, just like `packages'. However, in addition, a symlink
@ -31,8 +33,12 @@ assert bootable -> bootImage != "";
stdenv.mkDerivation {
name = "iso9660-image";
builder = ./make-iso9660-image.sh;
buildInputs = [cdrtools nix];
inherit isoName packages init bootable bootImage;
buildInputs = [cdrtools];
inherit isoName init bootable bootImage;
sources = map ({source, target}: source) 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]})"
done
# !!! Just as with make-initrd.nix, the call to Nix here needs to be
# fixed.
packagesClosure=$(nix-store -qR $packages $init)
storePaths=$($SHELL $pathsFromGraph ./init-closure)
for i in $packagesClosure; do
for i in $storePaths; do
graftList="$graftList ${i:1}=$i"
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
# init.
rescueCD = import ./make-iso9660-image.nix {
inherit (pkgs) stdenv cdrtools nix;
inherit (pkgs) stdenv cdrtools;
isoName = "nixos.iso";
contents = [