* The CD is now a true live CD: you can run Nix operations in it

thanks to unionfs.  For instance, nix-env and nixos-rebuild work.
  The tricky part was to build a Nix database (in the tmpfs/unionfs)
  which is now necessary to prevent store paths on the CD from being
  deleted right away because they otherwise wouldn't be valid.
  
* nixos-install: use the /etc/nixos/configuration.nix from the target
  file system (don't copy it anymore).  Since the user is supposed to
  mount the target file system on /mnt anyway, we may as well require
  that configuration.nix is placed in /mnt/etc/nixos.  This also makes
  upgrading / reinstalling much easier, since it will automatically
  use the right configuration.nix.

svn path=/nixos/trunk/; revision=10399
This commit is contained in:
Eelco Dolstra 2008-01-30 01:28:56 +00:00
parent 34e63da53b
commit 9fd5d70968
7 changed files with 36 additions and 28 deletions

View file

@ -36,14 +36,18 @@ rec {
extraJobs = [
# Unpack the NixOS/Nixpkgs sources to /etc/nixos.
# !!! run this synchronously
{ name = "unpack-sources";
job = "
start on startup
script
export PATH=${pkgs.gnutar}/bin:${pkgs.bzip2}/bin:$PATH
${system.nix}/bin/nix-store --load-db < /nix-path-registration
mkdir -p /etc/nixos/nixos
tar xjf /nixos.tar.bz2 -C /etc/nixos/nixos
tar xjf /nixpkgs.tar.bz2 -C /etc/nixos
tar xjf /install/nixos.tar.bz2 -C /etc/nixos/nixos
tar xjf /install/nixpkgs.tar.bz2 -C /etc/nixos
mv /etc/nixos/nixpkgs-* /etc/nixos/nixpkgs
ln -sfn ../nixpkgs/pkgs /etc/nixos/nixos/pkgs
chown -R root.root /etc/nixos
@ -66,6 +70,7 @@ rec {
{ name = "rogue";
job = "
env HOME=/root
chdir /root
start on udev
stop on shutdown
respawn ${pkgs.rogue}/bin/rogue < /dev/tty8 > /dev/tty8 2>&1
@ -214,10 +219,10 @@ rec {
target = "boot/background.xpm.gz";
}
{ source = nixosTarball + "/" + nixosTarball.tarName;
target = "/" + nixosTarball.tarName;
target = "/install/" + nixosTarball.tarName;
}
{ source = nixpkgsTarball;
target = "/nixpkgs.tar.bz2";
target = "/install/nixpkgs.tar.bz2";
}
{ source = pkgs.writeText "label" "";
target = "/${configuration.boot.rootLabel}";

View file

@ -73,7 +73,7 @@ if test ! -e $HOME/.nix-defexpr -o -L $HOME/.nix-defexpr; then
echo "creating $HOME/.nix-defexpr" >&2
rm -f $HOME/.nix-defexpr
mkdir $HOME/.nix-defexpr
ln -s /etc/nixos/install-source.nix $HOME/.nix-defexpr/nixpkgs_sys
ln -s /etc/nixos/nixpkgs $HOME/.nix-defexpr/nixpkgs_sys
ln -s /etc/nixos/nixos $HOME/.nix-defexpr/nixos
if test "$USER" != root; then
ln -s /nix/var/nix/gcroots/per-user/root/channels $HOME/.nix-defexpr/channels_root

View file

@ -39,8 +39,8 @@ done
# Also put a nix-pull manifest of the closures on the CD.
printManifest=1 perl $pathsFromGraph closure-* > MANIFEST
echo "MANIFEST=MANIFEST" >> pathlist
printRegistration=1 perl $pathsFromGraph closure-* > nix-path-registration
echo "nix-path-registration=nix-path-registration" >> pathlist
# Add symlinks to the top-level store objects.

View file

@ -47,6 +47,20 @@ if ($ENV{"printManifest"} eq "1") {
}
}
elsif ($ENV{"printRegistration"} eq "1") {
# This is the format used by `nix-store --register-validity
# --hash-given' / `nix-store --load-db'.
foreach my $storePath (sort (keys %storePaths)) {
print "$storePath\n";
print "0000000000000000000000000000000000000000000000000000000000000000\n"; # !!! fix
print "\n"; # don't care about preserving the deriver
print scalar(@{$refs{$storePath}}), "\n";
foreach my $ref (@{$refs{$storePath}}) {
print "$ref\n";
}
}
}
else {
foreach my $storePath (sort (keys %storePaths)) {
print "$storePath\n";

View file

@ -29,8 +29,7 @@ fi
svn co https://svn.cs.uu.nl:12443/repos/trace/nixos/trunk nixos
svn co https://svn.cs.uu.nl:12443/repos/trace/nixpkgs/trunk nixpkgs
svn co https://svn.cs.uu.nl:12443/repos/trace/services/trunk services
ln -sfn ../services nixos/services
# A few symlink.
# Add a few required symlink.
ln -sfn ../services nixos/services
ln -sfn ../nixpkgs/pkgs nixos/pkgs
ln -sfn nixpkgs/pkgs/top-level/all-packages.nix install-source.nix

View file

@ -19,6 +19,7 @@ if test -z "$NIXOS"; then
NIXOS=/etc/nixos/nixos
fi
# NIXOS_CONFIG is interpreted relative to $mountPoint.
if test -z "$NIXOS_CONFIG"; then
NIXOS_CONFIG=/etc/nixos/configuration.nix
fi
@ -38,14 +39,13 @@ if ! test -e "$NIXOS"; then
exit 1
fi
if ! test -e "$NIXOS_CONFIG"; then
echo "configuration file $NIXOS_CONFIG doesn't exist"
if ! test -e "$mountPoint/$NIXOS_CONFIG"; then
echo "configuration file $mountPoint/$NIXOS_CONFIG doesn't exist"
exit 1
fi
NIXOS=$(readlink -f "$NIXOS")
NIXOS_CONFIG=$(readlink -f "$NIXOS_CONFIG")
# Mount some stuff in the target root directory.
@ -142,22 +142,10 @@ echo "building the system configuration..."
chroot $mountPoint @nix@/bin/nix-env \
-p /nix/var/nix/profiles/system \
-f "/mnt$NIXOS/system/system.nix" \
--arg configuration "import /mnt$NIXOS_CONFIG" \
--arg configuration "import $NIXOS_CONFIG" \
--set -A system
# Copy the configuration to /etc/nixos.
backupTimestamp=$(date "+%Y%m%d%H%M%S")
targetConfig=$mountPoint/etc/nixos/configuration.nix
mkdir -p $(dirname $targetConfig)
if test -e $targetConfig -o -L $targetConfig; then
cp -f $targetConfig $targetConfig.backup-$backupTimestamp
fi
if test "$NIXOS_CONFIG" != "$targetConfig"; then
cp -f $NIXOS_CONFIG $targetConfig
fi
# Make a backup of the old NixOS/Nixpkgs sources.
echo "copying NixOS/Nixpkgs sources to /etc/nixos...."
@ -177,7 +165,6 @@ cp -prd $NIXOS $targetNixos
if test -e /etc/nixos/nixpkgs; then
cp -prd /etc/nixos/nixpkgs $targetNixpkgs
fi
ln -sfn nixpkgs/pkgs/top-level/all-packages.nix $mountPoint/etc/nixos/install-source.nix
# Grub needs a mtab.

View file

@ -155,7 +155,10 @@ fi
# Make this configuration the current configuration.
ln -sfn "$systemConfig" /var/run/current-system
# The readlink is there to ensure that when $systemConfig = /system
# (which is a symlink to the store), /var/run/current-system is still
# used as a garbage collection root.
ln -sfn "$(readlink -f "$systemConfig")" /var/run/current-system
# Prevent the current configuration from being garbage-collected.