Skip to content

Commit fc63410

Browse files
committed
Install Nix: add subscribeChannels()
rm old add a nix-channel
1 parent cd94065 commit fc63410

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

scripts/install-nix-from-closure.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,14 +730,27 @@ installNix() {
730730
readonly NIX_SSL_CERT_FILE="$HOME/.nix-profile/etc/ssl/certs/ca-bundle.crt"
731731
export NIX_SSL_CERT_FILE
732732
}
733+
734+
subscribeChannels() {
735+
# Subscribe the user to the Nixpkgs channel and fetch it.
736+
trap 'subscribeChannelsRevert $LINENO $?' INT TERM ABRT QUIT
737+
subscribeChannelsRevert() {
738+
errorRevert "Received Error signal from line $1"
739+
errorRevert "Reverting channels subscriptions: nixpkgs"
740+
"$nix"/bin/nix-channel --remove nixpkgs
741+
error "
742+
743+
Changes reverted.
744+
" "$2"
745+
}
746+
readonly channelUrl='https://nixos.org/channels/nixpkgs-unstable'
747+
print "Subscribing to channel: nixpkgs=$channelUrl"
748+
"$nix"/bin/nix-channel --add "$channelUrl"
749+
}
733750
}
734751

735752
}
736753
echo "performing a single-user installation of Nix..." >&2
737-
# Subscribe the user to the Nixpkgs channel and fetch it.
738-
if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
739-
$nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
740-
fi
741754
if [ -z "$_NIX_INSTALLER_TEST" ]; then
742755
$nix/bin/nix-channel --update nixpkgs
743756
fi

0 commit comments

Comments
 (0)