···
-
# The initrd expects these directories to exist.
-
mkdir /mnt/dev /mnt/proc /mnt/sys
-
mount -o bind /proc /mnt/proc
-
mount -o bind /dev /mnt/dev
-
mount -o bind /sys /mnt/sys
-
# Copy all paths in the closure to the filesystem.
-
storePaths=$(perl ${pkgs.pathsFromGraph} /tmp/xchg/closure)
-
mkdir -p /mnt/nix/store
-
echo "copying everything (will take a while)..."
-
cp -prd $storePaths /mnt/nix/store/
# Register the paths in the Nix database.
printRegistration=1 perl ${pkgs.pathsFromGraph} /tmp/xchg/closure | \
-
chroot /mnt ${config.nix.package.out}/bin/nix-store --load-db --option build-users-group ""
# Add missing size/hash fields to the database. FIXME:
# exportReferencesGraph should provide these directly.
-
chroot /mnt ${config.nix.package.out}/bin/nix-store --verify --check-contents
-
# Create the system profile to allow nixos-rebuild to work.
-
chroot /mnt ${config.nix.package.out}/bin/nix-env --option build-users-group "" \
-
-p /nix/var/nix/profiles/system --set ${config.system.build.toplevel}
-
# `nixos-rebuild' requires an /etc/NIXOS.
-
# `switch-to-configuration' requires a /bin/sh
-
ln -s ${config.system.build.binsh}/bin/sh /mnt/bin/sh
# Install a configuration.nix.
···
cp ${configFile} /mnt/etc/nixos/configuration.nix
-
# Generate the GRUB menu.
-
${optionalString installBootLoader "chroot /mnt ${config.system.build.toplevel}/bin/switch-to-configuration boot"}
-
umount /mnt/proc /mnt/dev /mnt/sys
# Do a fsck to make sure resize2fs works.