Move some corepkgs into the nix binary

This commit is contained in:
Eelco Dolstra 2020-03-11 16:41:22 +01:00
parent e02481ded2
commit 9950cdec35
8 changed files with 23 additions and 7 deletions

View file

@ -1,4 +1,7 @@
corepkgs_FILES = buildenv.nix unpack-channel.nix derivation.nix fetchurl.nix imported-drv-to-derivation.nix corepkgs_FILES = \
unpack-channel.nix \
derivation.nix \
fetchurl.nix
$(foreach file,config.nix $(corepkgs_FILES),$(eval $(call install-data-in,$(d)/$(file),$(datadir)/nix/corepkgs))) $(foreach file,config.nix $(corepkgs_FILES),$(eval $(call install-data-in,$(d)/$(file),$(datadir)/nix/corepkgs)))

View file

@ -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 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)) $(eval $(call install-file-in, $(d)/nix-expr.pc, $(prefix)/lib/pkgconfig, 0644))
$(d)/primops.cc: $(d)/imported-drv-to-derivation.nix.gen.hh

View file

@ -121,10 +121,17 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
mkString(*(outputsVal->listElems()[outputs_index++]), o.first); mkString(*(outputsVal->listElems()[outputs_index++]), o.first);
} }
w.attrs->sort(); w.attrs->sort();
Value fun;
state.evalFile(settings.nixDataDir + "/nix/corepkgs/imported-drv-to-derivation.nix", fun); static Value * fun = nullptr;
state.forceFunction(fun, pos); if (!fun) {
mkApp(v, fun, w); 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); state.forceAttrs(v, pos);
} else { } else {
state.forceAttrs(*args[0]); state.forceAttrs(*args[0]);

View file

@ -106,7 +106,9 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
/* Get the environment builder expression. */ /* Get the environment builder expression. */
Value envBuilder; Value envBuilder;
state.evalFile(state.findFile("nix/buildenv.nix"), envBuilder); state.eval(state.parseExprFromString(
#include "buildenv.nix.gen.hh"
, "/"), envBuilder);
/* Construct a Nix expression that calls the user environment /* Construct a Nix expression that calls the user environment
builder with the manifest as argument. */ builder with the manifest as argument. */

View file

@ -23,3 +23,5 @@ $(foreach name, \
nix-build nix-channel nix-collect-garbage nix-copy-closure nix-daemon nix-env nix-hash nix-instantiate nix-prefetch-url nix-shell nix-store, \ nix-build nix-channel nix-collect-garbage nix-copy-closure nix-daemon nix-env nix-hash nix-instantiate nix-prefetch-url nix-shell nix-store, \
$(eval $(call install-symlink, nix, $(bindir)/$(name)))) $(eval $(call install-symlink, nix, $(bindir)/$(name))))
$(eval $(call install-symlink, $(bindir)/nix, $(libexecdir)/nix/build-remote)) $(eval $(call install-symlink, $(bindir)/nix, $(libexecdir)/nix/build-remote))
src/nix-env/nix-env.cc: src/nix-env/buildenv.nix.gen.hh

View file

@ -1,7 +1,7 @@
with import ./lib.nix; with import ./lib.nix;
with builtins; with builtins;
assert pathExists <nix/buildenv.nix>; assert pathExists <nix/fetchurl.nix>;
assert length __nixPath == 6; assert length __nixPath == 6;
assert length (filter (x: x.prefix == "nix") __nixPath) == 1; assert length (filter (x: x.prefix == "nix") __nixPath) == 1;