From 67050453343e58664047fa0361d746baffd27d9f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 8 Nov 2006 02:34:14 +0000 Subject: [PATCH] * Start of the installer: copy the closure of Nix to the target device so we can then do nix-env operations in a chroot to do the actual installation. svn path=/nixu/trunk/; revision=6977 --- test/installer.nix | 15 +++++++++++++++ test/installer.sh | 41 +++++++++++++++++++++++++++++++++++++++++ test/rescue-system.nix | 7 +++++++ 3 files changed, 63 insertions(+) create mode 100644 test/installer.nix create mode 100644 test/installer.sh diff --git a/test/installer.nix b/test/installer.nix new file mode 100644 index 000000000000..1560e6654897 --- /dev/null +++ b/test/installer.nix @@ -0,0 +1,15 @@ +{ stdenv, genericSubstituter, shell, nix +}: + +genericSubstituter { + src = ./installer.sh; + isExecutable = true; + inherit shell nix; + + nixClosure = stdenv.mkDerivation { + name = "closure"; + builder = builtins.toFile "builder.sh" + "source $stdenv/setup; /nix/bin/nix-store -qR $nix > $out"; + inherit nix; + }; +} diff --git a/test/installer.sh b/test/installer.sh new file mode 100644 index 000000000000..c2742e9018eb --- /dev/null +++ b/test/installer.sh @@ -0,0 +1,41 @@ +#! @shell@ + +# Syntax: installer.sh +# (e.g., installer.sh /dev/hda1 ./my-machine.nix) + +# - mount target device +# - make Nix store etc. +# - copy closure of rescue env to target device +# - register validity +# - start the "target" installer in a chroot to the target device +# * do a nix-pull +# * nix-env -p system-profile -i +# * run hook scripts provided by packages in the configuration? +# - install/update grub + +targetDevice="$1" + +if test -z "$targetDevice"; then + echo "syntax: installer.sh " + exit 1 +fi + + +# Make sure that the target device isn't mounted. +umount "$targetDevice" 2> /dev/null + + +# Check it. +fsck "$targetDevice" || exit 1 + + +# Mount the target device. +mountPoint=/tmp/inst-mnt +mkdir -p $mountPoint +mount "$targetDevice" $mountPoint || exit 1 + + +# Copy Nix to the Nix store on the target device. +mkdir -p $mountPoint/nix/store/ +cp -prd $(cat @nixClosure@) $mountPoint/nix/store/ || exit 1 + diff --git a/test/rescue-system.nix b/test/rescue-system.nix index fd22e482f2e3..e4147b153f5e 100644 --- a/test/rescue-system.nix +++ b/test/rescue-system.nix @@ -98,6 +98,13 @@ rec { }; + # The installer. + nixosInstaller = import ./installer.nix { + inherit (pkgs) stdenv genericSubstituter nix; + shell = pkgs.bash + "/bin/sh"; + }; + + # Since the CD is read-only, the mount points must be on disk. cdMountPoints = pkgs.stdenv.mkDerivation { name = "mount-points";