Created
November 6, 2015 17:55
-
-
Save rened/60d17f1ff46516b6cc44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script installs nix from source into the current working directory. | |
set -e | |
export TARGET=$(pwd) | |
export BUILDTMP=/tmp/install-nix-here | |
export BUILDTMPESC=$(echo $BUILDTMP | sed -e's/\//\\\//g') | |
if [ "$(ls -A $TARGET)" ]; then | |
echo "Target directory $TARGET is not empty. Exiting." | |
exit | |
fi | |
cd | |
mkdir -p $BUILDTMP | |
rm -rf $BUILDTMP/* | |
cd $BUILDTMP | |
wget https://nixos.org/releases/nix/nix-1.10/nix-1.10.tar.xz | |
tar xvJf nix-1.10.tar.xz | |
wget http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz | |
tar xzvf bzip2-1.0.6.tar.gz | |
wget http://curl.haxx.se/download/curl-7.35.0.tar.lzma | |
lzma -d curl-7.35.0.tar.lzma | |
tar xvf curl-7.35.0.tar | |
wget https://www.sqlite.org/2014/sqlite-autoconf-3080300.tar.gz | |
tar xzvf sqlite-autoconf-3080300.tar.gz | |
wget http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.631.tar.gz | |
tar xzvf DBI-1.631.tar.gz | |
wget http://search.cpan.org/CPAN/authors/id/I/IS/ISHIGAKI/DBD-SQLite-1.40.tar.gz | |
tar xzvf DBD-SQLite-1.40.tar.gz | |
wget http://search.cpan.org/CPAN/authors/id/S/SZ/SZBALINT/WWW-Curl-4.15.tar.gz | |
tar xzvf WWW-Curl-4.15.tar.gz | |
export PATH=$BUILDTMP/bin:$PATH | |
export PKG_CONFIG_PATH=$BUILDTMP/lib/pkgconfig:$PKG_CONFIG_PATH | |
export LDFLAGS="-L$BUILDTMP/lib $LDFLAGS" | |
export CFLAGS="-I$BUILDTMP/include $CFLAGS" | |
export CPPFLAGS="-I$BUILDTMP/include $CPPFLAGS" | |
export PERL5OPT="-I$BUILDTMP/lib/perl" | |
cd bzip2-1.0.6 | |
make -f Makefile-libbz2_so | |
make install PREFIX=$BUILDTMP | |
cp libbz2.so.1.0 libbz2.so.1.0.6 $BUILDTMP/lib | |
cd $BUILDTMP/curl-7.35.0/ | |
./configure --prefix=$BUILDTMP; make -j8; make install | |
cd $BUILDTMP/sqlite-autoconf-3080300/ | |
./configure --prefix=$BUILDTMP; make -j8; make install | |
cd $BUILDTMP/DBI-1.631 | |
perl Makefile.PL PREFIX=$BUILDTMP; make; make install | |
cd $BUILDTMP/DBD-SQLite-1.40 | |
perl Makefile.PL PREFIX=$BUILDTMP; make; make install | |
cd $BUILDTMP/WWW-Curl-4.15 | |
perl Makefile.PL PREFIX=$BUILDTMP; make; make install | |
cd $BUILDTMP/nix-1.10 | |
env \ | |
PKG_CONFIG_PATH="$BUILDTMP/lib/pkgconfig" \ | |
LDFLAGS="-L$BUILDTMP/lib $LDFLAGS" \ | |
LD_LIBRARY_PATH="$BUILDTMP/lib:$LD_LIBRARY_PATH" \ | |
CFLAGS="-I$BUILDTMP/include" \ | |
CPPFLAGS="-I$BUILDTMP/include" \ | |
./configure --prefix=$BUILDTMP --with-store-dir=$TARGET/store --localstatedir=$TARGET/var | |
sed -i'' -e"s/libstore_LDFLAGS = -lsqlite3 -lbz2 -lcurl/libstore_LDFLAGS = -L$BUILDTMPESC\/lib -lsqlite3 -lbz2 -lcurl/" src/libstore/local.mk | |
sed -i'' -e"s/nix-store_LDFLAGS = -lbz2/nix-store_LDFLAGS = -L$BUILDTMPESC\/lib -lbz2/" src/nix-store/local.mk | |
sed -i'' -e"s/bsdiff_LDFLAGS = -lbz2/bsdiff_LDFLAGS = -L$BUILDTMPESC\/lib -lbz2/" src/bsdiff-4.3/local.mk | |
sed -i'' -e"s/bspatch_LDFLAGS = -lbz2/bspatch_LDFLAGS = -L$BUILDTMPESC\/lib -lbz2/" src/bsdiff-4.3/local.mk | |
sed -i'' -e"s/#include <bzlib.h>/#include <$BUILDTMPESC\/include\/bzlib.h>/" src/nix-store/nix-store.cc | |
sed -i'' -e"s/#include <bzlib.h>/#include <$BUILDTMPESC\/include\/bzlib.h>/" src/libstore/build.cc | |
sed -i'' -e"s/#include <bzlib.h>/#include <$BUILDTMPESC\/include\/bzlib.h>/" src/bsdiff-4.3/bspatch.c | |
sed -i'' -e"s/#include <bzlib.h>/#include <$BUILDTMPESC\/include\/bzlib.h>/" src/bsdiff-4.3/bsdiff.c | |
make | |
make install | |
# git clone https://github.com/NixOS/nixpkgs.git $TARGET/nixpkgs | |
# ln -s $TARGET/nixpkgs $HOME/.nix-defexpr | |
nix-channel --add http://nixos.org/channels/nixpkgs-unstable | |
nix-channel --update | |
mkdir -p $TARGET/store | |
mkdir -p $TARGET/var | |
mkdir -p $HOME/.nixpkgs | |
echo " pkgs: | |
{ | |
packageOverrides = self: { | |
nix = self.nix.override { | |
storeDir = "$TARGET/store"; | |
stateDir = "$TARGET/var"; | |
}; | |
}; | |
}" > $HOME/.nixpkgs/config.nix | |
$BUILDTMP/bin/nix-env -iA nix | |
ln -s $TARGET/var/nix/profiles/default $HOME/.nix-profile | |
echo 'export PATH=$HOME/.nix-profile/bin:$PATH' >> $HOME/.profile | |
if [ -e /home/rene/.nix-profile/etc/profile.d/nix.sh ]; then . /home/rene/.nix-profile/etc/profile.d/nix.sh; fi | |
echo "nix-install-here finished. .profile updated. Please run | |
source ~/.profile | |
Enjoy nix!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment