mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
Merge branch 'master' into push-rrzylpqynznw
This commit is contained in:
commit
82397e220d
16 changed files with 133 additions and 107 deletions
90
docker.nix
90
docker.nix
|
@ -1,6 +1,10 @@
|
||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
# Core dependencies
|
||||||
lib ? pkgs.lib,
|
pkgs,
|
||||||
|
lib,
|
||||||
|
runCommand,
|
||||||
|
buildPackages,
|
||||||
|
# Image configuration
|
||||||
name ? "nix",
|
name ? "nix",
|
||||||
tag ? "latest",
|
tag ? "latest",
|
||||||
bundleNixpkgs ? true,
|
bundleNixpkgs ? true,
|
||||||
|
@ -14,36 +18,52 @@
|
||||||
gid ? 0,
|
gid ? 0,
|
||||||
uname ? "root",
|
uname ? "root",
|
||||||
gname ? "root",
|
gname ? "root",
|
||||||
|
# Default Packages
|
||||||
|
nix,
|
||||||
|
bashInteractive,
|
||||||
|
coreutils-full,
|
||||||
|
gnutar,
|
||||||
|
gzip,
|
||||||
|
gnugrep,
|
||||||
|
which,
|
||||||
|
curl,
|
||||||
|
less,
|
||||||
|
wget,
|
||||||
|
man,
|
||||||
|
cacert,
|
||||||
|
findutils,
|
||||||
|
iana-etc,
|
||||||
|
gitMinimal,
|
||||||
|
openssh,
|
||||||
|
# Other dependencies
|
||||||
|
shadow,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
defaultPkgs =
|
defaultPkgs = [
|
||||||
with pkgs;
|
nix
|
||||||
[
|
bashInteractive
|
||||||
nix
|
coreutils-full
|
||||||
bashInteractive
|
gnutar
|
||||||
coreutils-full
|
gzip
|
||||||
gnutar
|
gnugrep
|
||||||
gzip
|
which
|
||||||
gnugrep
|
curl
|
||||||
which
|
less
|
||||||
curl
|
wget
|
||||||
less
|
man
|
||||||
wget
|
cacert.out
|
||||||
man
|
findutils
|
||||||
cacert.out
|
iana-etc
|
||||||
findutils
|
gitMinimal
|
||||||
iana-etc
|
openssh
|
||||||
git
|
] ++ extraPkgs;
|
||||||
openssh
|
|
||||||
]
|
|
||||||
++ extraPkgs;
|
|
||||||
|
|
||||||
users =
|
users =
|
||||||
{
|
{
|
||||||
|
|
||||||
root = {
|
root = {
|
||||||
uid = 0;
|
uid = 0;
|
||||||
shell = "${pkgs.bashInteractive}/bin/bash";
|
shell = lib.getExe bashInteractive;
|
||||||
home = "/root";
|
home = "/root";
|
||||||
gid = 0;
|
gid = 0;
|
||||||
groups = [ "root" ];
|
groups = [ "root" ];
|
||||||
|
@ -52,7 +72,7 @@ let
|
||||||
|
|
||||||
nobody = {
|
nobody = {
|
||||||
uid = 65534;
|
uid = 65534;
|
||||||
shell = "${pkgs.shadow}/bin/nologin";
|
shell = lib.getExe' shadow "nologin";
|
||||||
home = "/var/empty";
|
home = "/var/empty";
|
||||||
gid = 65534;
|
gid = 65534;
|
||||||
groups = [ "nobody" ];
|
groups = [ "nobody" ];
|
||||||
|
@ -63,7 +83,7 @@ let
|
||||||
// lib.optionalAttrs (uid != 0) {
|
// lib.optionalAttrs (uid != 0) {
|
||||||
"${uname}" = {
|
"${uname}" = {
|
||||||
uid = uid;
|
uid = uid;
|
||||||
shell = "${pkgs.bashInteractive}/bin/bash";
|
shell = lib.getExe bashInteractive;
|
||||||
home = "/home/${uname}";
|
home = "/home/${uname}";
|
||||||
gid = gid;
|
gid = gid;
|
||||||
groups = [ "${gname}" ];
|
groups = [ "${gname}" ];
|
||||||
|
@ -170,7 +190,7 @@ let
|
||||||
baseSystem =
|
baseSystem =
|
||||||
let
|
let
|
||||||
nixpkgs = pkgs.path;
|
nixpkgs = pkgs.path;
|
||||||
channel = pkgs.runCommand "channel-nixos" { inherit bundleNixpkgs; } ''
|
channel = runCommand "channel-nixos" { inherit bundleNixpkgs; } ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
if [ "$bundleNixpkgs" ]; then
|
if [ "$bundleNixpkgs" ]; then
|
||||||
ln -s ${
|
ln -s ${
|
||||||
|
@ -182,11 +202,11 @@ let
|
||||||
echo "[]" > $out/manifest.nix
|
echo "[]" > $out/manifest.nix
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
rootEnv = pkgs.buildPackages.buildEnv {
|
rootEnv = buildPackages.buildEnv {
|
||||||
name = "root-profile-env";
|
name = "root-profile-env";
|
||||||
paths = defaultPkgs;
|
paths = defaultPkgs;
|
||||||
};
|
};
|
||||||
manifest = pkgs.buildPackages.runCommand "manifest.nix" { } ''
|
manifest = buildPackages.runCommand "manifest.nix" { } ''
|
||||||
cat > $out <<EOF
|
cat > $out <<EOF
|
||||||
[
|
[
|
||||||
${lib.concatStringsSep "\n" (
|
${lib.concatStringsSep "\n" (
|
||||||
|
@ -215,7 +235,7 @@ let
|
||||||
]
|
]
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
profile = pkgs.buildPackages.runCommand "user-environment" { } ''
|
profile = buildPackages.runCommand "user-environment" { } ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
cp -a ${rootEnv}/* $out/
|
cp -a ${rootEnv}/* $out/
|
||||||
ln -s ${manifest} $out/manifest.nix
|
ln -s ${manifest} $out/manifest.nix
|
||||||
|
@ -228,7 +248,7 @@ let
|
||||||
else
|
else
|
||||||
flake-registry;
|
flake-registry;
|
||||||
in
|
in
|
||||||
pkgs.runCommand "base-system"
|
runCommand "base-system"
|
||||||
{
|
{
|
||||||
inherit
|
inherit
|
||||||
passwdContents
|
passwdContents
|
||||||
|
@ -289,8 +309,8 @@ let
|
||||||
echo "${channelURL} ${channelName}" > $out${userHome}/.nix-channels
|
echo "${channelURL} ${channelName}" > $out${userHome}/.nix-channels
|
||||||
|
|
||||||
mkdir -p $out/bin $out/usr/bin
|
mkdir -p $out/bin $out/usr/bin
|
||||||
ln -s ${pkgs.coreutils}/bin/env $out/usr/bin/env
|
ln -s ${lib.getExe' coreutils-full "env"} $out/usr/bin/env
|
||||||
ln -s ${pkgs.bashInteractive}/bin/bash $out/bin/sh
|
ln -s ${lib.getExe bashInteractive} $out/bin/sh
|
||||||
|
|
||||||
''
|
''
|
||||||
+ (lib.optionalString (flake-registry-path != null) ''
|
+ (lib.optionalString (flake-registry-path != null) ''
|
||||||
|
@ -299,7 +319,7 @@ let
|
||||||
globalFlakeRegistryPath="$nixCacheDir/flake-registry.json"
|
globalFlakeRegistryPath="$nixCacheDir/flake-registry.json"
|
||||||
ln -s ${flake-registry-path} $out$globalFlakeRegistryPath
|
ln -s ${flake-registry-path} $out$globalFlakeRegistryPath
|
||||||
mkdir -p $out/nix/var/nix/gcroots/auto
|
mkdir -p $out/nix/var/nix/gcroots/auto
|
||||||
rootName=$(${pkgs.nix}/bin/nix --extra-experimental-features nix-command hash file --type sha1 --base32 <(echo -n $globalFlakeRegistryPath))
|
rootName=$(${lib.getExe' nix "nix"} --extra-experimental-features nix-command hash file --type sha1 --base32 <(echo -n $globalFlakeRegistryPath))
|
||||||
ln -s $globalFlakeRegistryPath $out/nix/var/nix/gcroots/auto/$rootName
|
ln -s $globalFlakeRegistryPath $out/nix/var/nix/gcroots/auto/$rootName
|
||||||
'')
|
'')
|
||||||
);
|
);
|
||||||
|
@ -331,7 +351,7 @@ pkgs.dockerTools.buildLayeredImageWithNixDb {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
Cmd = [ (lib.getExe pkgs.bashInteractive) ];
|
Cmd = [ (lib.getExe bashInteractive) ];
|
||||||
User = "${toString uid}:${toString gid}";
|
User = "${toString uid}:${toString gid}";
|
||||||
Env = [
|
Env = [
|
||||||
"USER=${uname}"
|
"USER=${uname}"
|
||||||
|
|
|
@ -404,8 +404,7 @@
|
||||||
dockerImage =
|
dockerImage =
|
||||||
let
|
let
|
||||||
pkgs = nixpkgsFor.${system}.native;
|
pkgs = nixpkgsFor.${system}.native;
|
||||||
image = import ./docker.nix {
|
image = pkgs.callPackage ./docker.nix {
|
||||||
inherit pkgs;
|
|
||||||
tag = pkgs.nix.version;
|
tag = pkgs.nix.version;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
|
@ -484,7 +484,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||||
auto path = state->coerceToPath(noPos, v, context, "while evaluating the filename to edit");
|
auto path = state->coerceToPath(noPos, v, context, "while evaluating the filename to edit");
|
||||||
return {path, 0};
|
return {path, 0};
|
||||||
} else if (v.isLambda()) {
|
} else if (v.isLambda()) {
|
||||||
auto pos = state->positions[v.payload.lambda.fun->pos];
|
auto pos = state->positions[v.lambda().fun->pos];
|
||||||
if (auto path = std::get_if<SourcePath>(&pos.origin))
|
if (auto path = std::get_if<SourcePath>(&pos.origin))
|
||||||
return {*path, pos.line};
|
return {*path, pos.line};
|
||||||
else
|
else
|
||||||
|
|
|
@ -252,7 +252,7 @@ const char * nix_get_path_string(nix_c_context * context, const nix_value * valu
|
||||||
// We could use v.path().to_string().c_str(), but I'm concerned this
|
// We could use v.path().to_string().c_str(), but I'm concerned this
|
||||||
// crashes. Looks like .path() allocates a CanonPath with a copy of the
|
// crashes. Looks like .path() allocates a CanonPath with a copy of the
|
||||||
// string, then it gets the underlying data from that.
|
// string, then it gets the underlying data from that.
|
||||||
return v.payload.path.path;
|
return v.pathStr();
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS_NULL
|
NIXC_CATCH_ERRS_NULL
|
||||||
}
|
}
|
||||||
|
|
|
@ -667,8 +667,8 @@ namespace nix {
|
||||||
auto v = eval("derivation");
|
auto v = eval("derivation");
|
||||||
ASSERT_EQ(v.type(), nFunction);
|
ASSERT_EQ(v.type(), nFunction);
|
||||||
ASSERT_TRUE(v.isLambda());
|
ASSERT_TRUE(v.isLambda());
|
||||||
ASSERT_NE(v.payload.lambda.fun, nullptr);
|
ASSERT_NE(v.lambda().fun, nullptr);
|
||||||
ASSERT_TRUE(v.payload.lambda.fun->hasFormals());
|
ASSERT_TRUE(v.lambda().fun->hasFormals());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PrimOpTest, currentTime) {
|
TEST_F(PrimOpTest, currentTime) {
|
||||||
|
|
|
@ -204,7 +204,7 @@ FrameInfo SampleStack::getFrameInfoFromValueAndPos(const Value & v, std::span<Va
|
||||||
/* NOTE: No actual references to garbage collected values are not held in
|
/* NOTE: No actual references to garbage collected values are not held in
|
||||||
the profiler. */
|
the profiler. */
|
||||||
if (v.isLambda())
|
if (v.isLambda())
|
||||||
return LambdaFrameInfo{.expr = v.payload.lambda.fun, .callPos = pos};
|
return LambdaFrameInfo{.expr = v.lambda().fun, .callPos = pos};
|
||||||
else if (v.isPrimOp()) {
|
else if (v.isPrimOp()) {
|
||||||
return getPrimOpFrameInfo(*v.primOp(), args, pos);
|
return getPrimOpFrameInfo(*v.primOp(), args, pos);
|
||||||
} else if (v.isPrimOpApp())
|
} else if (v.isPrimOpApp())
|
||||||
|
|
|
@ -147,8 +147,8 @@ PosIdx Value::determinePos(const PosIdx pos) const
|
||||||
#pragma GCC diagnostic ignored "-Wswitch-enum"
|
#pragma GCC diagnostic ignored "-Wswitch-enum"
|
||||||
switch (internalType) {
|
switch (internalType) {
|
||||||
case tAttrs: return attrs()->pos;
|
case tAttrs: return attrs()->pos;
|
||||||
case tLambda: return payload.lambda.fun->pos;
|
case tLambda: return lambda().fun->pos;
|
||||||
case tApp: return payload.app.left->determinePos(pos);
|
case tApp: return app().left->determinePos(pos);
|
||||||
default: return pos;
|
default: return pos;
|
||||||
}
|
}
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
@ -160,10 +160,10 @@ bool Value::isTrivial() const
|
||||||
internalType != tApp
|
internalType != tApp
|
||||||
&& internalType != tPrimOpApp
|
&& internalType != tPrimOpApp
|
||||||
&& (internalType != tThunk
|
&& (internalType != tThunk
|
||||||
|| (dynamic_cast<ExprAttrs *>(payload.thunk.expr)
|
|| (dynamic_cast<ExprAttrs *>(thunk().expr)
|
||||||
&& ((ExprAttrs *) payload.thunk.expr)->dynamicAttrs.empty())
|
&& ((ExprAttrs *) thunk().expr)->dynamicAttrs.empty())
|
||||||
|| dynamic_cast<ExprLambda *>(payload.thunk.expr)
|
|| dynamic_cast<ExprLambda *>(thunk().expr)
|
||||||
|| dynamic_cast<ExprList *>(payload.thunk.expr));
|
|| dynamic_cast<ExprList *>(thunk().expr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -525,9 +525,9 @@ std::ostream & operator<<(std::ostream & output, const PrimOp & primOp)
|
||||||
|
|
||||||
const PrimOp * Value::primOpAppPrimOp() const
|
const PrimOp * Value::primOpAppPrimOp() const
|
||||||
{
|
{
|
||||||
Value * left = payload.primOpApp.left;
|
Value * left = primOpApp().left;
|
||||||
while (left && !left->isPrimOp()) {
|
while (left && !left->isPrimOp()) {
|
||||||
left = left->payload.primOpApp.left;
|
left = left->primOpApp().left;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!left)
|
if (!left)
|
||||||
|
@ -610,7 +610,7 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (v.isLambda()) {
|
if (v.isLambda()) {
|
||||||
auto exprLambda = v.payload.lambda.fun;
|
auto exprLambda = v.lambda().fun;
|
||||||
|
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
@ -1567,13 +1567,13 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
||||||
|
|
||||||
if (vCur.isLambda()) {
|
if (vCur.isLambda()) {
|
||||||
|
|
||||||
ExprLambda & lambda(*vCur.payload.lambda.fun);
|
ExprLambda & lambda(*vCur.lambda().fun);
|
||||||
|
|
||||||
auto size =
|
auto size =
|
||||||
(!lambda.arg ? 0 : 1) +
|
(!lambda.arg ? 0 : 1) +
|
||||||
(lambda.hasFormals() ? lambda.formals->formals.size() : 0);
|
(lambda.hasFormals() ? lambda.formals->formals.size() : 0);
|
||||||
Env & env2(allocEnv(size));
|
Env & env2(allocEnv(size));
|
||||||
env2.up = vCur.payload.lambda.env;
|
env2.up = vCur.lambda().env;
|
||||||
|
|
||||||
Displacement displ = 0;
|
Displacement displ = 0;
|
||||||
|
|
||||||
|
@ -1603,7 +1603,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
||||||
symbols[i.name])
|
symbols[i.name])
|
||||||
.atPos(lambda.pos)
|
.atPos(lambda.pos)
|
||||||
.withTrace(pos, "from call site")
|
.withTrace(pos, "from call site")
|
||||||
.withFrame(*fun.payload.lambda.env, lambda)
|
.withFrame(*fun.lambda().env, lambda)
|
||||||
.debugThrow();
|
.debugThrow();
|
||||||
}
|
}
|
||||||
env2.values[displ++] = i.def->maybeThunk(*this, env2);
|
env2.values[displ++] = i.def->maybeThunk(*this, env2);
|
||||||
|
@ -1630,7 +1630,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
||||||
.atPos(lambda.pos)
|
.atPos(lambda.pos)
|
||||||
.withTrace(pos, "from call site")
|
.withTrace(pos, "from call site")
|
||||||
.withSuggestions(suggestions)
|
.withSuggestions(suggestions)
|
||||||
.withFrame(*fun.payload.lambda.env, lambda)
|
.withFrame(*fun.lambda().env, lambda)
|
||||||
.debugThrow();
|
.debugThrow();
|
||||||
}
|
}
|
||||||
unreachable();
|
unreachable();
|
||||||
|
@ -1702,7 +1702,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
||||||
Value * primOp = &vCur;
|
Value * primOp = &vCur;
|
||||||
while (primOp->isPrimOpApp()) {
|
while (primOp->isPrimOpApp()) {
|
||||||
argsDone++;
|
argsDone++;
|
||||||
primOp = primOp->payload.primOpApp.left;
|
primOp = primOp->primOpApp().left;
|
||||||
}
|
}
|
||||||
assert(primOp->isPrimOp());
|
assert(primOp->isPrimOp());
|
||||||
auto arity = primOp->primOp()->arity;
|
auto arity = primOp->primOp()->arity;
|
||||||
|
@ -1718,8 +1718,8 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
||||||
|
|
||||||
Value * vArgs[maxPrimOpArity];
|
Value * vArgs[maxPrimOpArity];
|
||||||
auto n = argsDone;
|
auto n = argsDone;
|
||||||
for (Value * arg = &vCur; arg->isPrimOpApp(); arg = arg->payload.primOpApp.left)
|
for (Value * arg = &vCur; arg->isPrimOpApp(); arg = arg->primOpApp().left)
|
||||||
vArgs[--n] = arg->payload.primOpApp.right;
|
vArgs[--n] = arg->primOpApp().right;
|
||||||
|
|
||||||
for (size_t i = 0; i < argsLeft; ++i)
|
for (size_t i = 0; i < argsLeft; ++i)
|
||||||
vArgs[argsDone + i] = args[i];
|
vArgs[argsDone + i] = args[i];
|
||||||
|
@ -1825,14 +1825,14 @@ void EvalState::autoCallFunction(const Bindings & args, Value & fun, Value & res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fun.isLambda() || !fun.payload.lambda.fun->hasFormals()) {
|
if (!fun.isLambda() || !fun.lambda().fun->hasFormals()) {
|
||||||
res = fun;
|
res = fun;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto attrs = buildBindings(std::max(static_cast<uint32_t>(fun.payload.lambda.fun->formals->formals.size()), args.size()));
|
auto attrs = buildBindings(std::max(static_cast<uint32_t>(fun.lambda().fun->formals->formals.size()), args.size()));
|
||||||
|
|
||||||
if (fun.payload.lambda.fun->formals->ellipsis) {
|
if (fun.lambda().fun->formals->ellipsis) {
|
||||||
// If the formals have an ellipsis (eg the function accepts extra args) pass
|
// If the formals have an ellipsis (eg the function accepts extra args) pass
|
||||||
// all available automatic arguments (which includes arguments specified on
|
// all available automatic arguments (which includes arguments specified on
|
||||||
// the command line via --arg/--argstr)
|
// the command line via --arg/--argstr)
|
||||||
|
@ -1840,7 +1840,7 @@ void EvalState::autoCallFunction(const Bindings & args, Value & fun, Value & res
|
||||||
attrs.insert(v);
|
attrs.insert(v);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, only pass the arguments that the function accepts
|
// Otherwise, only pass the arguments that the function accepts
|
||||||
for (auto & i : fun.payload.lambda.fun->formals->formals) {
|
for (auto & i : fun.lambda().fun->formals->formals) {
|
||||||
auto j = args.get(i.name);
|
auto j = args.get(i.name);
|
||||||
if (j) {
|
if (j) {
|
||||||
attrs.insert(*j);
|
attrs.insert(*j);
|
||||||
|
@ -1850,7 +1850,7 @@ Nix attempted to evaluate a function as a top level expression; in
|
||||||
this case it must have its arguments supplied either by default
|
this case it must have its arguments supplied either by default
|
||||||
values, or passed explicitly with '--arg' or '--argstr'. See
|
values, or passed explicitly with '--arg' or '--argstr'. See
|
||||||
https://nixos.org/manual/nix/stable/language/constructs.html#functions.)", symbols[i.name])
|
https://nixos.org/manual/nix/stable/language/constructs.html#functions.)", symbols[i.name])
|
||||||
.atPos(i.pos).withFrame(*fun.payload.lambda.env, *fun.payload.lambda.fun).debugThrow();
|
.atPos(i.pos).withFrame(*fun.lambda().env, *fun.lambda().fun).debugThrow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2163,7 +2163,7 @@ void EvalState::forceValueDeep(Value & v)
|
||||||
try {
|
try {
|
||||||
// If the value is a thunk, we're evaling. Otherwise no trace necessary.
|
// If the value is a thunk, we're evaling. Otherwise no trace necessary.
|
||||||
auto dts = debugRepl && i.value->isThunk()
|
auto dts = debugRepl && i.value->isThunk()
|
||||||
? makeDebugTraceStacker(*this, *i.value->payload.thunk.expr, *i.value->payload.thunk.env, i.pos,
|
? makeDebugTraceStacker(*this, *i.value->thunk().expr, *i.value->thunk().env, i.pos,
|
||||||
"while evaluating the attribute '%1%'", symbols[i.name])
|
"while evaluating the attribute '%1%'", symbols[i.name])
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
|
@ -2368,7 +2368,7 @@ BackedStringView EvalState::coerceToString(
|
||||||
!canonicalizePath && !copyToStore
|
!canonicalizePath && !copyToStore
|
||||||
? // FIXME: hack to preserve path literals that end in a
|
? // FIXME: hack to preserve path literals that end in a
|
||||||
// slash, as in /foo/${x}.
|
// slash, as in /foo/${x}.
|
||||||
v.payload.path.path
|
v.pathStr()
|
||||||
: copyToStore
|
: copyToStore
|
||||||
? store->printStorePath(copyPathToStore(context, v.path()))
|
? store->printStorePath(copyPathToStore(context, v.path()))
|
||||||
: std::string(v.path().path.abs());
|
: std::string(v.path().path.abs());
|
||||||
|
@ -2636,14 +2636,14 @@ void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::st
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case nPath:
|
case nPath:
|
||||||
if (v1.payload.path.accessor != v2.payload.path.accessor) {
|
if (v1.pathAccessor() != v2.pathAccessor()) {
|
||||||
error<AssertionError>(
|
error<AssertionError>(
|
||||||
"path '%s' is not equal to path '%s' because their accessors are different",
|
"path '%s' is not equal to path '%s' because their accessors are different",
|
||||||
ValuePrinter(*this, v1, errorPrintOptions),
|
ValuePrinter(*this, v1, errorPrintOptions),
|
||||||
ValuePrinter(*this, v2, errorPrintOptions))
|
ValuePrinter(*this, v2, errorPrintOptions))
|
||||||
.debugThrow();
|
.debugThrow();
|
||||||
}
|
}
|
||||||
if (strcmp(v1.payload.path.path, v2.payload.path.path) != 0) {
|
if (strcmp(v1.pathStr(), v2.pathStr()) != 0) {
|
||||||
error<AssertionError>(
|
error<AssertionError>(
|
||||||
"path '%s' is not equal to path '%s'",
|
"path '%s' is not equal to path '%s'",
|
||||||
ValuePrinter(*this, v1, errorPrintOptions),
|
ValuePrinter(*this, v1, errorPrintOptions),
|
||||||
|
@ -2810,8 +2810,8 @@ bool EvalState::eqValues(Value & v1, Value & v2, const PosIdx pos, std::string_v
|
||||||
case nPath:
|
case nPath:
|
||||||
return
|
return
|
||||||
// FIXME: compare accessors by their fingerprint.
|
// FIXME: compare accessors by their fingerprint.
|
||||||
v1.payload.path.accessor == v2.payload.path.accessor
|
v1.pathAccessor() == v2.pathAccessor()
|
||||||
&& strcmp(v1.payload.path.path, v2.payload.path.path) == 0;
|
&& strcmp(v1.pathStr(), v2.pathStr()) == 0;
|
||||||
|
|
||||||
case nNull:
|
case nNull:
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -89,9 +89,9 @@ Env & EvalState::allocEnv(size_t size)
|
||||||
void EvalState::forceValue(Value & v, const PosIdx pos)
|
void EvalState::forceValue(Value & v, const PosIdx pos)
|
||||||
{
|
{
|
||||||
if (v.isThunk()) {
|
if (v.isThunk()) {
|
||||||
Env * env = v.payload.thunk.env;
|
Env * env = v.thunk().env;
|
||||||
assert(env || v.isBlackhole());
|
assert(env || v.isBlackhole());
|
||||||
Expr * expr = v.payload.thunk.expr;
|
Expr * expr = v.thunk().expr;
|
||||||
try {
|
try {
|
||||||
v.mkBlackhole();
|
v.mkBlackhole();
|
||||||
//checkInterrupt();
|
//checkInterrupt();
|
||||||
|
@ -106,7 +106,7 @@ void EvalState::forceValue(Value & v, const PosIdx pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (v.isApp())
|
else if (v.isApp())
|
||||||
callFunction(*v.payload.app.left, *v.payload.app.right, v, pos);
|
callFunction(*v.app().left, *v.app().right, v, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -410,11 +410,6 @@ public:
|
||||||
return internalType == tList1 || internalType == tList2 || internalType == tListN;
|
return internalType == tList1 || internalType == tList2 || internalType == tListN;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value * const * listElems()
|
|
||||||
{
|
|
||||||
return internalType == tList1 || internalType == tList2 ? payload.smallList : payload.bigList.elems;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::span<Value * const> listItems() const
|
std::span<Value * const> listItems() const
|
||||||
{
|
{
|
||||||
assert(isList());
|
assert(isList());
|
||||||
|
@ -444,8 +439,8 @@ public:
|
||||||
{
|
{
|
||||||
assert(internalType == tPath);
|
assert(internalType == tPath);
|
||||||
return SourcePath(
|
return SourcePath(
|
||||||
ref(payload.path.accessor->shared_from_this()),
|
ref(pathAccessor()->shared_from_this()),
|
||||||
CanonPath(CanonPath::unchecked_t(), payload.path.path));
|
CanonPath(CanonPath::unchecked_t(), pathStr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view string_view() const
|
std::string_view string_view() const
|
||||||
|
@ -482,6 +477,24 @@ public:
|
||||||
|
|
||||||
NixFloat fpoint() const
|
NixFloat fpoint() const
|
||||||
{ return payload.fpoint; }
|
{ return payload.fpoint; }
|
||||||
|
|
||||||
|
Lambda lambda() const
|
||||||
|
{ return payload.lambda; }
|
||||||
|
|
||||||
|
ClosureThunk thunk() const
|
||||||
|
{ return payload.thunk; }
|
||||||
|
|
||||||
|
FunctionApplicationThunk primOpApp() const
|
||||||
|
{ return payload.primOpApp; }
|
||||||
|
|
||||||
|
FunctionApplicationThunk app() const
|
||||||
|
{ return payload.app; }
|
||||||
|
|
||||||
|
const char * pathStr() const
|
||||||
|
{ return payload.path.path; }
|
||||||
|
|
||||||
|
SourceAccessor * pathAccessor() const
|
||||||
|
{ return payload.path.accessor; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -489,7 +502,7 @@ extern ExprBlackHole eBlackHole;
|
||||||
|
|
||||||
bool Value::isBlackhole() const
|
bool Value::isBlackhole() const
|
||||||
{
|
{
|
||||||
return internalType == tThunk && payload.thunk.expr == (Expr*) &eBlackHole;
|
return internalType == tThunk && thunk().expr == (Expr*) &eBlackHole;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::mkBlackhole()
|
void Value::mkBlackhole()
|
||||||
|
|
|
@ -651,7 +651,7 @@ struct CompareValues
|
||||||
// Note: we don't take the accessor into account
|
// Note: we don't take the accessor into account
|
||||||
// since it's not obvious how to compare them in a
|
// since it's not obvious how to compare them in a
|
||||||
// reproducible way.
|
// reproducible way.
|
||||||
return strcmp(v1->payload.path.path, v2->payload.path.path) < 0;
|
return strcmp(v1->pathStr(), v2->pathStr()) < 0;
|
||||||
case nList:
|
case nList:
|
||||||
// Lexicographic comparison
|
// Lexicographic comparison
|
||||||
for (size_t i = 0;; i++) {
|
for (size_t i = 0;; i++) {
|
||||||
|
@ -3138,12 +3138,12 @@ static void prim_functionArgs(EvalState & state, const PosIdx pos, Value * * arg
|
||||||
if (!args[0]->isLambda())
|
if (!args[0]->isLambda())
|
||||||
state.error<TypeError>("'functionArgs' requires a function").atPos(pos).debugThrow();
|
state.error<TypeError>("'functionArgs' requires a function").atPos(pos).debugThrow();
|
||||||
|
|
||||||
if (!args[0]->payload.lambda.fun->hasFormals()) {
|
if (!args[0]->lambda().fun->hasFormals()) {
|
||||||
v.mkAttrs(&state.emptyBindings);
|
v.mkAttrs(&state.emptyBindings);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &formals = args[0]->payload.lambda.fun->formals->formals;
|
const auto &formals = args[0]->lambda().fun->formals->formals;
|
||||||
auto attrs = state.buildBindings(formals.size());
|
auto attrs = state.buildBindings(formals.size());
|
||||||
for (auto & i : formals)
|
for (auto & i : formals)
|
||||||
attrs.insert(i.name, state.getBool(i.def), i.pos);
|
attrs.insert(i.name, state.getBool(i.def), i.pos);
|
||||||
|
|
|
@ -453,13 +453,13 @@ private:
|
||||||
|
|
||||||
if (v.isLambda()) {
|
if (v.isLambda()) {
|
||||||
output << "lambda";
|
output << "lambda";
|
||||||
if (v.payload.lambda.fun) {
|
if (v.lambda().fun) {
|
||||||
if (v.payload.lambda.fun->name) {
|
if (v.lambda().fun->name) {
|
||||||
output << " " << state.symbols[v.payload.lambda.fun->name];
|
output << " " << state.symbols[v.lambda().fun->name];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << state.positions[v.payload.lambda.fun->pos];
|
s << state.positions[v.lambda().fun->pos];
|
||||||
output << " @ " << filterANSIEscapes(toView(s));
|
output << " @ " << filterANSIEscapes(toView(s));
|
||||||
}
|
}
|
||||||
} else if (v.isPrimOp()) {
|
} else if (v.isPrimOp()) {
|
||||||
|
|
|
@ -126,18 +126,18 @@ static void printValueAsXML(EvalState & state, bool strict, bool location,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XMLAttrs xmlAttrs;
|
XMLAttrs xmlAttrs;
|
||||||
if (location) posToXML(state, xmlAttrs, state.positions[v.payload.lambda.fun->pos]);
|
if (location) posToXML(state, xmlAttrs, state.positions[v.lambda().fun->pos]);
|
||||||
XMLOpenElement _(doc, "function", xmlAttrs);
|
XMLOpenElement _(doc, "function", xmlAttrs);
|
||||||
|
|
||||||
if (v.payload.lambda.fun->hasFormals()) {
|
if (v.lambda().fun->hasFormals()) {
|
||||||
XMLAttrs attrs;
|
XMLAttrs attrs;
|
||||||
if (v.payload.lambda.fun->arg) attrs["name"] = state.symbols[v.payload.lambda.fun->arg];
|
if (v.lambda().fun->arg) attrs["name"] = state.symbols[v.lambda().fun->arg];
|
||||||
if (v.payload.lambda.fun->formals->ellipsis) attrs["ellipsis"] = "1";
|
if (v.lambda().fun->formals->ellipsis) attrs["ellipsis"] = "1";
|
||||||
XMLOpenElement _(doc, "attrspat", attrs);
|
XMLOpenElement _(doc, "attrspat", attrs);
|
||||||
for (auto & i : v.payload.lambda.fun->formals->lexicographicOrder(state.symbols))
|
for (auto & i : v.lambda().fun->formals->lexicographicOrder(state.symbols))
|
||||||
doc.writeEmptyElement("attr", singletonAttrs("name", state.symbols[i.name]));
|
doc.writeEmptyElement("attr", singletonAttrs("name", state.symbols[i.name]));
|
||||||
} else
|
} else
|
||||||
doc.writeEmptyElement("varpat", singletonAttrs("name", state.symbols[v.payload.lambda.fun->arg]));
|
doc.writeEmptyElement("varpat", singletonAttrs("name", state.symbols[v.lambda().fun->arg]));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,8 +252,8 @@ static Flake readFlake(
|
||||||
if (auto outputs = vInfo.attrs()->get(sOutputs)) {
|
if (auto outputs = vInfo.attrs()->get(sOutputs)) {
|
||||||
expectType(state, nFunction, *outputs->value, outputs->pos);
|
expectType(state, nFunction, *outputs->value, outputs->pos);
|
||||||
|
|
||||||
if (outputs->value->isLambda() && outputs->value->payload.lambda.fun->hasFormals()) {
|
if (outputs->value->isLambda() && outputs->value->lambda().fun->hasFormals()) {
|
||||||
for (auto & formal : outputs->value->payload.lambda.fun->formals->formals) {
|
for (auto & formal : outputs->value->lambda().fun->formals->formals) {
|
||||||
if (formal.name != state.sSelf)
|
if (formal.name != state.sSelf)
|
||||||
flake.inputs.emplace(state.symbols[formal.name], FlakeInput {
|
flake.inputs.emplace(state.symbols[formal.name], FlakeInput {
|
||||||
.ref = parseFlakeRef(state.fetchSettings, std::string(state.symbols[formal.name]))
|
.ref = parseFlakeRef(state.fetchSettings, std::string(state.symbols[formal.name]))
|
||||||
|
|
|
@ -387,8 +387,8 @@ static void main_nix_build(int argc, char * * argv)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool add = false;
|
bool add = false;
|
||||||
if (v.type() == nFunction && v.payload.lambda.fun->hasFormals()) {
|
if (v.type() == nFunction && v.lambda().fun->hasFormals()) {
|
||||||
for (auto & i : v.payload.lambda.fun->formals->formals) {
|
for (auto & i : v.lambda().fun->formals->formals) {
|
||||||
if (state->symbols[i.name] == "inNixShell") {
|
if (state->symbols[i.name] == "inNixShell") {
|
||||||
add = true;
|
add = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -492,8 +492,8 @@ struct CmdFlakeCheck : FlakeCommand
|
||||||
if (!v.isLambda()) {
|
if (!v.isLambda()) {
|
||||||
throw Error("overlay is not a function, but %s instead", showType(v));
|
throw Error("overlay is not a function, but %s instead", showType(v));
|
||||||
}
|
}
|
||||||
if (v.payload.lambda.fun->hasFormals()
|
if (v.lambda().fun->hasFormals()
|
||||||
|| !argHasName(v.payload.lambda.fun->arg, "final"))
|
|| !argHasName(v.lambda().fun->arg, "final"))
|
||||||
throw Error("overlay does not take an argument named 'final'");
|
throw Error("overlay does not take an argument named 'final'");
|
||||||
// FIXME: if we have a 'nixpkgs' input, use it to
|
// FIXME: if we have a 'nixpkgs' input, use it to
|
||||||
// evaluate the overlay.
|
// evaluate the overlay.
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
# Test the container built by ../../docker.nix.
|
# Test the container built by ../../docker.nix.
|
||||||
|
|
||||||
{
|
{
|
||||||
lib,
|
|
||||||
config,
|
config,
|
||||||
nixpkgs,
|
|
||||||
hostPkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
pkgs = config.nodes.machine.nixpkgs.pkgs;
|
pkgs = config.nodes.machine.nixpkgs.pkgs;
|
||||||
|
|
||||||
nixImage = import ../../docker.nix {
|
nixImage = pkgs.callPackage ../../docker.nix { };
|
||||||
inherit (config.nodes.machine.nixpkgs) pkgs;
|
nixUserImage = pkgs.callPackage ../../docker.nix {
|
||||||
};
|
|
||||||
nixUserImage = import ../../docker.nix {
|
|
||||||
inherit (config.nodes.machine.nixpkgs) pkgs;
|
|
||||||
name = "nix-user";
|
name = "nix-user";
|
||||||
uid = 1000;
|
uid = 1000;
|
||||||
gid = 1000;
|
gid = 1000;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue