NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.73k stars 1.52k forks source link

Installing nix to a custom directory (as per wiki) fails #512

Open vrthra opened 9 years ago

vrthra commented 9 years ago

I have been trying to follow the Nix wiki to install Nix on a custom path /scratch/gopinath/nix. The /nix path is not accessible to me due to the restrictions on the system provided by my university. The PRoot option does not fit my requirements. I also do not have root access. So here are the steps I have tried.

Environment:

| uname -a
Linux hati.eecs.oregonstate.edu 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Dec 13 06:58:20 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
| cat /etc/redhat-release
Red Hat Enterprise Linux Workstation release 6.5 (Santiago)
| gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)

My efforts

This is what I have tried so far; I used the below script install.sh on the extracted folder /scratch/gopinath/usr/nix-boot

#!/bin/bash
set -e
export nix_boot=${NIX_BOOT-/scratch/gopinath/usr/nix-boot}
export nix_root=${NIX_ROOT-/scratch/gopinath/nix}
export RUN_EXPENSIVE_TESTS=no
export PATH=$nix_boot/bin:/scratch/gopinath/usr/bin:$PATH
export PKG_CONFIG_PATH=$nix_boot/lib/pkgconfig:$PKG_CONFIG_PATH
export LDFLAGS="-L$nix_boot/lib -L$nix_boot/lib64 $LDFLAGS"
export LD_LIBRARY_PATH="$nix_boot/lib:$nix_boot/lib64:$LD_LIBRARY_PATH"
export CPPFLAGS="-I$nix_boot/include $CPPFLAGS"
#export PERL5OPT="-I$nix_boot/lib/perl"
export PERL5OPT="-I$nix_boot/lib64/perl5"
export NIXPKGS=/scratch/gopinath/nixpkgs
all="bzip2 curl sqlite dbi dbd wwwcurl bootstrap nix"
case $1 in
  -h) echo $all nix1.8; exit 0;;
  -sh) $2; exit 0;;
bzip2)
(cd bzip2-1.0.6;
  make -f Makefile-libbz2_so;
  make install PREFIX=$nix_boot;
  cp libbz2.so.1.0 libbz2.so.1.0.6 $nix_boot/lib; ) ;;

curl)
(cd curl-7.35.0/;
  ./configure --prefix=$nix_boot;
  make;
  make install; ) ;;

sqlite)
(cd sqlite-autoconf-3080300/;
  ./configure --prefix=$nix_boot;
  make;
  make install; ) ;;

libxml2)
  (cd libxml2-2.9.2; ./configure --prefix=$nix_boot;
  make;
  cp ./libxml2-2.9.2/xmllint $nix_boot/bin
  # make install;
  ) ;;

libxslt)
  (cd libxslt-1.1.28;  ./configure --prefix=$nix_boot;
  make;
  make install; ) ;;

gcc)
  (cd gcc-4.9.2; ./contrib/download_prerequisites; )
  rm -rf gcc-objs;
  mkdir -p gcc-objs
  (cd gcc-objs; ./../gcc-4.9.2/configure --prefix=$nix_boot;
  make;
  make install; ) ;;

bison)
  (cd bison-3.0; ./configure --prefix=$nix_boot;
  make;
  make install; ) ;;

flex)
  (cd flex-2.5.39;  ./configure --prefix=$nix_boot;
  make;
  make install; );;

coreutils)
  (cd coreutils-8.23;  ./configure --enable-install-program=hostname --prefix=$nix_boot;
  make;
  make install; );;

bash)
  (cd bash-4.3;  ./configure --prefix=$nix_boot;
  make;
  make install; );;

dbi)
(cd DBI-1.631/;
  perl Makefile.PL PREFIX=$nix_boot PERLMAINCC=$nix_boot/bin/gcc;
  make;
  make install; ) ;;

dbd)
(cd DBD-SQLite-1.40/;
  perl Makefile.PL PREFIX=$nix_boot PERLMAINCC=$nix_boot/bin/gcc;
  make;
  make install; ) ;;

wwwcurl)
(cd WWW-Curl-4.15;
  perl Makefile.PL PREFIX=$nix_boot PERLMAINCC=$nix_boot/bin/gcc;
  make;
  make install; ) ;;

bootstrap)
rm -rf nix
git clone https://github.com/NixOS/nix nix
(cd nix;
  ./bootstrap.sh ) ;;

nix)
(cd nix;
  echo "./configure --prefix=$nix_boot --with-store-dir=$nix_root/store --localstatedir=$nix_root/var" > myconfig.sh;
  ./configure --prefix=$nix_boot --with-store-dir=$nix_root/store --localstatedir=$nix_root/var --with-coreutils-bin=/scratch/gopinath/usr/bin --enable-static  --enable-static-nix ;
  /usr/bin/perl -pi -e 's#--nonet# #g' doc/manual/local.mk;
  echo "GLOBAL_LDFLAGS += -lpthread" >> doc/manual/local.mk;
  make;
  make install; ) ;;

nixconfig)
  nix-channel --add http://nixos.org/channels/nixpkgs-unstable && \
  nix-channel --update && \
  nix-env -iA nix -f $NIXPKGS ;
 ;;

all) for i in $all;
     do env nix_boot=$nix_boot nix_root=$nix_root ./$0 $i ;
     done ;;

*) echo $all;
   echo nix_root=$nix_root
   echo nix_boot=$nix_boot;;
esac

Every thing works fine until I hit the nix. On both nix 1.8 and on nix from the repository, I get

bash-4.1$ make
Makefile:28: Makefile.config: No such file or directory
  GEN    Makefile.config
  GEN    doc/manual/manual.is-valid
-:1: parser error : Document is empty

^
-:1: parser error : Start tag expected, '<' not found

^
make: *** [doc/manual/manual.is-valid] Error 1

If I do make clean and then make I get

bash-4.1$ make
Makefile:28: Makefile.config: No such file or directory
  GEN    Makefile.config
  GEN    doc/manual/version.txt
  GEN    doc/manual/manual.xmli
doc/manual/command-ref/nix-env.xml:203: element include: XInclude error : failed build URL
doc/manual/command-ref/nix-env.xml:1368: element include: XInclude error : failed build URL
doc/manual/command-ref/nix-build.xml:129: element include: XInclude error : failed build URL
doc/manual/command-ref/nix-build.xml:184: element include: XInclude error : failed build URL
doc/manual/command-ref/nix-shell.xml:143: element include: XInclude error : failed build URL
doc/manual/command-ref/nix-shell.xml:195: element include: XInclude error : failed build URL
doc/manual/command-ref/nix-store.xml:119: element include: XInclude error : failed build URL
doc/manual/command-ref/nix-store.xml:1346: element include: XInclude error : failed build URL
doc/manual/command-ref/nix-instantiate.xml:166: element include: XInclude error : failed build URL
doc/manual/command-ref/nix-instantiate.xml:258: element include: XInclude error : failed build URL
  GEN    doc/manual/manual.is-valid
-:1: parser error : Document is empty

^
-:1: parser error : Start tag expected, '<' not found

^
make: *** [doc/manual/manual.is-valid] Error 1

On debug, it seems that xsltproc is called with --nonet flag as in

file: doc/manual/local.mk 

$(d)/manual.is-valid: $(d)/manual.xmli
/scratch/gopinath/usr/nix-boot/bin/xsltproc --nonet \
  --param section.autolabel 1 \
  --param section.label.includes.component.label 1 \
  --param html.stylesheet \'style.css\' \
  --param xref.with.number.and.title 1 \
  --param toc.section.depth 3 \
  --param admon.style \'\' \
  --param callout.graphics.extension \'.gif\' \
  --param contrib.inline.enabled 0 \
  --stringparam generate.toc "book toc" \
  --param keep.relative.image.uris 0 \
  --novalid \
  --stringparam profile.condition manual \
           http://docbook.sourceforge.net/release/xsl-ns/1.78.1/profiling/profile.xsl \
           doc/manual/manual.xmli \
  | /scratch/gopinath/usr/nix-boot/bin/xmllint --nonet --noout --relaxng http://docbook.org/xml/5.0/rng/docbook.rng -

It seems nonet flag is messing with me here somehow, even when using the latest xmllint and xsltproc (mentioned in the install script above).

bash-4.1$ which xsltproc
/scratch/gopinath/usr/nix-boot/bin/xsltproc
bash-4.1$ /scratch/gopinath/usr/nix-boot/bin/xsltproc --version
Using libxml 20902, libxslt 10128 and libexslt 817
xsltproc was compiled against libxml 20902, libxslt 10128 and libexslt 817
libxslt 10128 was compiled against libxml 20902
libexslt 817 was compiled against libxml 20902
bash-4.1$ which xmllint
/scratch/gopinath/usr/nix-boot/bin/xmllint
bash-4.1$ /scratch/gopinath/usr/nix-boot/bin/xmllint --version
/scratch/gopinath/usr/nix-boot/bin/xmllint: using libxml version 20902
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib Lzma 

So I did perl -pi -e 's#--nonet# #g' on doc/manual/local.mk as I mention in the above script.

It now seems that the C11 support in GCC 4.4.7 (default) is insufficient. So I am updated my GCC to 4.9.2 and installed it to the same location (updated in the above script). Now my error on building nix is

$ make
...
configure: creating ./config.status
config.status: creating config.h
config.status: config.h is unchanged
  GEN    Makefile.config
  CXX    src/nix-hash/nix-hash.o
  CXX    src/libmain/shared.o
  CXX    src/libmain/stack.o
  CXX    src/libstore/build.o
  CXX    src/libstore/derivations.o
  CXX    src/libstore/gc.o
  CXX    src/libstore/globals.o
  GEN    src/libstore/schema.sql.hh
  CXX    src/libstore/local-store.o
  CXX    src/libstore/misc.o
  CXX    src/libstore/optimise-store.o
  CXX    src/libstore/pathlocks.o
  CXX    src/libstore/references.o
  CXX    src/libstore/remote-store.o
  CXX    src/libstore/store-api.o
  CXX    src/libutil/affinity.o
  CXX    src/libutil/archive.o
  CXX    src/libutil/hash.o
  CXX    src/libutil/regex.o
  CXX    src/libutil/serialise.o
  CXX    src/libutil/util.o
  CXX    src/libutil/xml-writer.o
  CXX    src/boost/format/format_implementation.o
  CXX    src/boost/format/free_funcs.o
  CXX    src/boost/format/parsing.o
  LD     src/boost/format/libnixformat.so
  LD     src/libutil/libnixutil.so
  LD     src/libstore/libnixstore.so
  LD     src/libmain/libnixmain.so
  LD     src/nix-hash/nix-hash
/usr/bin/ld: src/nix-hash/nix-hash: undefined reference to symbol '__pthread_key_create@@GLIBC_2.2.5'
/usr/bin/ld: note: '__pthread_key_create@@GLIBC_2.2.5' is defined in DSO /lib64/libpthread.so.0 so try adding it to the linker command line
/lib64/libpthread.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [src/nix-hash/nix-hash] Error 1
zsh: exit 1     ./install.sh nix

I worked around this error by modifying doc/manual/local.mk by adding a line GLOBAL_LDFLAGS += -lpthread. Now the error is

  CXX    src/libexpr/parser-tab.o
In file included from src/libexpr/parser-tab.cc:255:0:
src/libexpr/parser-tab.hh:124:15: error: redefinition of ‘union YYSTYPE’
 typedef union YYSTYPE
               ^
In file included from src/libexpr/parser.y:53:0:
src/libexpr/parser-tab.hh:124:15: error: previous definition of ‘union YYSTYPE’
 typedef union YYSTYPE
               ^
In file included from src/libexpr/parser-tab.cc:255:0:
src/libexpr/parser-tab.hh:147:10: error: invalid type in declaration before ‘;’ token
 } YYSTYPE;
          ^
src/libexpr/parser-tab.hh:147:10: error: conflicting declaration ‘typedef int YYSTYPE’
In file included from src/libexpr/parser.y:53:0:
src/libexpr/parser-tab.hh:147:3: note: previous declaration as ‘typedef union YYSTYPE YYSTYPE’
 } YYSTYPE;
   ^
make: *** [src/libexpr/parser-tab.o] Error 1

And apparently this was because my bison was old

| yacc -V       
yacc - 1.9 20070509
| bison -V
bison (GNU Bison) 2.4.1

I updated this to bison 3.0 (in the script above), and the errors went away, but flex needs to be updated

  GEN    Makefile.config
  CXX    src/libexpr/parser-tab.o
In file included from src/libexpr/parser-tab.cc:255:0:
src/libexpr/parser-tab.hh:124:15: error: redefinition of ‘union YYSTYPE’
 typedef union YYSTYPE
               ^
In file included from src/libexpr/parser.y:53:0:
src/libexpr/parser-tab.hh:124:15: error: previous definition of ‘union YYSTYPE’
 typedef union YYSTYPE
               ^
In file included from src/libexpr/parser-tab.cc:255:0:
src/libexpr/parser-tab.hh:147:10: error: invalid type in declaration before ‘;’ token
 } YYSTYPE;
          ^
src/libexpr/parser-tab.hh:147:10: error: conflicting declaration ‘typedef int YYSTYPE’
In file included from src/libexpr/parser.y:53:0:
src/libexpr/parser-tab.hh:147:3: note: previous declaration as ‘typedef union YYSTYPE YYSTYPE’
 } YYSTYPE;
   ^

And updating to flex 2.5.39 seems to remove the remaining errors. Now, on adding the channel

bash-4.1$ nix-channel --add http://nixos.org/channels/nixpkgs-unstable
Can't load '/scratch/gopinath/usr/nix-boot/lib/perl5/site_perl/5.10.1/x86_64-linux-thread-multi/auto/Nix/Store/Store.so' for module Nix::Store: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /scratch/gopinath/usr/nix-boot/lib/perl5/site_perl/5.10.1/x86_64-linux-thread-multi/auto/Nix/Store/Store.so) at /usr/lib64/perl5/XSLoader.pm line 70.
 at /scratch/gopinath/usr/nix-boot/lib/perl5/site_perl/5.10.1/x86_64-linux-thread-multi/Nix/Store.pm line 38
Compilation failed in require at /scratch/gopinath/usr/nix-boot/lib/perl5/site_perl/5.10.1/x86_64-linux-thread-multi/Nix/Manifest.pm line 13.
BEGIN failed--compilation aborted at /scratch/gopinath/usr/nix-boot/lib/perl5/site_perl/5.10.1/x86_64-linux-thread-multi/Nix/Manifest.pm line 13.
Compilation failed in require at /scratch/gopinath/usr/nix-boot/bin/nix-channel line 8.
BEGIN failed--compilation aborted at /scratch/gopinath/usr/nix-boot/bin/nix-channel line 8.

This was resolved by setting LD_LIBRARY_PATH to look in $nix_boot/lib64 After that, the guide asks me to install nix with

bash-4.1$ cat ~/.nixpkgs/config.nix 
pkgs:
{
  packageOverrides = self: {
    nix = self.nix.override {
      storeDir = "/scratch/gopinath/nix/store";
      stateDir = "/scratch/gopinath/nix/var";
    };
  };
}

bash-4.1$ nix-env -iA nix
error: attribute ‘nix’ in selection path ‘nix’ not found

It seems that here is a solution. So,

$ nix-env -iA nix -f ~/.nix-defexpr/channels/nixpkgs
...
building tests/test-suite.log
make[5]: Entering directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23'
building all
make  all-recursive
make[6]: Entering directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23'
building all-recursive
Making all in po
make[7]: Entering directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23/po'
building check-macro-version
make[7]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23/po'
Making all in .
make[7]: Entering directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23'
make[7]: Nothing to be done for `all-am'.
make[7]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23'
Making all in gnulib-tests
make[7]: Entering directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23/gnulib-tests'
building all
make  all-recursive
make[8]: Entering directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23/gnulib-tests'
building all-recursive
Making all in .
make[9]: Entering directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23/gnulib-tests'
make[9]: Nothing to be done for `all-am'.
make[9]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23/gnulib-tests'
make[8]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23/gnulib-tests'
make[7]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23/gnulib-tests'
make[6]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23'
make[5]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23'
...
============================================================================
Testsuite summary for GNU coreutils 8.23
============================================================================
# TOTAL: 563
# PASS:  439
# SKIP:  120
# XFAIL: 0
# FAIL:  3
# XPASS: 0
# ERROR: 1
============================================================================
See ./tests/test-suite.log
Please report to bug-coreutils@gnu.org
============================================================================
make[4]: *** [tests/test-suite.log] Error 1
make[4]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23'
make[3]: *** [check-TESTS] Error 2
make[3]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23'
make[2]: *** [check-am] Error 2
make[2]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/tmp/nix-build-coreutils-8.23.drv-0/coreutils-8.23'
make: *** [check] Error 2
builder for ‘/scratch/gopinath/nix/store/1rcj45a27mz06rlw354k1zzwvz0wf24k-coreutils-8.23.drv’ failed
 with exit code 2
cannot build derivation ‘/scratch/gopinath/nix/store/m2v75p5m7irqh0z2af5idypkil9v630m-stdenv.drv’: 1
 dependencies couldn't be built
cannot build derivation ‘/scratch/gopinath/nix/store/sp3ic057ydmkv4cnxrbgz016ivy3lac3-nix-1.8.drv’: 
1 dependencies couldn't be built
error: build of ‘/scratch/gopinath/nix/store/sp3ic057ydmkv4cnxrbgz016ivy3lac3-nix-1.8.drv’ failed

So core-utils fails. Now what do I do? The error test is

...
ERROR: tests/chown/separator
============================

id: cannot find name for user ID 44172
separator.sh: set-up failure: 
...

And fails are

FAIL: tests/misc/help-version
=============================

0+1 records in
0+1 records out
whoami: cannot find name for user ID 44172
FAIL: whoami
FAIL: tests/id/uid
==================

id: cannot find name for user ID 44172
id: : no such user
id: 44172: no such user
id: 44172: no such user
id: +44172: no such user
id: 44172: no such user
id: 44172: no such user
id: +44172: no such user
id: 44172: no such user
id: 44172: no such user
id: +44172: no such user
...
FAIL: tests/id/zero
===================

id: cannot find name for user ID 44172
uid=44172 gid=16473 groups=16473,5087,5105,10550,12244,13985,14073,20416
id: 44172: no such user
id: 44172: no such user
....
id: cannot find name for group ID 16473
id: cannot find name for group ID 16473
....
--- exp 2015-04-12 04:20:21.655856440 +0000
+++ out2        2015-04-12 04:20:21.660856355 +0000
@@ -1,5 +1,17 @@
@@ -1,5 +1,17 @@

-id -g[z] 44172: id -gn[z] 44172: id -gr[z] 44172: id -grn[z] 44172: id -G[z] 44172: id -Gn[z] 44172
: id -Gr[z] 44172: id -Grn[z] 44172: id -u[z] 44172: id -un[z] 44172: id -ur[z] 44172: id -urn[z] 44
172: id -g[z] root: 0
+id -g[z] 44172: 
+id -gn[z] 44172: 
...

So I installed coreutils-8.23 on the same prefix, and tried again. Unfortunately, the above test errors anyway. It seems that it is always trying to use the system id irrespective of the path settings.

It seemed that I could hack through by disabling doChecks in the coreutils-8.23.drv file. So I cloned the repo https://github.com/nixos/nixpkgs and set NIXPKGS enviornment variable pointing to it. Next, I modified the pkgs/tools/misc/coreutils/default.nix so that doCheck = false always. Next I executed

nix-env -iA nix -f $NIXPKGS
...
FAIL: tests/dump-db.sh
running test tests/case-hack.sh
+ clearStore
+ echo 'clearing store...'
clearing store...
+ chmod -R +w /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/store
+ rm -rf /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/store
+ mkdir /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/store
+ rm -rf /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/db
+ mkdir /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/db
+ nix-store --init
+ clearProfiles
+ profiles=/tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/var/nix/profiles
+ rm -rf /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/var/nix/profiles
+ rm -f /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/var/nix/gcroots/auto/mqgm5a11kh8r74bbz2gzygddh00lakss
+ rm -f /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/var/nix/gcroots/ref
+ rm -rf /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/case
+ opts='--option use-case-hack true'
+ nix-store --option use-case-hack true --restore /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/case
+ nix-store --option use-case-hack true --dump /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/case
+ cmp case.nar /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/case.nar
++ nix-hash --option use-case-hack true --type sha256 /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/case
++ nix-hash --flat --type sha256 case.nar
+ '[' ccd0c2353fbb6ff6853088e01f0557e8b9cbc9d11d2e1f8435175dc08091c2a3 = ccd0c2353fbb6ff6853088e01f0557e8b9cbc9d11d2e1f8435175dc08091c2a3 ']'
+ touch /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/case/xt_CONNMARK.h~nix~case~hack~3
+ nix-store --option use-case-hack true --dump /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/case
error: file name collision in between ‘/tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/case/xt_CONNMARK.h’ and ‘/tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/case/xt_CONNMARK.h~nix~case~hack~3’
PASS: tests/case-hack.sh
running test tests/check-reqs.sh
+ RESULT=/tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/result
+ nix-build -o /tmp/nix-build-nix-1.8.drv-0/nix-1.8/tests/test-tmp/result check-reqs.nix -A test1
download-from-binary-cache.pl: cannot figure out user name at /scratch/gopinath/nix/store/9313bj65al5bm42q6fiw7y74ayjxli1h-nix-1.8/libexec/nix/substituters/download-from-binary-cache.pl line 48.
error: substituter ‘download-from-binary-cache.pl’ died unexpectedly
FAIL: tests/check-reqs.sh
30 out of 42 tests failed 
mk/tests.mk:11: recipe for target 'installcheck' failed
make: *** [installcheck] Error 1
builder for ‘/scratch/gopinath/nix/store/fl8hcbq2cqpadbdrlh2cf5zmafx79r6z-nix-1.8.drv’ failed with exit code 2
error: build of ‘/scratch/gopinath/nix/store/fl8hcbq2cqpadbdrlh2cf5zmafx79r6z-nix-1.8.drv’ failed

So I disabled doInstallCheck in pkgs/tools/package-management/nix/default.nix. Here are my changes so far

diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix
index 1dc5bfa..635ae2c 100644
--- a/pkgs/tools/misc/coreutils/default.nix
+++ b/pkgs/tools/misc/coreutils/default.nix
@@ -59,7 +59,8 @@ let
     # (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025),
     # Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351),
     # and {Open,Free}BSD.
-    doCheck = stdenv ? glibc;
+    doCheck = false;
+    # stdenv ? glibc;

     # Saw random failures like ‘help2man: can't get '--help' info from
     # man/sha512sum.td/sha512sum’.
diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix
index 2d10511..f272bf7 100644
--- a/pkgs/tools/package-management/nix/default.nix
+++ b/pkgs/tools/package-management/nix/default.nix
@@ -43,7 +43,7 @@ stdenv.mkDerivation rec {

   installFlags = "sysconfdir=$(out)/etc";

-  doInstallCheck = true;
+  doInstallCheck = false;

   crossAttrs = {
     postUnpack =

Next, I ran nix-env -iA nix -f $NIXPKGS ; which resulted in

downloading Nix expressions from ‘http://nixos.org/releases/nixpkgs/nixpkgs-15.05pre59184.e07ea5c/nixexprs.tar.xz’...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
unpacking channels...
installing ‘nix-1.8’
error: opening lock file ‘/nix/var/nix/profiles/default.lock’: No such file or directory

I had passed --localstatedir=$nix_root/var" to the configure. So why is it not using that directory?

fictitious commented 9 years ago

I think it's because of this line in nix/configure.ac https://github.com/NixOS/nix/blob/master/configure.ac#L47

# State should be stored in /nix/var, unless the user overrides it explicitly.
test "$localstatedir" = '${prefix}/var' && localstatedir=/nix/var

That is, if your $localstatedir is $prefix/var, it's replaced with /nix/var, even if, as in your case, you did override it explicitly.

I have no idea why it's doing this, my workaround was to use something else for $localstatedir when configuring nix.

vrthra commented 9 years ago

But my prefix is /scratch/gopinath/usr/nix-boot and localstatedir is /scratch/gopinath/nix/var !

fictitious commented 9 years ago

Sorry, mixed up nix-boot and nix-root. Must be something else then.

vrthra commented 9 years ago

It seems to be picking it up from somewhere else I can see in nix/config.status

S["storedir"]="/scratch/gopinath/nix/store"
S["localstatedir"]="/scratch/gopinath/nix/var"

I have also tried setting

export NIX_STORE_DIR=$nix_root/store
export NIX_STATE_DIR=$nix_root/var

in the environment, I dont know why nix-env is not picking up those settings at least.

vrthra commented 9 years ago

So apparently, the problem was a link from $HOME/.nix-profile to /nix/var/nix/profiles/default that got created at some time. If I remove this link, nix-env -iA nix -f $NIXPKGS succeeds. Now, I am stuck with the final step in the wiki .

$ ln -s $HOME/nix/var/nix/profiles/default $HOME/.nix-profile

Unfortunately in my case, /scratch/gopinath/nix/var/nix/profiles does not have a default directory, but a per-user/gopinath/channels/... directory

fictitious commented 9 years ago

For what it worth, it works for me on Ubuntu 12.10 with these steps:

  1. install all prerequisites.
  2. configure and build nix

            ./configure --enable-gc --prefix=/home/artem/src/nix/install-1.8 \
                     --with-store-dir=/home/artem/src/nix/store   \
                     --localstatedir=/home/artem/src/nix/var 
            make
            make install
            mkdir ~/.nix-defexpr
  3. git clone nixpkgs into some directory, say, $NIXPKGS
  4. create ~/.nixpkgs/config.nix with these overrides:

          ...
          storeDir = "/home/artem/src/nix/store";
          stateDir = "/home/artem/src/nix/var";
          ...
  5. temporarily add /home/artem/src/nix/install-1.8/bin to PATH, then

          nix-env -iA nix -f $NIXPKGS

this will download and bootstrap stdenv, and build nix again with all dependencies, as expected.

restore PATH

Note that the resulting nix is configured in step 4 to use the same store and state dirs as bootstrap nix in step 2, so when I'm doing

            /home/artem/src/nix/var/nix/profiles/default/bin/nix-env -iA nix -f $NIXPKGS

it just says

               replacing old ‘nix-1.8’
               installing ‘nix-1.8’

and does nothing else, as expected - it finds that nix is already in the store.

I see these differences from your setup:

fictitious commented 9 years ago

Also, you can check how the nix that you build in-store is configured

    nix-instantiate --eval -E  'with import ./<your-nixpkgs-dir-here>  { } ; nix.configureFlags'

in my case, it prints

"--with-store-dir=/home/artem/src/nix/store --localstatedir=/home/artem/src/nix/var --sysconfdir=/etc\n--with-dbi=/home/artem/src/nix/store/24bhn7pfxnky9afna225aj86p5khfc3l-perl-DBI-1.631/lib/perl5/site_perl\n--with-dbd-sqlite=/home/artem/src/nix/store/9fyh8wa9wcqb6l5789lpp9f4csj1361h-perl-DBD-SQLite-1.44/lib/perl5/site_perl\n--with-www-curl=/home/artem/src/nix/store/g4r6dfbr3yhmgcnvx40l5ablgjliy3h1-perl-WWW-Curl-4.17/lib/perl5/site_perl\n--disable-init-state\n--enable-gc\n"

so it picks up --with-store-dir and --localstatedir from ~/.nixpkgs/config.nix

Also, you can check if it sees ~/.nixpkgs/config.nix at all like this:

      nix-instantiate --eval -E  'with import ./<your-nixpkgs-dir-here>  { } ; config'

if it's there, it prints

       { packageOverrides = <LAMBDA>; }

when I remove it, it prints

       {  }
vrthra commented 9 years ago

Thanks, I am rebuilding the entire thing. I will update once it is done.

vrthra commented 9 years ago

I was able to complete the installation once I fixed the link $HOME/.nix-profile.

$ nix-instantiate --eval -E  'with import /scratch/gopinath/nixpkgs  { } ; nix.configureFlags'

"--with-store-dir=/scratch/gopinath/nix/store --localstatedir=/scratch/gopinath/nix/var --sysconfdir=/etc\n--with-dbi=/scratch/gopinath/nix/store/8chh42ypqq8zx9pa0w7mry309d6pyawk-perl-DBI-1.631/lib/perl5/site_perl\n--with-dbd-sqlite=/scratch/gopinath/nix/store/zvi44yi1ahpabnca9dibs4w1qs6c9mh6-perl-DBD-SQLite-1.44/lib/perl5/site_perl\n--with-www-curl=/scratch/gopinath/nix/store/96gnqa8q99czrx3n2p3svvvxcdppr2fj-perl-WWW-Curl-4.17/lib/perl5/site_perl\n--disable-init-state\n--enable-gc\n"

Invoking it nix-env -iA nix -f $NIXPKGS seems to work

I am now trying to see which of my steps are absolutely necessary. Thanks for all the help.

vrthra commented 9 years ago

So, after going through the complete steps again, and using steps from @fictitious here is what I found. The set of absolutely required packages for my platform (I had to upgrade these packages, some of which are mentioned in the wiki, while (starred) others are not.). The versions are what I tested with, and were latest versions at this time.:

bison-3.0.tar.gz*        DBI-1.631.tar.gz            libxml2-2.9.2.tar.gz*
bzip2-1.0.6.tar.gz      flex-2.5.39.tar.bz2         libxslt-1.1.28.tar.gz*
coreutils-8.23.tar.xz*   WWW-Curl-4.15.tar.gz
curl-7.35.0.tar.lzma    gcc-4.9.2.tar.gz*
DBD-SQLite-1.40.tar.gz  sqlite-autoconf-3080300.tar.gz

I also did not enable gc, but enabled static nix. I also still had to remove the nonet, and also add pthread to LDFLAGS.

./configure  --enable-static  --enable-static-nix  --prefix=$nix_boot --with-store-dir=$nix_root/store --localstatedir=$nix_root/var;
/usr/bin/perl -pi -e 's#--nonet# #g' doc/manual/local.mk;
echo "GLOBAL_LDFLAGS += -lpthread" >> doc/manual/local.mk;

I checked out git@github.com:nixos/nixpkgs.git to ~/.nix-defexpr rather than using $NIXPKGS for convenience.

Now, the only problem I find when executing nix-env -iA nix is that, the doCheck fails on nix and its requirement coreutils fails on doInstallCheck (the errors same as given previously). So my changes were

diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix
index 1dc5bfa..635ae2c 100644
--- a/pkgs/tools/misc/coreutils/default.nix
+++ b/pkgs/tools/misc/coreutils/default.nix
@@ -59,7 +59,8 @@ let
     # (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025),
     # Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351),
     # and {Open,Free}BSD.
-    doCheck = stdenv ? glibc;
+    doCheck = false;

     # Saw random failures like ‘help2man: can't get '--help' info from
     # man/sha512sum.td/sha512sum’.
diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix
index 2d10511..f272bf7 100644
--- a/pkgs/tools/package-management/nix/default.nix
+++ b/pkgs/tools/package-management/nix/default.nix
@@ -43,7 +43,7 @@ stdenv.mkDerivation rec {

   installFlags = "sysconfdir=$(out)/etc";

-  doInstallCheck = true;
+  doInstallCheck = false;

   crossAttrs = {
     postUnpack =

With these changes, nix-env -i nix goes through, and I verified that the system works by using $ nix-instantiate --eval -E 'with import /scratch/gopinath/nixpkgs { } ; nix.configureFlags' and also by installing ruby, python, ghc, and jdk8

vcunat commented 9 years ago

Coreutils check problems: we don't have these on Hydra and I also haven't seen them locally (when rebuilding stdenv+coreutils+nix a few times). They're probably related to you not using chrooted builds and to coreutils tests being often bogus (and thus unreliable, e.g. https://github.com/NixOS/nixpkgs/issues/5652, https://github.com/NixOS/nixpkgs/issues/6306).

qqldd commented 9 years ago

@vrthra @vcunat I got to here from @vrthra original threads in superuser.

I also have same issue here and I went through similar steps as @vrthra did.

I am now using the prooted method from here: https://nixos.org/wiki/How_to_install_nix_in_home_%28on_another_distribution%29

The last step fails: env NIX_STORE_DIR=$HOME/nix nix-env -i nix

It is because the coreutil. Here is my error:

ERROR: tests/rm/deep-2.sh
building tests/rm/dir-no-w.log
PASS: tests/rm/dir-no-w.sh
building tests/rm/dir-nonrecur.log
--
ERROR: tests/chown/separator.sh
building tests/cp/abuse.log
PASS: tests/cp/abuse.sh
building tests/cp/acl.log
--
ERROR: tests/du/long-from-unreadable.sh
building tests/du/long-sloop.log
long-sloop.sh: skipped test: Your system appears to be able to handle more than $n symlinks
SKIP: tests/du/long-sloop.sh
--
# ERROR: 3

.. contents:: :depth: 2

--
ERROR: tests/rm/deep-2
======================

File name too long at -e line 2.
--
ERROR: tests/chown/separator
============================

id: cannot find name for user ID 1165
--
ERROR: tests/du/long-from-unreadable
====================================

File name too long at -e line 2.
--
# ERROR: 3
============================================================================
See ./tests/test-suite.log
Please report to bug-coreutils@gnu.org

I am not sure about the File name too long at -e line 2 problem with rm and du. But for chown, @vrthra and I have similar id: cannot find name for user ID 1165 problem. I believe it is because the user is not store locally which means the /etc/passwd does not store the username. The server I use should use the LDAP authentication. I can get my user using getent passwd with no problem.

Do you have any ideas to solve the coreutil problem? Or how can I configure the coreutil package (to remove the check) using the nix-env -i nix command?

Thanks!

vcunat commented 9 years ago

You should be able to switch off the check phase by defining a packageOverrides for coreutils in your config.nix. See wiki e.g. pkgs.mu for details; you need to add doCheck = false;.

fowlay commented 9 years ago

About the coreutils problem: I have tried out installing Nix on a Ubuntu 14.04 system without root privileges, except that I used root privileges for the installation of some prerequisites from the official Ubuntu repository. My steps are in principle the following:

  1. Install prerequisites, approximately these: libbz2-dev (1.0.6-5), sqlite3 (3.8.2-1ubuntu2.1), libsqlite3-dev (3.8.2-1ubuntu2.1), libcurl4-openssl-dev (7.35.0-1ubuntu2.5), libdbi-perl (1.630-1), libdbd-sqlite3-perl (1.40-3).
  2. Build and install the nix-1.9 source tarball to a directory of mine, configured to find the Nix store under another directory of mine.
  3. Sourcing etc/profile.d/nix.sh, appending my PATH with the path of the built-from-source Nix and set up to use the nixpkgs-unstable channel.
  4. Finally do `nix-env --install --attr nixpkgs.nix'

The 4th steps causes a bootstrapping where the GNU toolchain and other utilities are installed in the Nix store. Coreutils is among these packages.

Initially I ran into the problem with one of the coreutils tests failing, just like others in this thread. I could not figure out how to set up a "packageOverrides" definition to achieve "doCheck = false".

However, it turns out that if I install the 'unscd' package (using Synaptic, with root privileges) and repeat the bootstrapping then it runs to completion, and coreutils is indeed installed in the Nix store. Unscd is described as a "Micro Name Service Caching Daemon" and one of its benefits is to speed up name resolutions.

The unscd daemon starts automatically upon installation and upon reboot in the Ubuntu environment. I did not make any changes to the installed default configuration file.

My host is on a corporate LAN and configured to use a centralized service for user authentication. Maybe this is significant; maybe the coreutils problem would not be there on a stand-alone Ubuntu installation with Internet access.

zhou13 commented 8 years ago

Is it possible to auto disable the check when custom directory is used?

ashgillman commented 8 years ago

I am trying to proot bootstrap like @qqldd.

As @fowlay found, I cannot use overrideDerivation, as suggested by @vcunat, to fix the issue. my config.nix is:

{
  packageOverrides = pkgs: {
    coreutils = pkgs.coreutils.overrideDerivation (oldAttrs : {
      doCheck = false;
      name = oldAttrs.name + "-user-install";
    });
    usrnix = pkgs.nix.override {
      storeDir = "/home/gil2a4/nix/store";
      stateDir = "/home/gil2a4/nix/var";
    };
  };
}

Then:

env NIX_STORE_DIR=/home/gil2a4/nix/store NIX_STATE_DIR=/home/gil2a4/nix/var nix-env -iA nixpkgs.coreutils

installs the correct, overridden coreutils, but

env NIX_STORE_DIR=/home/gil2a4/nix/store NIX_STATE_DIR=/home/gil2a4/nix/var nix-env -iA nixpkgs.usrnix

Uses the old coreutils.

I am trying to automate building, is there a way to fix this without changing the file in nixpkgs, I'd prefer not to have to pull my own copy of nixpkgs and patch the doCheck line

vcunat commented 8 years ago

As @zhou13 suggested, the checks are now disabled when using non-standard storeDir.

vrthra commented 8 years ago

Since coreutils is now fixed, I tried to run the manual installation again. This is the script I used:

#!/bin/bash
set -e
base=$1
shift;
export nix_boot=${NIX_BOOT-$base/nix-boot/usr}
export nix_root=${NIX_ROOT-$base/nix}
export RUN_EXPENSIVE_TESTS=no

export PATH=$nix_boot/bin:/usr/bin:/bin                           # wiki
export PKG_CONFIG_PATH=$nix_boot/lib/pkgconfig:$PKG_CONFIG_PATH   # wiki
export LDFLAGS="-L$nix_boot/lib -L$nix_boot/lib64 $LDFLAGS"       # wiki
export CPPFLAGS="-I$nix_boot/include $CPPFLAGS"                   # wiki
export PERL5OPT="-I$nix_boot/lib/perl"                            # wiki
#export PERL5OPT="-I$nix_boot/lib64/perl5"                        # wiki on some systems.
export NIXPKGS=$base/nix-boot/nixpkgs
unset PERL5LIB PERL_LOCAL_LIB_ROOT PERL_MB_OPT PERL_MM_OPT        # Perl INSTALLBASE error.

all="get prepare \
  gcc \
  bzip2 \
  curl \
  sqlite \
  dbi \
  dbd \
  wwwcurl \
  bison \
  flex \
  coreutils \
  nixbootstrap nix nixconfig nixprofile"

get() {
  # remove echo to download.
  echo wget -c $1
}
case $1 in
  -h) echo $all; exit 0;;
  get)
    mkdir -p src
    (cd ./static;
    files="https://nixos.org/releases/nix/nix-1.10/nix-1.10.tar.xz
           http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz
           http://curl.haxx.se/download/curl-7.35.0.tar.lzma
           https://www.sqlite.org/2014/sqlite-autoconf-3080300.tar.gz
           http://pkgs.fedoraproject.org/repo/extras/perl-DBI/DBI-1.631.tar.gz/444d3c305e86597e11092b517794a840/DBI-1.631.tar.gz
           http://pkgs.fedoraproject.org/repo/pkgs/perl-DBD-SQLite/DBD-SQLite-1.40.tar.gz/b9876882186499583428b14cf5c0e29c/DBD-SQLite-1.40.tar.gz
           http://search.cpan.org/CPAN/authors/id/S/SZ/SZBALINT/WWW-Curl-4.15.tar.gz
           http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz
           http://sourceforge.mirrorservice.org/f/fl/flex/flex-2.5.36.tar.gz
           https://ftp.gnu.org/gnu/gcc/gcc-4.9.2/gcc-4.9.2.tar.gz
           http://ftp.gnu.org/gnu/coreutils/coreutils-8.23.tar.xz"
      for i in $files;
      do
        y=$(echo $i | sed -e 's#.*/##g')
        get -c $i;
        case $i in
          *xz) xzcat $y;;
          *gz) zcat $y;;
          *lzma) xzcat $y;;
          *tar) cat $y;;
          *) cat $y;;
        esac | (cd ../src && tar -xvpf -)
      done )
    ;;
  -sh) $2; exit 0;;
bzip2)
(cd src/bzip2-1.0.6;
  make -f Makefile-libbz2_so;
  make install PREFIX=$nix_boot;
  cp libbz2.so.1.0 libbz2.so.1.0.6 $nix_boot/lib; ) ;;

curl)
(cd src/curl-7.35.0/;
  ./configure --prefix=$nix_boot;
  make;
  make install; ) ;;

sqlite)
(cd src/sqlite-autoconf-3080300/;
  ./configure --prefix=$nix_boot;
  make;
  make install; ) ;;

libxml2)
  (cd src/libxml2-2.9.2; ./configure --prefix=$nix_boot;
  make;
  cp ./libxml2-2.9.2/xmllint $nix_boot/bin
  # make install;
  ) ;;

libxslt)
  (cd src/libxslt-1.1.28;  ./configure --prefix=$nix_boot;
  make;
  make install; ) ;;

gcc)
  (cd src/gcc-4.9.2; ./contrib/download_prerequisites; )
  rm -rf src/gcc-objs;
  mkdir -p src/gcc-objs
  (cd src/gcc-objs; ./../gcc-4.9.2/configure --prefix=$nix_boot --disable-multilib;
  make;
  make install; ) ;;

bison)
  (cd src/bison-3.0*; ./configure --prefix=$nix_boot;
  make;
  make install; ) ;;

flex)
  (cd src/flex-2.5.*;  ./configure --prefix=$nix_boot;
  make;
  make install; );;

coreutils)
  (cd src/coreutils-8.23;  ./configure --enable-install-program=hostname --prefix=$nix_boot;
  make;
  make install; );;

bash)
  (cd src/bash-4.3;  ./configure --prefix=$nix_boot;
  make;
  make install; );;

dbi)
(cd src/DBI-1.631/;
  echo perl Makefile.PL PREFIX=$nix_boot PERLMAINCC=$nix_boot/bin/gcc > myconfig.sh;
  chmod +x myconfig.sh;
  ./myconfig.sh;
  make;
  make install; ) ;;

dbd)
(cd src/DBD-SQLite-1.40/;
  echo perl Makefile.PL PREFIX=$nix_boot PERLMAINCC=$nix_boot/bin/gcc > myconfig.sh;
  chmod +x myconfig.sh;
  ./myconfig.sh;
  make;
  make install; ) ;;

wwwcurl)
(cd src/WWW-Curl-4.15;
  echo perl Makefile.PL PREFIX=$nix_boot PERLMAINCC=$nix_boot/bin/gcc > myconfig.sh;
  chmod +x myconfig.sh;
  ./myconfig.sh;
  make;
  make install; ) ;;

prepare)
  rm -rf nix
  rm -rf $NIXPKGS
  rm -rf ~/.nix-profile
  git clone https://github.com/NixOS/nix nix
  git clone git@github.com:NixOS/nixpkgs.git $NIXPKGS
  ;;

nixbootstrap)
(cd nix;
  ./bootstrap.sh ) ;;

nix)
(cd nix;
  echo "./configure --prefix=$nix_boot \
                    --with-store-dir=$nix_root/store \
                    --localstatedir=$nix_root/var" > myconfig.sh;
  chmod +x ./myconfig.sh
  ./myconfig.sh
  # --with-coreutils-bin=$nix_boot/usr/bin;
  /usr/bin/perl -pi -e 's#--nonet# #g' doc/manual/local.mk;
  echo "GLOBAL_LDFLAGS += -lpthread" >> doc/manual/local.mk;
  make;
  make install; ) ;;

nixconfig)
  ( export LD_LIBRARY_PATH="$nix_boot/lib:$nix_boot/lib64:$LD_LIBRARY_PATH";
  echo $LD_LIBRARY_PATH;
  # nix-channel --add http://nixos.org/channels/nixpkgs-unstable && \
  # nix-channel --update &&
  # nix-env -i nix
  $nix_boot/bin/nix-env -iA nix -f $NIXPKGS )
  $nix_root/var/nix/profiles/default/bin/nix-env -iA nix -f $NIXPKGS
 ;;

nixprofile)
  ln -s $nix_root/var/nix/profiles/default $HOME/.nix-profile
  ;;

all) for i in $all;
     do env nix_boot=$nix_boot nix_root=$nix_root ./$0 $i ;
     done ;;

*) echo $0 '<install-base>' all
   echo $all;
   echo nix_root=$nix_root
   echo nix_boot=$nix_boot
   echo PATH=$PATH
   echo PKG_CONFIG_PATH=$PKG_CONFIG_PATH
   echo LDFLAGS=$LDFLAGS
   echo CPPFLAGS=$CPPFLAGS
   echo PERL5OPT=$PERL5OPT
   echo NIXPKGS=$NIXPKGS ;;
esac

It can be executed by giving a base directory on which nix-boot and nix-store should be created, and the target to be executed. For example, to do the complete installation the target is all

./nix-install.sh /scratch/gopinatr all

So with the latest checkout, I have another problem. nix-env fails to read the store.

./nix-install.sh /scratch/gopinatr nixconfig
error: current Nix store schema is version 9, but I only support 7

or

$nix_root/var/nix/profiles/default/bin/nix-env -iA nix -f $NIXPKGS
error: current Nix store schema is version 9, but I only support 7

However, the nix-env that I installed in $nix_boot/usr/bin/nix-env has no problems with the store.

bash-4.2$ export LD_LIBRARY_PATH=/scratch/gopinatr/nix-boot/usr/lib:/scratch/gopinatr/nix-boot/usr/lib64:
bash-4.2$ $nix_boot/bin/nix-env -iA nix -f $NIXPKGS
replacing old ‘nix-1.11.2’
installing ‘nix-1.11.2’
veprbl commented 8 years ago

@vrthra I just found myself in the same situation. If you bootstrap using nix from git, the resulting store won't work with nix-1.11.

vrthra commented 8 years ago

I was inspecting ./nixpkgs/pkgs/tools/package-management/nix and found that I will have to use nix-1.12pre4523_3b81b26 Now, using that instead of nix-1.11 (update in the previous shell script)

nixconfig)
  (
  export LD_LIBRARY_PATH="$nix_boot/lib:$nix_boot/lib64:$LD_LIBRARY_PATH";
  $nix_boot/bin/nix-env -i nix-1.12pre4523_3b81b26 -f $NIXPKGS )
  $nix_root/var/nix/profiles/default/bin/nix-env -i nix-1.12pre4523_3b81b26 -f $NIXPKGS
 ;;

Running this

bash-4.2$ $nix_boot/bin/nix-env -i nix-1.12pre4523_3b81b26 -f $NIXPKGS
replacing old ‘nix-1.12pre4523_3b81b26’
installing ‘nix-1.12pre4523_3b81b26’
bash-4.2$ unset LD_LIBRARY_PATH
bash-4.2$ $nix_root/var/nix/profiles/default/bin/nix-env -i nix-1.12pre4523_3b81b26 -f $NIXPKGS
error: creating directory ‘/nix’: Permission denied
....
shrinking RPATHs of ELF executables and libraries in /scratch/gopinatr/nix/store/56npz4ixahpqk4304cyyas2v866lvi1j-nix-1.12pre4523_3b81b26-debug
patching script interpreter paths in /scratch/gopinatr/nix/store/56npz4ixahpqk4304cyyas2v866lvi1j-nix-1.12pre4523_3b81b26-debug

building path(s) ‘/scratch/gopinatr/nix/store/cqz9cjn8nmiqqyd5b997c9qyx2p09b9n-user-environment’
created 115 symlinks in user environment
error: creating directory ‘/nix’: Permission denied
veprbl commented 8 years ago

You will have to update ~/.nixpkgs/config.nix to override unstable version with nixUnstable = self.nix.override {.

vrthra commented 8 years ago

Could you please share your command lines too? I have now

pkgs:
{
  packageOverrides = self: {
    nixUnstable = self.nix.override {
      storeDir = "/scratch/gopinatr/nix/store";
      stateDir = "/scratch/gopinatr/nix/var";
    };
  };
}

How do I install nixUnstable now? running

$nix_boot/bin/nix-env -i nix -f $NIXPKGS

seems to install nix-1.11.2 rather than nix-1.12pre4523_3b81b26

veprbl commented 8 years ago

Oh, sorry nixUnstable = self.nixUnstable.override {

vrthra commented 8 years ago

Something is still wrong for me.

pkgs:
{
  packageOverrides = self: {
    nixUnstable = self.nixUnstable.override {
      storeDir = "/scratch/gopinatr/nix/store";
      stateDir = "/scratch/gopinatr/nix/var";
    };
  };
}

And command line

bash-4.2$ $nix_boot/bin/nix-env -iA nixUnstable -f $NIXPKGS
replacing old ‘nix-1.12pre4523_3b81b26’
installing ‘nix-1.12pre4523_3b81b26’
bash-4.2$ unset LD_LIBRARY_PATH
bash-4.2$ $nix_root/var/nix/profiles/default/bin/nix-env -iA nixUnstable -f $NIXPKGS
error: current Nix store schema is version 9, but I only support 7
veprbl commented 8 years ago

@vrthra It seems like revision 3b81b26 is too old https://github.com/NixOS/nix/blob/3b81b2645706d7f8d9c0ec228426dee8ef1fc7ac/src/libstore/local-store.hh#L22 I'm out of ideas.

veprbl commented 8 years ago

Got one. Try editing nixpkgs/pkgs/tools/package-management/nix/default.nix to set unstable to use e.g. nix-1.12pre4663_1b5b654

veprbl commented 8 years ago

In that case url needs update http://hydra.nixos.org/build/36462474/download/3/ as in http://hydra.nixos.org/build/36462474

vrthra commented 8 years ago

It seems http://hydra.nixos.org/build/36462474/download/3/nix-1.12pre4663_1b5b654.tar.xz is 404.

groxxda commented 8 years ago

Probably https://github.com/NixOS/hydra/issues/321 Can you use nix-store -r /nix/store/lyxnia5x46wigvxf0cc26x2s673hiwrn-nix-tarball-1.12pre4663_1b5b654/tarballs/nix-1.12pre4663_1b5b654.tar.xz ?

vrthra commented 8 years ago

@groxxda I did not understand what you meant? The file nix-1.12pre4663_1b5b654.tar.xz is not present in my system. Did you mean for me to download it from somewhere else?

i.e

bash-4.2$ ./usr/bin/nix-store -r $nix_root/nix/store/lyxnia5x46wigvxf0cc26x2s673hiwrn-nix-tarball-1.12pre4663_1b5b654/tarballs/nix-1.12pre4663_1b5b654.tar.xz
error: getting status of ‘/scratch/gopinatr/nix/nix/store/lyxnia5x46wigvxf0cc26x2s673hiwrn-nix-tarball-1.12pre4663_1b5b654/tarballs/nix-1.12pre4663_1b5b654.tar.xz’: No such file or directory
bash-4.2$ ./usr/bin/nix-store -r /nix/store/lyxnia5x46wigvxf0cc26x2s673hiwrn-nix-tarball-1.12pre4663_1b5b654/tarballs/nix-1.12pre4663_1b5b654.tar.xz
error: getting status of ‘/nix/store/lyxnia5x46wigvxf0cc26x2s673hiwrn-nix-tarball-1.12pre4663_1b5b654/tarballs/nix-1.12pre4663_1b5b654.tar.xz’: No such file or directory
bash-4.2$ find $nix_root -name nix-1.12pre4663_1b5b654.tar.xz
groxxda commented 8 years ago

For me nix-store -r ... downloads the file from the binary cache:

nix-store -r /nix/store/lyxnia5x46wigvxf0cc26x2s673hiwrn-nix-tarball-1.12pre4663_1b5b654/ 
these paths will be fetched (1.52 MiB download, 1.98 MiB unpacked):
  /nix/store/lyxnia5x46wigvxf0cc26x2s673hiwrn-nix-tarball-1.12pre4663_1b5b654
fetching path ‘/nix/store/lyxnia5x46wigvxf0cc26x2s673hiwrn-nix-tarball-1.12pre4663_1b5b654’...

*** Downloading ‘https://cache.nixos.org/nar/0ndrm5w5lwx3ln0mpbl92wnxvnpamxpkx0jg78qfkqym96d82n63.nar.xz’ (signed by ‘cache.nixos.org-1’) to ‘/nix/store/lyxnia5x46wigvxf0cc26x2s673hiwrn-nix-tarball-1.12pre4663_1b5b654’...
veprbl commented 8 years ago

@groxxda This probably doesn't work for installation with storage in home.

vrthra commented 8 years ago

@veprbl @groxxda I used a VM to install Nix, and used that vm to download using nix-store -r as you mentioned. Using that, I was able to install

bash-4.2$ $nix_boot/bin/nix-env -iA nixUnstable -f $NIXPKGS
...
building path(s) ‘/scratch/gopinatr/nix/store/dl9zv5lqa3amsnn5n09sh2zv5y3h2i2c-user-environment’
created 5 symlinks in user environment
bash-4.2$ unset LD_LIBRARY_PATH
bash-4.2$ $nix_root/var/nix/profiles/default/bin/nix-env -iA nixUnstable -f $NIXPKGS
replacing old ‘nix-1.11.2’
installing ‘nix-1.11.2’
building path(s) ‘/scratch/gopinatr/nix/store/biaf7h3cl5c1z07rmdm8mzwgp2yds5rw-user-environment’
created 5 symlinks in user environment
bash-4.2$ nix-env -q
nix-1.11.2
bash-4.2$ which nix-env
/nfs/stak/students/g/gopinatr/.nix-profile/bin/nix-env

Thanks for all the help! I suppose once the nix 1.11.2 is released, users will be able to download the tarball any way, so this seems to be fixed!.

vrthra commented 8 years ago

Related: #691 #692 #569 #566 #324 #295

nh2 commented 5 years ago

FAIL: tests/id/zero

We observed a similar coreutils test failure without custom directory:

https://github.com/nh2/static-haskell-nix/issues/29

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

stale[bot] commented 2 years ago

I closed this issue due to inactivity. → More info