Shellcheck the existing installer
This commit is contained in:
parent
2a0112a370
commit
799f5adf79
|
@ -123,7 +123,7 @@ let
|
||||||
|
|
||||||
runCommand "nix-binary-tarball-${version}"
|
runCommand "nix-binary-tarball-${version}"
|
||||||
{ exportReferencesGraph = [ "closure1" toplevel "closure2" cacert ];
|
{ exportReferencesGraph = [ "closure1" toplevel "closure2" cacert ];
|
||||||
buildInputs = [ perl ];
|
buildInputs = [ perl shellcheck ];
|
||||||
meta.description = "Distribution-independent Nix bootstrap binaries for ${system}";
|
meta.description = "Distribution-independent Nix bootstrap binaries for ${system}";
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
|
@ -132,6 +132,9 @@ let
|
||||||
substitute ${./scripts/install-nix-from-closure.sh} $TMPDIR/install \
|
substitute ${./scripts/install-nix-from-closure.sh} $TMPDIR/install \
|
||||||
--subst-var-by nix ${toplevel} \
|
--subst-var-by nix ${toplevel} \
|
||||||
--subst-var-by cacert ${cacert}
|
--subst-var-by cacert ${cacert}
|
||||||
|
|
||||||
|
shellcheck -e SC1090 $TMPDIR/install
|
||||||
|
|
||||||
chmod +x $TMPDIR/install
|
chmod +x $TMPDIR/install
|
||||||
dir=nix-${version}-${system}
|
dir=nix-${version}-${system}
|
||||||
fn=$out/$dir.tar.bz2
|
fn=$out/$dir.tar.bz2
|
||||||
|
|
|
@ -7,7 +7,7 @@ self="$(dirname "$0")"
|
||||||
nix="@nix@"
|
nix="@nix@"
|
||||||
cacert="@cacert@"
|
cacert="@cacert@"
|
||||||
|
|
||||||
if ! [ -e $self/.reginfo ]; then
|
if ! [ -e "$self/.reginfo" ]; then
|
||||||
echo "$0: incomplete installer (.reginfo is missing)" >&2
|
echo "$0: incomplete installer (.reginfo is missing)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -23,6 +23,11 @@ if [ -z "$USER" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$HOME" ]; then
|
||||||
|
echo "$0: \$HOME is not set" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
printf '\e[1;31mwarning: installing Nix as root is not supported by this script!\e[0m\n'
|
printf '\e[1;31mwarning: installing Nix as root is not supported by this script!\e[0m\n'
|
||||||
fi
|
fi
|
||||||
|
@ -47,7 +52,7 @@ mkdir -p $dest/store
|
||||||
|
|
||||||
echo -n "copying Nix to $dest/store..." >&2
|
echo -n "copying Nix to $dest/store..." >&2
|
||||||
|
|
||||||
for i in $(cd $self/store >/dev/null && echo *); do
|
for i in $(cd "$self/store" >/dev/null && echo ./*); do
|
||||||
echo -n "." >&2
|
echo -n "." >&2
|
||||||
i_tmp="$dest/store/$i.$$"
|
i_tmp="$dest/store/$i.$$"
|
||||||
if [ -e "$i_tmp" ]; then
|
if [ -e "$i_tmp" ]; then
|
||||||
|
@ -61,39 +66,39 @@ done
|
||||||
echo "" >&2
|
echo "" >&2
|
||||||
|
|
||||||
echo "initialising Nix database..." >&2
|
echo "initialising Nix database..." >&2
|
||||||
if ! $nix/bin/nix-store --init; then
|
if ! "$nix/bin/nix-store" --init; then
|
||||||
echo "$0: failed to initialize the Nix database" >&2
|
echo "$0: failed to initialize the Nix database" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $nix/bin/nix-store --load-db < $self/.reginfo; then
|
if ! "$nix/bin/nix-store" --load-db < "$self/.reginfo"; then
|
||||||
echo "$0: unable to register valid paths" >&2
|
echo "$0: unable to register valid paths" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
. $nix/etc/profile.d/nix.sh
|
. "$nix/etc/profile.d/nix.sh"
|
||||||
|
|
||||||
if ! $nix/bin/nix-env -i "$nix"; then
|
if ! "$nix/bin/nix-env" -i "$nix"; then
|
||||||
echo "$0: unable to install Nix into your default profile" >&2
|
echo "$0: unable to install Nix into your default profile" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install an SSL certificate bundle.
|
# Install an SSL certificate bundle.
|
||||||
if [ -z "$NIX_SSL_CERT_FILE" -o ! -f "$NIX_SSL_CERT_FILE" ]; then
|
if [ -z "$NIX_SSL_CERT_FILE" ] || [ ! -f "$NIX_SSL_CERT_FILE" ]; then
|
||||||
$nix/bin/nix-env -i "$cacert"
|
"$nix/bin/nix-env" -i "$cacert"
|
||||||
export NIX_SSL_CERT_FILE="$HOME/.nix-profile/etc/ssl/certs/ca-bundle.crt"
|
export NIX_SSL_CERT_FILE="$HOME/.nix-profile/etc/ssl/certs/ca-bundle.crt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Subscribe the user to the Nixpkgs channel and fetch it.
|
# Subscribe the user to the Nixpkgs channel and fetch it.
|
||||||
if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
|
if ! "$nix/bin/nix-channel" --list | grep -q "^nixpkgs "; then
|
||||||
$nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
"$nix/bin/nix-channel" --add https://nixos.org/channels/nixpkgs-unstable
|
||||||
fi
|
fi
|
||||||
if [ -z "$_NIX_INSTALLER_TEST" ]; then
|
if [ -z "$_NIX_INSTALLER_TEST" ]; then
|
||||||
$nix/bin/nix-channel --update nixpkgs
|
"$nix/bin/nix-channel" --update nixpkgs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make the shell source nix.sh during login.
|
# Make the shell source nix.sh during login.
|
||||||
p=$NIX_LINK/etc/profile.d/nix.sh
|
p="$NIX_LINK/etc/profile.d/nix.sh"
|
||||||
|
|
||||||
added=
|
added=
|
||||||
for i in .bash_profile .bash_login .profile; do
|
for i in .bash_profile .bash_login .profile; do
|
||||||
|
@ -101,7 +106,7 @@ for i in .bash_profile .bash_login .profile; do
|
||||||
if [ -w "$fn" ]; then
|
if [ -w "$fn" ]; then
|
||||||
if ! grep -q "$p" "$fn"; then
|
if ! grep -q "$p" "$fn"; then
|
||||||
echo "modifying $fn..." >&2
|
echo "modifying $fn..." >&2
|
||||||
echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> $fn
|
echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> "$fn"
|
||||||
fi
|
fi
|
||||||
added=1
|
added=1
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue