* The user should mount the target file system.

svn path=/nixos/trunk/; revision=7598
This commit is contained in:
Eelco Dolstra 2007-01-09 23:12:41 +00:00
parent efefd93551
commit fd4c1a2c43
3 changed files with 19 additions and 26 deletions

8
README
View file

@ -34,6 +34,8 @@
- The NixOS installer doesn't do any partitioning or formatting yet, - The NixOS installer doesn't do any partitioning or formatting yet,
so you need to that yourself. Use "fdisk", "mkfs.ext2" and "tune2fs". so you need to that yourself. Use "fdisk", "mkfs.ext2" and "tune2fs".
- Mount the target root device, e.g., under /mnt.
- Unpack the NixOS and Nixpkgs sources: - Unpack the NixOS and Nixpkgs sources:
$ tar xf /nixos.tar.bz2 $ tar xf /nixos.tar.bz2
@ -56,10 +58,10 @@
- Do the installation: - Do the installation:
$ nixos-installer.sh /dev/TARGET . my-config.nix $ nixos-installer.sh ROOTDIR . my-config.nix
where TARGET matched boot.rootDevice in your configuration. (TODO: where ROOTDIR is the mount point of the target root device (i.e.,
this should be extracted automatically.) boot.rootDevice in your configuration).
- If everything went well: - If everything went well:

View file

@ -1,7 +1,7 @@
rec { rec {
nixpkgsRel = "nixpkgs-0.11pre7577"; nixpkgsRel = "nixpkgs-0.11pre7593";
configuration = { configuration = {
@ -94,7 +94,7 @@ rec {
# Get a recent copy of Nixpkgs. # Get a recent copy of Nixpkgs.
nixpkgsTarball = pkgs.fetchurl { nixpkgsTarball = pkgs.fetchurl {
url = configuration.installer.nixpkgsURL + "/" + nixpkgsRel + ".tar.bz2"; url = configuration.installer.nixpkgsURL + "/" + nixpkgsRel + ".tar.bz2";
md5 = "0949415aa342679f206fdb7ee9b04b46"; md5 = "fd443fb8b1c4d352d9a8b7d19dfb7c49";
}; };

View file

@ -1,7 +1,7 @@
#! @shell@ #! @shell@
# Syntax: installer.sh <DEVICE> <NIX-EXPR> # Syntax: installer.sh <DEVICE> <NIX-EXPR>
# (e.g., installer.sh /dev/hda1 ./my-machine.nix) # (e.g., installer.sh /mnt/root ./my-machine.nix)
# - mount target device # - mount target device
# - make Nix store etc. # - make Nix store etc.
@ -15,12 +15,12 @@
set -e set -e
targetDevice="$1" mountPoint="$1"
nixosDir="$2" nixosDir="$2"
configuration="$3" configuration="$3"
if test -z "$targetDevice" -o -z "$nixosDir" -o -z "$configuration"; then if test ! -e "$mountPoint" -o ! -e "$nixosDir" -o ! -e "$configuration"; then
echo "Syntax: installer.sh <targetDevice> <nixosDir> <configuration>" echo "Syntax: installer.sh <targetRootDir> <nixosDir> <configuration>"
exit 1 exit 1
fi fi
@ -28,19 +28,7 @@ nixosDir=$(readlink -f "$nixosDir")
configuration=$(readlink -f "$configuration") configuration=$(readlink -f "$configuration")
# Make sure that the target device isn't mounted. # Mount some stuff in the target root directory.
umount "$targetDevice" 2> /dev/null || true
# Check it.
fsck -n "$targetDevice"
# Mount the target device.
mountPoint=/tmp/inst-mnt
mkdir -p $mountPoint
mount "$targetDevice" $mountPoint
mkdir -m 0755 -p $mountPoint/dev $mountPoint/proc $mountPoint/sys $mountPoint/mnt mkdir -m 0755 -p $mountPoint/dev $mountPoint/proc $mountPoint/sys $mountPoint/mnt
mount --rbind / $mountPoint/mnt mount --rbind / $mountPoint/mnt
mount --bind /dev $mountPoint/dev mount --bind /dev $mountPoint/dev
@ -48,6 +36,7 @@ mount --bind /proc $mountPoint/proc
mount --bind /sys $mountPoint/sys mount --bind /sys $mountPoint/sys
cleanup() { cleanup() {
# !!! don't umount any we didn't mount ourselves
for i in $(grep -F "$mountPoint" /proc/mounts \ for i in $(grep -F "$mountPoint" /proc/mounts \
| perl -e 'while (<>) { /^\S+\s+(\S+)\s+/; print "$1\n"; }' \ | perl -e 'while (<>) { /^\S+\s+(\S+)\s+/; print "$1\n"; }' \
| sort -r); | sort -r);
@ -81,7 +70,7 @@ mkdir -m 1777 -p \
storePaths=$(@shell@ @pathsFromGraph@ @nixClosure@) storePaths=$(@shell@ @pathsFromGraph@ @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 $mountPoint...."
for i in $storePaths; do for i in $storePaths; do
echo " $i" echo " $i"
rsync -a $i $mountPoint/nix/store/ rsync -a $i $mountPoint/nix/store/
@ -133,13 +122,15 @@ chroot $mountPoint @nix@/bin/nix-env \
targetConfig=$mountPoint/etc/nixos/configuration.nix targetConfig=$mountPoint/etc/nixos/configuration.nix
mkdir -p $(dirname $targetConfig) mkdir -p $(dirname $targetConfig)
if test -e $targetConfig -o -L $targetConfig; then if test -e $targetConfig -o -L $targetConfig; then
mv $targetConfig $targetConfig.backup-$(date "+%Y%m%d%H%M%S") cp -f $targetConfig $targetConfig.backup-$(date "+%Y%m%d%H%M%S")
fi fi
cp $configuration $targetConfig if
cp -f $configuration $targetConfig
# Grub needs a mtab. # Grub needs a mtab.
echo "$targetDevice / somefs rw 0 0" > $mountPoint/etc/mtab rootDevice=$(df $mountPoint | grep '^/' | sed 's^ .*^^')
echo "$rootDevice / somefs rw 0 0" > $mountPoint/etc/mtab
# Mark the target as a NixOS installation, otherwise # Mark the target as a NixOS installation, otherwise