* The user should mount the target file system.
svn path=/nixos/trunk/; revision=7598
This commit is contained in:
parent
efefd93551
commit
fd4c1a2c43
8
README
8
README
|
@ -34,6 +34,8 @@
|
|||
- The NixOS installer doesn't do any partitioning or formatting yet,
|
||||
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:
|
||||
|
||||
$ tar xf /nixos.tar.bz2
|
||||
|
@ -56,10 +58,10 @@
|
|||
|
||||
- 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:
|
||||
this should be extracted automatically.)
|
||||
where ROOTDIR is the mount point of the target root device (i.e.,
|
||||
boot.rootDevice in your configuration).
|
||||
|
||||
- If everything went well:
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
rec {
|
||||
|
||||
|
||||
nixpkgsRel = "nixpkgs-0.11pre7577";
|
||||
nixpkgsRel = "nixpkgs-0.11pre7593";
|
||||
|
||||
|
||||
configuration = {
|
||||
|
@ -94,7 +94,7 @@ rec {
|
|||
# Get a recent copy of Nixpkgs.
|
||||
nixpkgsTarball = pkgs.fetchurl {
|
||||
url = configuration.installer.nixpkgsURL + "/" + nixpkgsRel + ".tar.bz2";
|
||||
md5 = "0949415aa342679f206fdb7ee9b04b46";
|
||||
md5 = "fd443fb8b1c4d352d9a8b7d19dfb7c49";
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! @shell@
|
||||
|
||||
# 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
|
||||
# - make Nix store etc.
|
||||
|
@ -15,12 +15,12 @@
|
|||
|
||||
set -e
|
||||
|
||||
targetDevice="$1"
|
||||
mountPoint="$1"
|
||||
nixosDir="$2"
|
||||
configuration="$3"
|
||||
|
||||
if test -z "$targetDevice" -o -z "$nixosDir" -o -z "$configuration"; then
|
||||
echo "Syntax: installer.sh <targetDevice> <nixosDir> <configuration>"
|
||||
if test ! -e "$mountPoint" -o ! -e "$nixosDir" -o ! -e "$configuration"; then
|
||||
echo "Syntax: installer.sh <targetRootDir> <nixosDir> <configuration>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -28,19 +28,7 @@ nixosDir=$(readlink -f "$nixosDir")
|
|||
configuration=$(readlink -f "$configuration")
|
||||
|
||||
|
||||
# Make sure that the target device isn't mounted.
|
||||
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
|
||||
|
||||
# Mount some stuff in the target root directory.
|
||||
mkdir -m 0755 -p $mountPoint/dev $mountPoint/proc $mountPoint/sys $mountPoint/mnt
|
||||
mount --rbind / $mountPoint/mnt
|
||||
mount --bind /dev $mountPoint/dev
|
||||
|
@ -48,6 +36,7 @@ mount --bind /proc $mountPoint/proc
|
|||
mount --bind /sys $mountPoint/sys
|
||||
|
||||
cleanup() {
|
||||
# !!! don't umount any we didn't mount ourselves
|
||||
for i in $(grep -F "$mountPoint" /proc/mounts \
|
||||
| perl -e 'while (<>) { /^\S+\s+(\S+)\s+/; print "$1\n"; }' \
|
||||
| sort -r);
|
||||
|
@ -81,7 +70,7 @@ mkdir -m 1777 -p \
|
|||
storePaths=$(@shell@ @pathsFromGraph@ @nixClosure@)
|
||||
|
||||
# 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
|
||||
echo " $i"
|
||||
rsync -a $i $mountPoint/nix/store/
|
||||
|
@ -133,13 +122,15 @@ chroot $mountPoint @nix@/bin/nix-env \
|
|||
targetConfig=$mountPoint/etc/nixos/configuration.nix
|
||||
mkdir -p $(dirname $targetConfig)
|
||||
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
|
||||
cp $configuration $targetConfig
|
||||
if
|
||||
cp -f $configuration $targetConfig
|
||||
|
||||
|
||||
# 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
|
||||
|
|
Loading…
Reference in a new issue