Skip to content

Commit

Permalink
Merge pull request NixOS#2679 from bjornfor/offline-install
Browse files Browse the repository at this point in the history
install script: don't abort when "nix-channel --update" fails
  • Loading branch information
edolstra authored May 1, 2019
2 parents 83f2b11 + b9567aa commit 989cb37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion scripts/install-multi-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,16 @@ EOF
}
trap finish_fail EXIT

channel_update_failed=0
function finish_success {
finish_cleanup

ok "Alright! We're done!"
if [ "x$channel_update_failed" = x1 ]; then
echo ""
echo "But fetching the nixpkgs channel failed. (Are you offline?)"
echo "To try again later, run \"sudo -i nix-channel --update nixpkgs\"."
fi
cat <<EOF
Before Nix will work in your existing shells, you'll need to close
Expand Down Expand Up @@ -734,7 +740,9 @@ setup_default_profile() {
# otherwise it will be lost in environments where sudo doesn't pass
# all the environment variables by default.
_sudo "to update the default channel in the default profile" \
HOME="$ROOT_HOME" NIX_SSL_CERT_FILE="$NIX_SSL_CERT_FILE" "$NIX_INSTALLED_NIX/bin/nix-channel" --update nixpkgs
HOME="$ROOT_HOME" NIX_SSL_CERT_FILE="$NIX_SSL_CERT_FILE" "$NIX_INSTALLED_NIX/bin/nix-channel" --update nixpkgs \
|| channel_update_failed=1

}


Expand Down
5 changes: 4 additions & 1 deletion scripts/install-nix-from-closure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
$nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
fi
if [ -z "$_NIX_INSTALLER_TEST" ]; then
$nix/bin/nix-channel --update nixpkgs
if ! $nix/bin/nix-channel --update nixpkgs; then
echo "Fetching the nixpkgs channel failed. (Are you offline?)"
echo "To try again later, run \"nix-channel --update nixpkgs\"."
fi
fi

added=
Expand Down

0 comments on commit 989cb37

Please sign in to comment.