mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-25 21:44:49 +00:00
* 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
This commit is contained in:
parent
624fe3f2d4
commit
6705045334
15
test/installer.nix
Normal file
15
test/installer.nix
Normal file
@ -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;
|
||||
};
|
||||
}
|
41
test/installer.sh
Normal file
41
test/installer.sh
Normal file
@ -0,0 +1,41 @@
|
||||
#! @shell@
|
||||
|
||||
# Syntax: installer.sh <DEVICE> <NIX-EXPR>
|
||||
# (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 <nix-expr for the configuration>
|
||||
# * run hook scripts provided by packages in the configuration?
|
||||
# - install/update grub
|
||||
|
||||
targetDevice="$1"
|
||||
|
||||
if test -z "$targetDevice"; then
|
||||
echo "syntax: installer.sh <targetDevice>"
|
||||
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
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user