about summary refs log tree commit diff
path: root/scripts/install-nix-from-closure.sh
diff options
context:
space:
mode:
authorwmertens <Wout.Mertens@gmail.com>2014-10-07T15·40+0200
committerWout Mertens <Wout.Mertens@gmail.com>2016-04-10T19·55+0200
commit4916d920927b186fb2b88443e062e9e382cded4b (patch)
tree7da67b1bbfd97ca28bba333ced77532b204041b1 /scripts/install-nix-from-closure.sh
parent8cffec84859cec8b610a2a22ab0c4d462a9351ff (diff)
Always verify nix store on install
Just wasted a couple hours chasing shadows because the nix store got
corrupted and there was no indication of that anywhere.

Since an install is one-time only, might as well verify.  Optimization
showed that the copied files aren't read-only; fixed that as well.

Also, use /bin/sh since there's a good chance that this script will be
run on systems without /bin/bash
Diffstat (limited to 'scripts/install-nix-from-closure.sh')
-rw-r--r--scripts/install-nix-from-closure.sh19
1 files changed, 18 insertions, 1 deletions
diff --git a/scripts/install-nix-from-closure.sh b/scripts/install-nix-from-closure.sh
index bef5cd4f15fa..07423e69967e 100644
--- a/scripts/install-nix-from-closure.sh
+++ b/scripts/install-nix-from-closure.sh
@@ -1,4 +1,4 @@
-#! /usr/bin/env bash
+#!/bin/sh
 
 set -e
 
@@ -49,7 +49,10 @@ for i in $(cd $self/store >/dev/null && echo *); do
     fi
     if ! [ -e "$dest/store/$i" ]; then
         cp -Rp "$self/store/$i" "$i_tmp"
+        chmod -R a-w "$i_tmp"
+        chmod +w "$i_tmp"
         mv "$i_tmp" "$dest/store/$i"
+        chmod -w "$dest/store/$i"
     fi
 done
 echo "" >&2
@@ -65,6 +68,11 @@ if ! $nix/bin/nix-store --load-db < $self/.reginfo; then
     exit 1
 fi
 
+if ! $nix/bin/nix-store --verify; then
+    echo "$0: store verification failed! Consider deleting /nix and starting over" >&2
+    exit 1
+fi
+
 . $nix/etc/profile.d/nix.sh
 
 if ! $nix/bin/nix-env -i "$nix"; then
@@ -123,3 +131,12 @@ variables are set, either log in again, or type
 in your shell.
 EOF
 fi
+cat >&2 <<EOF
+
+Then, consider running
+
+  nix-store --optimise
+
+which will reduce store disk usage by hardlinking identical
+files together.
+EOF