aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-03-11 16:41:22 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-03-11 16:57:48 +0100
commit9950cdec3514949942a79c58764b1ea9bf9d5d57 (patch)
treee514f3102570c3e10034e0c1476b863ca289504e /src/libexpr
parente02481ded216ffb5b06b413e3695d4e11e62e02f (diff)
Move some corepkgs into the nix binary
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/imported-drv-to-derivation.nix21
-rw-r--r--src/libexpr/local.mk2
-rw-r--r--src/libexpr/primops.cc15
3 files changed, 34 insertions, 4 deletions
diff --git a/src/libexpr/imported-drv-to-derivation.nix b/src/libexpr/imported-drv-to-derivation.nix
new file mode 100644
index 000000000..eab8b050e
--- /dev/null
+++ b/src/libexpr/imported-drv-to-derivation.nix
@@ -0,0 +1,21 @@
+attrs @ { drvPath, outputs, name, ... }:
+
+let
+
+ commonAttrs = (builtins.listToAttrs outputsList) //
+ { all = map (x: x.value) outputsList;
+ inherit drvPath name;
+ type = "derivation";
+ };
+
+ outputToAttrListElement = outputName:
+ { name = outputName;
+ value = commonAttrs // {
+ outPath = builtins.getAttr outputName attrs;
+ inherit outputName;
+ };
+ };
+
+ outputsList = map outputToAttrListElement outputs;
+
+in (builtins.head outputsList).value
diff --git a/src/libexpr/local.mk b/src/libexpr/local.mk
index 26b9f14ba..8a9b3c2ea 100644
--- a/src/libexpr/local.mk
+++ b/src/libexpr/local.mk
@@ -31,3 +31,5 @@ clean-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexe
dist-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh
$(eval $(call install-file-in, $(d)/nix-expr.pc, $(prefix)/lib/pkgconfig, 0644))
+
+$(d)/primops.cc: $(d)/imported-drv-to-derivation.nix.gen.hh
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 4cd28698c..8de234951 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -121,10 +121,17 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
mkString(*(outputsVal->listElems()[outputs_index++]), o.first);
}
w.attrs->sort();
- Value fun;
- state.evalFile(settings.nixDataDir + "/nix/corepkgs/imported-drv-to-derivation.nix", fun);
- state.forceFunction(fun, pos);
- mkApp(v, fun, w);
+
+ static Value * fun = nullptr;
+ if (!fun) {
+ fun = state.allocValue();
+ state.eval(state.parseExprFromString(
+ #include "imported-drv-to-derivation.nix.gen.hh"
+ , "/"), *fun);
+ }
+
+ state.forceFunction(*fun, pos);
+ mkApp(v, *fun, w);
state.forceAttrs(v, pos);
} else {
state.forceAttrs(*args[0]);