summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-02-27 19:58:23 +0100
committerEelco Dolstra <edolstra@gmail.com>2018-02-27 19:58:23 +0100
commitcc2eeef4abfaf484363d43d6bcce510f0f16dc1d (patch)
treee4fe86b08f63348ce89c9ed204ab46d8e8737b8f
parent8c6f9223d02c5123cbd364d6d56caca3c81416f0 (diff)
downloadnixpkgs-cc2eeef4abfaf484363d43d6bcce510f0f16dc1d.tar
nixpkgs-cc2eeef4abfaf484363d43d6bcce510f0f16dc1d.tar.gz
nixpkgs-cc2eeef4abfaf484363d43d6bcce510f0f16dc1d.tar.bz2
nixpkgs-cc2eeef4abfaf484363d43d6bcce510f0f16dc1d.tar.lz
nixpkgs-cc2eeef4abfaf484363d43d6bcce510f0f16dc1d.tar.xz
nixpkgs-cc2eeef4abfaf484363d43d6bcce510f0f16dc1d.tar.zst
nixpkgs-cc2eeef4abfaf484363d43d6bcce510f0f16dc1d.zip
Fix installing the Nixpkgs channel on the installation media
And test that it got installed correctly.
-rw-r--r--nixos/doc/manual/man-nixos-install.xml6
-rw-r--r--nixos/lib/make-disk-image.nix3
-rw-r--r--nixos/modules/installer/tools/nixos-install.sh11
-rw-r--r--nixos/tests/boot.nix5
4 files changed, 18 insertions, 7 deletions
diff --git a/nixos/doc/manual/man-nixos-install.xml b/nixos/doc/manual/man-nixos-install.xml
index 15c603256ca..c9887146989 100644
--- a/nixos/doc/manual/man-nixos-install.xml
+++ b/nixos/doc/manual/man-nixos-install.xml
@@ -26,8 +26,8 @@
       <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>
@@ -118,7 +118,7 @@ it.</para>
   </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>
diff --git a/nixos/lib/make-disk-image.nix b/nixos/lib/make-disk-image.nix
index 4da86346903..ebfb09db7b7 100644
--- a/nixos/lib/make-disk-image.nix
+++ b/nixos/lib/make-disk-image.nix
@@ -181,7 +181,8 @@ let format' = format; in let
     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/* /
diff --git a/nixos/modules/installer/tools/nixos-install.sh b/nixos/modules/installer/tools/nixos-install.sh
index b51779cfb95..87013dc8f97 100644
--- a/nixos/modules/installer/tools/nixos-install.sh
+++ b/nixos/modules/installer/tools/nixos-install.sh
@@ -12,6 +12,7 @@ umask 0022
 extraBuildFlags=()
 
 mountPoint=/mnt
+channelPath=
 
 while [ "$#" -gt 0 ]; do
     i="$1"; shift 1
@@ -28,10 +29,12 @@ while [ "$#" -gt 0 ]; do
         --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
             ;;
@@ -104,7 +107,9 @@ nix-env --store "$mountPoint" "${extraBuildFlags[@]}" \
 # 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
diff --git a/nixos/tests/boot.nix b/nixos/tests/boot.nix
index 0ba8a2704e6..301d9d0f817 100644
--- a/nixos/tests/boot.nix
+++ b/nixos/tests/boot.nix
@@ -25,6 +25,11 @@ let
           $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;
         '';
     };