summary refs log tree commit diff
path: root/nixos/modules/installer
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-05-08 23:40:17 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-05-09 00:52:02 +0200
commit8919d736a034c85eb3e38bc3d9baedcb00356e4e (patch)
treeb00165bc515aee5fd4e684dc70d487c4bcf51601 /nixos/modules/installer
parent22f102cbdc7e88ecb41b5d0a8720c8117e161aca (diff)
downloadnixlib-8919d736a034c85eb3e38bc3d9baedcb00356e4e.tar
nixlib-8919d736a034c85eb3e38bc3d9baedcb00356e4e.tar.gz
nixlib-8919d736a034c85eb3e38bc3d9baedcb00356e4e.tar.bz2
nixlib-8919d736a034c85eb3e38bc3d9baedcb00356e4e.tar.lz
nixlib-8919d736a034c85eb3e38bc3d9baedcb00356e4e.tar.xz
nixlib-8919d736a034c85eb3e38bc3d9baedcb00356e4e.tar.zst
nixlib-8919d736a034c85eb3e38bc3d9baedcb00356e4e.zip
nixos-install: Don't copy the bootstrap Nix if it's already there
This makes re-running nixos-install a bit faster.
Diffstat (limited to 'nixos/modules/installer')
-rw-r--r--nixos/modules/installer/tools/nixos-install.sh39
1 files changed, 18 insertions, 21 deletions
diff --git a/nixos/modules/installer/tools/nixos-install.sh b/nixos/modules/installer/tools/nixos-install.sh
index 3fd8bdbd69e0..1b481d4c65f9 100644
--- a/nixos/modules/installer/tools/nixos-install.sh
+++ b/nixos/modules/installer/tools/nixos-install.sh
@@ -100,17 +100,8 @@ mkdir -m 1775 -p $mountPoint/nix/store
 chown root:nixbld $mountPoint/nix/store
 
 
-# Get the store paths to copy from the references graph.
-storePaths=$(@perl@/bin/perl @pathsFromGraph@ @nixClosure@)
-
-
-# Copy Nix to the Nix store on the target device.
-echo "copying Nix to $mountPoint...."
-for i in $storePaths; do
-    echo "  $i"
-    chattr -R -i $mountPoint/$i 2> /dev/null || true # clear immutable bit
-    rsync -a $i $mountPoint/nix/store/
-done
+# There is no daemon in the chroot.
+unset NIX_REMOTE
 
 
 # We don't have locale-archive in the chroot, so clear $LANG.
@@ -119,10 +110,6 @@ export LC_ALL=
 export LC_TIME=
 
 
-# There is no daemon in the chroot
-unset NIX_REMOTE
-
-
 # Create a temporary Nix config file that causes the nixbld users to
 # be used.
 echo "build-users-group = nixbld" > $mountPoint/tmp/nix.conf # FIXME: remove in Nix 1.8
@@ -133,12 +120,22 @@ fi
 export NIX_CONF_DIR=/tmp
 
 
-# Register the paths in the Nix closure as valid.  This is necessary
-# to prevent them from being deleted the first time we install
-# something.  (I.e., Nix will see that, e.g., the glibc path is not
-# valid, delete it to get it out of the way, but as a result nothing
-# will work anymore.)
-chroot $mountPoint @nix@/bin/nix-store --register-validity < @nixClosure@
+# Copy Nix to the Nix store on the target device, unless it's already there.
+if ! NIX_DB_DIR=$mountPoint/nix/var/nix/db nix-store --check-validity @nix@ 2> /dev/null; then
+    echo "copying Nix to $mountPoint...."
+    for i in $(@perl@/bin/perl @pathsFromGraph@ @nixClosure@); do
+        echo "  $i"
+        chattr -R -i $mountPoint/$i 2> /dev/null || true # clear immutable bit
+        rsync -a $i $mountPoint/nix/store/
+    done
+
+    # Register the paths in the Nix closure as valid.  This is necessary
+    # to prevent them from being deleted the first time we install
+    # something.  (I.e., Nix will see that, e.g., the glibc path is not
+    # valid, delete it to get it out of the way, but as a result nothing
+    # will work anymore.)
+    chroot $mountPoint @nix@/bin/nix-store --register-validity < @nixClosure@
+fi
 
 
 # Create the required /bin/sh symlink; otherwise lots of things