From 4916d920927b186fb2b88443e062e9e382cded4b Mon Sep 17 00:00:00 2001 From: wmertens Date: Tue, 7 Oct 2014 17:40:31 +0200 Subject: [PATCH 1/2] 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 --- scripts/install-nix-from-closure.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/install-nix-from-closure.sh b/scripts/install-nix-from-closure.sh index bef5cd4f1..07423e699 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 < Date: Thu, 14 May 2015 16:36:24 +0200 Subject: [PATCH 2/2] Remove information about nix-store --optimise --- scripts/install-nix-from-closure.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/install-nix-from-closure.sh b/scripts/install-nix-from-closure.sh index 07423e699..a6966c414 100644 --- a/scripts/install-nix-from-closure.sh +++ b/scripts/install-nix-from-closure.sh @@ -131,12 +131,3 @@ variables are set, either log in again, or type in your shell. EOF fi -cat >&2 <