mirror of
https://github.com/NixOS/nix
synced 2025-07-07 14:21:48 +02:00
Merge remote-tracking branch 'origin/master' into flakes
This commit is contained in:
commit
35f6651735
10 changed files with 24 additions and 13 deletions
|
@ -146,8 +146,8 @@ public:
|
|||
Expr * parseExprFromFile(const Path & path, StaticEnv & staticEnv);
|
||||
|
||||
/* Parse a Nix expression from the specified string. */
|
||||
Expr * parseExprFromString(const string & s, const Path & basePath, StaticEnv & staticEnv);
|
||||
Expr * parseExprFromString(const string & s, const Path & basePath);
|
||||
Expr * parseExprFromString(std::string_view s, const Path & basePath, StaticEnv & staticEnv);
|
||||
Expr * parseExprFromString(std::string_view s, const Path & basePath);
|
||||
|
||||
Expr * parseStdin();
|
||||
|
||||
|
|
21
src/libexpr/imported-drv-to-derivation.nix
Normal file
21
src/libexpr/imported-drv-to-derivation.nix
Normal file
|
@ -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
|
|
@ -39,3 +39,5 @@ $(eval $(call install-file-in, $(d)/nix-expr.pc, $(prefix)/lib/pkgconfig, 0644))
|
|||
|
||||
$(foreach i, $(wildcard src/libexpr/flake/*.hh), \
|
||||
$(eval $(call install-file-in, $(i), $(includedir)/nix/flake, 0644)))
|
||||
|
||||
$(d)/primops.cc: $(d)/imported-drv-to-derivation.nix.gen.hh
|
||||
|
|
|
@ -611,13 +611,13 @@ Expr * EvalState::parseExprFromFile(const Path & path, StaticEnv & staticEnv)
|
|||
}
|
||||
|
||||
|
||||
Expr * EvalState::parseExprFromString(const string & s, const Path & basePath, StaticEnv & staticEnv)
|
||||
Expr * EvalState::parseExprFromString(std::string_view s, const Path & basePath, StaticEnv & staticEnv)
|
||||
{
|
||||
return parse(s.c_str(), "(string)", basePath, staticEnv);
|
||||
return parse(s.data(), "(string)", basePath, staticEnv);
|
||||
}
|
||||
|
||||
|
||||
Expr * EvalState::parseExprFromString(const string & s, const Path & basePath)
|
||||
Expr * EvalState::parseExprFromString(std::string_view s, const Path & basePath)
|
||||
{
|
||||
return parseExprFromString(s, basePath, staticBaseEnv);
|
||||
}
|
||||
|
|
|
@ -122,10 +122,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]);
|
||||
|
|
25
src/nix-env/buildenv.nix
Normal file
25
src/nix-env/buildenv.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ derivations, manifest }:
|
||||
|
||||
derivation {
|
||||
name = "user-environment";
|
||||
system = "builtin";
|
||||
builder = "builtin:buildenv";
|
||||
|
||||
inherit manifest;
|
||||
|
||||
# !!! grmbl, need structured data for passing this in a clean way.
|
||||
derivations =
|
||||
map (d:
|
||||
[ (d.meta.active or "true")
|
||||
(d.meta.priority or 5)
|
||||
(builtins.length d.outputs)
|
||||
] ++ map (output: builtins.getAttr output d) d.outputs)
|
||||
derivations;
|
||||
|
||||
# Building user environments remotely just causes huge amounts of
|
||||
# network traffic, so don't do that.
|
||||
preferLocalBuild = true;
|
||||
|
||||
# Also don't bother substituting.
|
||||
allowSubstitutes = false;
|
||||
}
|
|
@ -106,7 +106,9 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
|
||||
/* Get the environment builder expression. */
|
||||
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
|
||||
builder with the manifest as argument. */
|
||||
|
|
|
@ -24,4 +24,6 @@ $(foreach name, \
|
|||
$(eval $(call install-symlink, nix, $(bindir)/$(name))))
|
||||
$(eval $(call install-symlink, $(bindir)/nix, $(libexecdir)/nix/build-remote))
|
||||
|
||||
src/nix-env/nix-env.cc: src/nix-env/buildenv.nix.gen.hh
|
||||
|
||||
$(d)/flake.cc: $(d)/flake-template.nix.gen.hh
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue