Skip to content

Instantly share code, notes, and snippets.

@domenkozar
Created October 26, 2013 18:29
Show Gist options
  • Save domenkozar/7172907 to your computer and use it in GitHub Desktop.
Save domenkozar/7172907 to your computer and use it in GitHub Desktop.
ARCH=`uname -m`
ARCH_SYS=`uname -s | tr "[A-Z]" "[a-z]"`
VERSION=1.6
NAME=nix-${VERSION}-${ARCH}-${ARCH_SYS}
if [ "$ARCH" = "i686" -a "$ARCH_SYS" = "freebsd" ]
then
DOWNLOAD_URL=http://hydra.nixos.org/build/6039367/download/1/nix-1.6-i686-freebsd.tar.bz2
elif [ "$ARCH" = "i686" -a "$ARCH_SYS" = "linux" ]
then
DOWNLOAD_URL=http://hydra.nixos.org/build/6039372/download/1/nix-1.6-i686-linux.tar.bz2
elif [ "$ARCH" = "x86_64" -a "$ARCH_SYS" = "darwin" ]
then
DOWNLOAD_URL=http://hydra.nixos.org/build/6039370/download/1/nix-1.6-x86_64-darwin.tar.bz2
elif [ "$ARCH" = "x86_64" -a "$ARCH_SYS" = "freebsd" ]
then
DOWNLOAD_URL=http://hydra.nixos.org/build/6039364/download/1/nix-1.6-x86_64-freebsd.tar.bz2
elif [ "$ARCH" = "x86_64" -a "$ARCH_SYS" = "linux" ]
then
DOWNLOAD_URL=http://hydra.nixos.org/build/6039398/download/1/nix-1.6-x86_64-linux.tar.bz2
else
echo "Platform detected: ${ARCH_SYS} ${ARCH}"
echo "Platform not supported!"
exit 1
fi
echo "Platform detected: ${ARCH_SYS} ${ARCH}"
echo "Downloading Nix for your platform..."
WORK_DIR=`pwd`
if [ ! -f $WORK_DIR/${NAME}.tar.bz2 ]; then
curl -O $DOWNLOAD_URL
fi
sudo tar xfj $WORK_DIR/${NAME}.tar.bz2 -C /
sudo chown -R $USER /nix
/usr/bin/nix-finish-install
sudo rm /usr/bin/nix-finish-install
source $HOME/.nix-profile/etc/profile.d/nix.sh
cd $WORK_DIR
echo "Adding and updating Nix Packages channel..."
nix-channel --add http://nixos.org/channels/nixpkgs-unstable
nix-channel --update
nix-env -u \*
echo
echo "========================================================================"
echo
echo "Make sure to source Nix user profile:"
echo " echo \"source $HOME/.nix-profile/etc/profile.d/nix.sh\" >> ~/.profile"
echo
echo "========================================================================"
echo " ... happy Nix-ing!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment