Author: eelco
Date: Tue Jan  3 00:16:29 2012
New Revision: 31219
URL: https://nixos.org/websvn/nix/?rev=31219&sc=1

Log:
* Refactoring: Get rid of a few subdirectories in corepkgs/, and some
  other simplifications.
* Use <nix/...> to locate the corepkgs.  This allows them to be
  overriden through $NIX_PATH.
* Use bash's pipefail option in the NAR builder so that we don't need
  to create a temporary file.

Added:
   nix/trunk/corepkgs/buildenv.nix
      - copied, changed from r31218, 
nix/branches/multiple-outputs-sandbox/corepkgs/buildenv/default.nix
   nix/trunk/corepkgs/buildenv.pl   (contents, props changed)
      - copied, changed from r31218, 
nix/branches/multiple-outputs-sandbox/corepkgs/buildenv/builder.pl.in
   nix/trunk/corepkgs/nar.nix
      - copied, changed from r31218, nix/trunk/corepkgs/nar/nar.nix
Deleted:
   nix/trunk/corepkgs/buildenv/
   nix/trunk/corepkgs/nar/
Modified:
   nix/trunk/corepkgs/Makefile.am
   nix/trunk/scripts/nix-push.in
   nix/trunk/src/nix-env/user-env.cc
   nix/trunk/tests/common.sh.in
   nix/trunk/tests/init.sh
   nix/trunk/tests/lang.sh
   nix/trunk/tests/lang/eval-okay-search-path.nix
   nix/trunk/tests/user-envs.sh

Modified: nix/trunk/corepkgs/Makefile.am
==============================================================================
--- nix/trunk/corepkgs/Makefile.am      Mon Jan  2 19:25:08 2012        (r31218)
+++ nix/trunk/corepkgs/Makefile.am      Tue Jan  3 00:16:29 2012        (r31219)
@@ -1 +1,11 @@
-SUBDIRS = nar buildenv channels
+SUBDIRS = channels
+
+all-local: config.nix
+
+install-exec-local:
+       $(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
+       $(INSTALL_DATA) config.nix $(srcdir)/nar.nix $(srcdir)/buildenv.nix 
$(srcdir)/buildenv.pl $(DESTDIR)$(datadir)/nix/corepkgs
+
+include ../substitute.mk
+
+EXTRA_DIST = config.nix.in nar.nix buildenv.nix buildenv.pl

Copied and modified: nix/trunk/corepkgs/buildenv.nix (from r31218, 
nix/branches/multiple-outputs-sandbox/corepkgs/buildenv/default.nix)
==============================================================================
--- nix/branches/multiple-outputs-sandbox/corepkgs/buildenv/default.nix Mon Jan 
 2 19:25:08 2012        (r31218, copy source)
+++ nix/trunk/corepkgs/buildenv.nix     Tue Jan  3 00:16:29 2012        (r31219)
@@ -1,9 +1,12 @@
-{system, derivations, manifest}:
+with import <nix/config.nix>;
+
+{ system, derivations, manifest }:
 
 derivation { 
   name = "user-environment";
   system = system;
-  builder = ./builder.pl;
+  builder = perl;
+  args = [ "-w" ./buildenv.pl ];
   
   manifest = manifest;
 

Copied and modified: nix/trunk/corepkgs/buildenv.pl (from r31218, 
nix/branches/multiple-outputs-sandbox/corepkgs/buildenv/builder.pl.in)
==============================================================================
--- nix/branches/multiple-outputs-sandbox/corepkgs/buildenv/builder.pl.in       
Mon Jan  2 19:25:08 2012        (r31218, copy source)
+++ nix/trunk/corepkgs/buildenv.pl      Tue Jan  3 00:16:29 2012        (r31219)
@@ -1,5 +1,3 @@
-#! @perl@ -w
-
 use strict;
 use Cwd;
 use IO::Handle;

Copied and modified: nix/trunk/corepkgs/nar.nix (from r31218, 
nix/trunk/corepkgs/nar/nar.nix)
==============================================================================
--- nix/trunk/corepkgs/nar/nar.nix      Mon Jan  2 19:25:08 2012        
(r31218, copy source)
+++ nix/trunk/corepkgs/nar.nix  Tue Jan  3 00:16:29 2012        (r31219)
@@ -1,7 +1,30 @@
+with import <nix/config.nix>;
+
+let
+
+  builder = builtins.toFile "nar.sh"
+    ''
+      export PATH=${nixBinDir}:${coreutils}
+
+      echo "packing ‘$storePath’..."
+      mkdir $out
+      dst=$out/tmp.nar.bz2
+
+      set -o pipefail
+      nix-store --dump "$storePath" | ${bzip2} > $dst
+
+      nix-hash --flat --type $hashAlgo --base32 $dst > $out/narbz2-hash
+
+      mv $out/tmp.nar.bz2 $out/$(cat $out/narbz2-hash).nar.bz2
+    '';
+
+in
+
 { system, storePath, hashAlgo }:
 
 derivation {
   name = "nar";
-  builder = ./nar.sh;
+  builder = shell;
+  args = [ "-e" builder ];
   inherit system storePath hashAlgo;
 }

Modified: nix/trunk/scripts/nix-push.in
==============================================================================
--- nix/trunk/scripts/nix-push.in       Mon Jan  2 19:25:08 2012        (r31218)
+++ nix/trunk/scripts/nix-push.in       Tue Jan  3 00:16:29 2012        (r31219)
@@ -20,9 +20,6 @@
 
 my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
 
-my $dataDir = $ENV{"NIX_DATA_DIR"};
-$dataDir = "@datadir@" unless defined $dataDir;
-
 
 # Parse the command line.
 my $localCopy;
@@ -107,7 +104,7 @@
 
     # Construct a Nix expression that creates a Nix archive.
     my $nixexpr = 
-        "((import $dataDir/nix/corepkgs/nar/nar.nix) " .
+        "(import <nix/nar.nix> " .
         "{ storePath = builtins.storePath \"$storePath\"; system = 
\"@system@\"; hashAlgo = \"$hashAlgo\"; }) ";
     
     print NIX $nixexpr;

Modified: nix/trunk/src/nix-env/user-env.cc
==============================================================================
--- nix/trunk/src/nix-env/user-env.cc   Mon Jan  2 19:25:08 2012        (r31218)
+++ nix/trunk/src/nix-env/user-env.cc   Tue Jan  3 00:16:29 2012        (r31219)
@@ -112,7 +112,7 @@
 
     /* Get the environment builder expression. */
     Value envBuilder;
-    state.evalFile(nixDataDir + "/nix/corepkgs/buildenv", envBuilder);
+    state.evalFile(state.findFile("nix/buildenv.nix"), envBuilder);
 
     /* Construct a Nix expression that calls the user environment
        builder with the manifest as argument. */

Modified: nix/trunk/tests/common.sh.in
==============================================================================
--- nix/trunk/tests/common.sh.in        Mon Jan  2 19:25:08 2012        (r31218)
+++ nix/trunk/tests/common.sh.in        Tue Jan  3 00:16:29 2012        (r31219)
@@ -9,7 +9,6 @@
     export NIX_IGNORE_SYMLINK_STORE=1
     NIX_STORE_DIR=$TEST_ROOT/store
 fi
-export NIX_DATA_DIR=$TEST_ROOT/data
 export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
 export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
 export NIX_STATE_DIR=$TEST_ROOT/var/nix
@@ -19,15 +18,11 @@
 export NIX_LIBEXEC_DIR=$TEST_ROOT/bin
 export NIX_MANIFESTS_DIR=$TEST_ROOT/var/nix/manifests
 export NIX_ROOT_FINDER=
+export NIX_PATH=nix=$TOP/corepkgs
 export SHARED=$TEST_ROOT/shared
 
 export PATH=$NIX_BIN_DIR:$TOP/scripts:$PATH
 
-export REAL_BIN_DIR=@bindir@
-export REAL_LIBEXEC_DIR=@libexecdir@
-export REAL_LOCALSTATE_DIR=@localstatedir@
-export REAL_DATA_DIR=@datadir@
-export REAL_STORE_DIR=@storedir@
 export NIX_BUILD_HOOK=
 export PERL=perl
 export PERL5LIB=$TOP/perl/lib:$PERL5LIB

Modified: nix/trunk/tests/init.sh
==============================================================================
--- nix/trunk/tests/init.sh     Mon Jan  2 19:25:08 2012        (r31218)
+++ nix/trunk/tests/init.sh     Tue Jan  3 00:16:29 2012        (r31219)
@@ -10,7 +10,6 @@
 mkdir "$TEST_ROOT"
 
 mkdir "$NIX_STORE_DIR"
-mkdir "$NIX_DATA_DIR"
 mkdir "$NIX_LOCALSTATE_DIR"
 mkdir -p "$NIX_LOG_DIR"/drvs
 mkdir "$NIX_STATE_DIR"
@@ -39,29 +38,6 @@
 fsync-metadata = false
 EOF
 
-mkdir $NIX_DATA_DIR/nix
-cp -pr $TOP/corepkgs $NIX_DATA_DIR/nix/
-# Bah, scripts have the prefix hard-coded.  This is really messy stuff
-# (and likely to fail).
-for i in \
-    $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh \
-    ; do
-    sed < $i > $i.tmp \
-        -e "s^$REAL_BIN_DIR/nix-store^$NIX_BIN_DIR/nix-store^" \
-        -e "s^$REAL_BIN_DIR/nix-hash^$NIX_BIN_DIR/nix-hash^" \
-        -e "s^$REAL_LIBEXEC_DIR^$NIX_LIBEXEC_DIR^" \
-        -e "s^$REAL_LOCALSTATE_DIR^$NIX_LOCALSTATE_DIR^" \
-        -e "s^$REAL_DATA_DIR^$NIX_DATA_DIR^" \
-        -e "s^$REAL_STORE_DIR\([^/]\)^$NIX_STORE_DIR\1^"
-    mv $i.tmp $i
-    chmod +x $i
-done
-
-# Another ugly hack.
-sed "s|^$|PATH='$PATH'|" < $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh > tmp
-chmod +x tmp
-mv tmp $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh
-
 # An uberhack for Mac OS X 10.5: download-using-manifests uses Perl,
 # and Perl links against Darwin's libutil.dylib (in /usr/lib), but
 # when running "make check", the libtool wrapper script around the Nix

Modified: nix/trunk/tests/lang.sh
==============================================================================
--- nix/trunk/tests/lang.sh     Mon Jan  2 19:25:08 2012        (r31218)
+++ nix/trunk/tests/lang.sh     Tue Jan  3 00:16:29 2012        (r31219)
@@ -40,7 +40,7 @@
         if test -e lang/$i.flags; then
             flags=$(cat lang/$i.flags)
         fi
-        if ! NIX_PATH=lang/dir3:lang/dir4 nix-instantiate $flags --eval-only 
--strict lang/$i.nix > lang/$i.out; then
+        if ! NIX_PATH=lang/dir3:lang/dir4:$NIX_PATH nix-instantiate $flags 
--eval-only --strict lang/$i.nix > lang/$i.out; then
             echo "FAIL: $i should evaluate"
             fail=1
         elif ! diff lang/$i.out lang/$i.exp; then

Modified: nix/trunk/tests/lang/eval-okay-search-path.nix
==============================================================================
--- nix/trunk/tests/lang/eval-okay-search-path.nix      Mon Jan  2 19:25:08 
2012        (r31218)
+++ nix/trunk/tests/lang/eval-okay-search-path.nix      Tue Jan  3 00:16:29 
2012        (r31219)
@@ -1,3 +1,3 @@
-assert builtins.pathExists <nix/buildenv>;
+assert builtins.pathExists <nix/buildenv.nix>;
 
 import <a.nix> + import <b.nix> + import <c.nix> + import <dir5/c.nix>

Modified: nix/trunk/tests/user-envs.sh
==============================================================================
--- nix/trunk/tests/user-envs.sh        Mon Jan  2 19:25:08 2012        (r31218)
+++ nix/trunk/tests/user-envs.sh        Tue Jan  3 00:16:29 2012        (r31219)
@@ -36,7 +36,7 @@
 test "$($profiles/test/bin/foo)" = "foo-2.0pre1"
 
 # Upgrade "foo": should install foo-2.0.
-NIX_PATH=nixpkgs=./user-envs.nix nix-env -p $profiles/test -f '<nixpkgs>' -u 
foo
+NIX_PATH=nixpkgs=./user-envs.nix:$NIX_PATH nix-env -p $profiles/test -f 
'<nixpkgs>' -u foo
 
 # Query installed: should contain foo-2.0 now.
 test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
_______________________________________________
nix-commits mailing list
nix-comm...@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to