Fix installing the Nixpkgs channel on the installation media

And test that it got installed correctly.

Changed files
+18 -7
nixos
doc
lib
modules
installer
tests
+3 -3
nixos/doc/manual/man-nixos-install.xml
···
<replaceable>root</replaceable>
</arg>
<arg>
-
<arg choice='plain'><option>--closure</option></arg>
-
<replaceable>closure</replaceable>
+
<arg choice='plain'><option>--system</option></arg>
+
<replaceable>path</replaceable>
</arg>
<arg>
<arg choice='plain'><option>--no-channel-copy</option></arg>
···
</varlistentry>
<varlistentry>
-
<term><option>--closure</option></term>
+
<term><option>--system</option></term>
<listitem>
<para>If this option is provided, <command>nixos-install</command> will install the specified closure
rather than attempt to build one from <filename>/mnt/etc/nixos/configuration.nix</filename>.</para>
+2 -1
nixos/lib/make-disk-image.nix
···
nix-store --load-db < ${closureInfo}/registration
echo "running nixos-install..."
-
nixos-install --root $root --no-bootloader --no-root-passwd --closure ${config.system.build.toplevel} --substituters ""
+
nixos-install --root $root --no-bootloader --no-root-passwd \
+
--system ${config.system.build.toplevel} --channel ${channelSources} --substituters ""
echo "copying staging root to image..."
cptofs -p ${optionalString (partitionTableType != "none") "-P ${rootPartition}"} -t ${fsType} -i $diskImage $root/* /
+8 -3
nixos/modules/installer/tools/nixos-install.sh
···
extraBuildFlags=()
mountPoint=/mnt
+
channelPath=
while [ "$#" -gt 0 ]; do
i="$1"; shift 1
···
--root)
mountPoint="$1"; shift 1
;;
-
--closure)
-
# FIXME: --closure is a misnomer
+
--system|--closure)
system="$1"; shift 1
+
;;
+
--channel)
+
channelPath="$1"; shift 1
;;
--no-channel-copy)
noChannelCopy=1
···
# Copy the NixOS/Nixpkgs sources to the target as the initial contents
# of the NixOS channel.
if [[ -z $noChannelCopy ]]; then
-
channelPath="$(nix-env -p /nix/var/nix/profiles/per-user/root/channels -q nixos --no-name --out-path 2>/dev/null || echo -n "")"
+
if [[ -z $channelPath ]]; then
+
channelPath="$(nix-env -p /nix/var/nix/profiles/per-user/root/channels -q nixos --no-name --out-path 2>/dev/null || echo -n "")"
+
fi
if [[ -n $channelPath ]]; then
echo "copying channel..."
mkdir -p $mountPoint/nix/var/nix/profiles/per-user/root
+5
nixos/tests/boot.nix
···
$machine->start;
$machine->waitForUnit("multi-user.target");
$machine->succeed("nix verify -r --no-trust /run/current-system");
+
+
# Test whether the channel got installed correctly.
+
$machine->succeed("nix-instantiate --dry-run '<nixpkgs>' -A hello");
+
$machine->succeed("nix-env --dry-run -iA nixos.procps");
+
$machine->shutdown;
'';
};