about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2012-01-03T14·01+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2012-01-03T14·01+0000
commit921111d1972388a0aa1841c545c753cb996c9257 (patch)
treeab965ec07c63db0649c8d9871f6c72813b2696a9 /src
parent6c31232e1494d1d68a31fb8433dbf593f831dff2 (diff)
* Move the implementation of the ‘derivation’ primop into a separate
  file.

Diffstat (limited to 'src')
-rw-r--r--src/libexpr/eval.cc4
-rw-r--r--src/libexpr/primops.cc24
2 files changed, 3 insertions, 25 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 2b97b76fb776..bba14bc35491 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -148,8 +148,6 @@ EvalState::EvalState()
     nrAttrsets = nrOpUpdates = nrOpUpdateValuesCopied = 0;
     deepestStack = (char *) -1;
 
-    createBaseEnv();
-    
     allowUnsafeEquality = getEnv("NIX_NO_UNSAFE_EQ", "") == "";
 
 #if HAVE_BOEHMGC
@@ -188,6 +186,8 @@ EvalState::EvalState()
     foreach (Strings::iterator, i, paths) addToSearchPath(*i);
     addToSearchPath("nix=" + nixDataDir + "/nix/corepkgs");
     searchPathInsertionPoint = searchPath.begin();
+
+    createBaseEnv();
 }
 
 
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index ca7766487cd4..02c444cd6b86 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -1099,29 +1099,7 @@ void EvalState::createBaseEnv()
 
     /* Add a wrapper around the derivation primop that computes the
        `drvPath' and `outPath' attributes lazily. */
-    string s = "attrs: \
-      let \
-        strict = derivationStrict attrs; \
-        attrValues = attrs: \
-          map (name: builtins.getAttr name attrs) (builtins.attrNames attrs); \
-        outputToAttrListElement = output: \
-          { \
-            name = output; \
-            value = attrs // { \
-              outPath = builtins.getAttr (output + \"Path\") strict; \
-              drvPath = strict.drvPath; \
-              type = \"derivation\"; \
-              currentOutput = output; \
-            } // outputsAttrs // { all = allList; }; \
-          }; \
-        outputsList = if attrs ? outputs then \
-          map outputToAttrListElement attrs.outputs else \
-          [ (outputToAttrListElement \"out\") ]; \
-        outputsAttrs = builtins.listToAttrs outputsList; \
-        allList = attrValues outputsAttrs; \
-        head = if attrs ? outputs then builtins.head attrs.outputs else \"out\"; \
-      in builtins.getAttr head outputsAttrs";
-    mkThunk_(v, parseExprFromString(s, "/"));
+    mkThunk_(v, parseExprFromFile(findFile("nix/derivation.nix")));
     addConstant("derivation", v);
 
     /* Now that we've added all primops, sort the `builtins' attribute