nixpkgs/test/make-initrd.sh
Eelco Dolstra 0b26af2188 * The installer now installs a configuration on the target device that
boots into stage 1 (kernel+initrd) succesfully.
  
  `system-configuration.nix' contains the definition of the
  configuration to be installed.  The attribute systemConfiguration is
  installed into the profile /nix/var/nix/profiles/system.  Then the
  program /nix/var/nix/profiles/system/bin/switch-to-configuration is
  called to finalise the installation.  This program (generated by
  system-configuration.sh) installs Grub on the drive with a menu that
  contains the entry for the desired kernel and initrd.

  In principle this allows us to do rollbacks to previous system
  configurations by doing `nix-env --rollback' and then calling
  switch-to-configuration to update Grub.  Ideally this should be done
  in a single command (and we should consider the obvious risk of
  garbage collecting the current kernel etc. to which the current Grub
  menu points...).

  Maybe the responsibility for generating the Grub menu should be
  placed somewhere else.  For instance, we could generate a Grub menu
  automatically out of all the generations in the `system' profile.

svn path=/nixu/trunk/; revision=7009
2006-11-12 23:30:03 +00:00

21 lines
629 B
Bash

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)
# Paths in cpio archives *must* be relative, otherwise the kernel
# won't unpack 'em.
mkdir root
cd root
cp -prd --parents $packagesClosure .
# Put the closure in a gzipped cpio archive.
ensureDir $out
ln -s $init init
find * -print0 | cpio -ov -H newc --null | gzip -9 > $out/initrd