forked from lix-project/lix
Compare commits
6 commits
f96864fa15
...
0b4a54242e
Author | SHA1 | Date | |
---|---|---|---|
Nikodem Rabuliński | 0b4a54242e | ||
Nikodem Rabuliński | c8009321bf | ||
Qyriad | 93b7edfd07 | ||
julia | 005ee33a9a | ||
Qyriad | 5ff076d8ad | ||
julia | 5b7dcb3005 |
|
@ -61,3 +61,8 @@ edolstra:
|
||||||
roberth:
|
roberth:
|
||||||
display_name: Robert Hensing
|
display_name: Robert Hensing
|
||||||
github: roberth
|
github: roberth
|
||||||
|
|
||||||
|
midnightveil:
|
||||||
|
display_name: julia
|
||||||
|
forgejo: midnightveil
|
||||||
|
github: midnightveil
|
||||||
|
|
13
doc/manual/rl-next/enable-coredumps.md
Normal file
13
doc/manual/rl-next/enable-coredumps.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
synopsis: "Add an option `enable-core-dumps` that enables core dumps from builds"
|
||||||
|
cls: 1088
|
||||||
|
credits: midnightveil
|
||||||
|
category: Features
|
||||||
|
---
|
||||||
|
|
||||||
|
In the past, Lix disabled core dumps by setting the soft `RLIMIT_CORE` to 0
|
||||||
|
unconditionally. Although this rlimit could be altered from the builder since
|
||||||
|
it is just the soft limit, this was kind of annoying to do. By passing
|
||||||
|
`--option enable-core-dumps true` to an offending build, one can now cause the
|
||||||
|
core dumps to be handled by the system in the normal way (winding up in
|
||||||
|
`coredumpctl`, say, on Linux).
|
|
@ -14,8 +14,11 @@ struct EvalSettings : Config
|
||||||
|
|
||||||
static std::string resolvePseudoUrl(std::string_view url);
|
static std::string resolvePseudoUrl(std::string_view url);
|
||||||
|
|
||||||
Setting<bool> enableNativeCode{this, false, "allow-unsafe-native-code-during-evaluation",
|
Setting<bool> enableNativeCode{this, false, "allow-unsafe-native-code-during-evaluation", R"(
|
||||||
"Whether builtin functions that allow executing native code should be enabled."};
|
Whether builtin functions that allow executing native code should be enabled.
|
||||||
|
|
||||||
|
In particular, this adds the `importNative` and `exec` builtins.
|
||||||
|
)"};
|
||||||
|
|
||||||
Setting<Strings> nixPath{
|
Setting<Strings> nixPath{
|
||||||
this, getDefaultNixPath(), "nix-path",
|
this, getDefaultNixPath(), "nix-path",
|
||||||
|
|
|
@ -1977,6 +1977,9 @@ void LocalDerivationGoal::runChild()
|
||||||
|
|
||||||
/* Disable core dumps by default. */
|
/* Disable core dumps by default. */
|
||||||
struct rlimit limit = { 0, RLIM_INFINITY };
|
struct rlimit limit = { 0, RLIM_INFINITY };
|
||||||
|
if (settings.enableCoreDumps) {
|
||||||
|
limit.rlim_cur = RLIM_INFINITY;
|
||||||
|
}
|
||||||
setrlimit(RLIMIT_CORE, &limit);
|
setrlimit(RLIMIT_CORE, &limit);
|
||||||
|
|
||||||
// FIXME: set other limits to deterministic values?
|
// FIXME: set other limits to deterministic values?
|
||||||
|
|
|
@ -290,6 +290,15 @@ public:
|
||||||
Setting<off_t> reservedSize{this, 8 * 1024 * 1024, "gc-reserved-space",
|
Setting<off_t> reservedSize{this, 8 * 1024 * 1024, "gc-reserved-space",
|
||||||
"Amount of reserved disk space for the garbage collector."};
|
"Amount of reserved disk space for the garbage collector."};
|
||||||
|
|
||||||
|
Setting<bool> enableCoreDumps{
|
||||||
|
this, false, "enable-core-dumps",
|
||||||
|
R"(
|
||||||
|
If set to `false` (the default), `RLIMIT_CORE` has a soft limit of zero.
|
||||||
|
If set to `true`, the soft limit is infinite.
|
||||||
|
|
||||||
|
The hard limit is always infinite.
|
||||||
|
)"};
|
||||||
|
|
||||||
Setting<bool> fsyncMetadata{
|
Setting<bool> fsyncMetadata{
|
||||||
this, true, "fsync-metadata",
|
this, true, "fsync-metadata",
|
||||||
R"(
|
R"(
|
||||||
|
|
|
@ -87,11 +87,13 @@ public:
|
||||||
expectArgs({
|
expectArgs({
|
||||||
.label="inputs",
|
.label="inputs",
|
||||||
.optional=true,
|
.optional=true,
|
||||||
.handler={[&](std::string inputToUpdate){
|
.handler={[&](std::vector<std::string> inputsToUpdate) {
|
||||||
|
for (const auto & inputToUpdate : inputsToUpdate) {
|
||||||
auto inputPath = flake::parseInputPath(inputToUpdate);
|
auto inputPath = flake::parseInputPath(inputToUpdate);
|
||||||
if (lockFlags.inputUpdates.contains(inputPath))
|
if (lockFlags.inputUpdates.contains(inputPath))
|
||||||
warn("Input '%s' was specified multiple times. You may have done this by accident.");
|
warn("Input '%s' was specified multiple times. You may have done this by accident.");
|
||||||
lockFlags.inputUpdates.insert(inputPath);
|
lockFlags.inputUpdates.insert(inputPath);
|
||||||
|
}
|
||||||
}},
|
}},
|
||||||
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
||||||
completeFlakeInputPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix);
|
completeFlakeInputPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix);
|
||||||
|
@ -132,6 +134,15 @@ struct CmdFlakeLock : FlakeCommand
|
||||||
|
|
||||||
CmdFlakeLock()
|
CmdFlakeLock()
|
||||||
{
|
{
|
||||||
|
addFlag({
|
||||||
|
.longName="update-input",
|
||||||
|
.description="Replaced with `nix flake update input...`",
|
||||||
|
.labels={"input-path"},
|
||||||
|
.handler={[&](std::string inputToUpdate){
|
||||||
|
throw UsageError("`nix flake lock --update-input %1%` has been replaced by `nix flake update %1%`", inputToUpdate);
|
||||||
|
}}
|
||||||
|
});
|
||||||
|
|
||||||
/* Remove flags that don't make sense. */
|
/* Remove flags that don't make sense. */
|
||||||
removeFlag("no-write-lock-file");
|
removeFlag("no-write-lock-file");
|
||||||
}
|
}
|
||||||
|
|
15
tests/nixos/coredumps/default.nix
Normal file
15
tests/nixos/coredumps/default.nix
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
let
|
||||||
|
inherit (import ../util.nix) mkNixBuildTest;
|
||||||
|
in mkNixBuildTest rec {
|
||||||
|
name = "coredumps";
|
||||||
|
extraMachineConfig = { pkgs, ... }: {
|
||||||
|
boot.kernel.sysctl."kernel.core_pattern" = "core";
|
||||||
|
};
|
||||||
|
|
||||||
|
expressionFile = ./package.nix;
|
||||||
|
|
||||||
|
testScriptPost = ''
|
||||||
|
# do a test, but this time with coredumps enabled.
|
||||||
|
machine.succeed('nix-build --option enable-core-dumps true --expr "let pkgs = import <nixpkgs> {}; in pkgs.callPackage ${expressionFile} { shouldBePresent = true; }"')
|
||||||
|
'';
|
||||||
|
}
|
16
tests/nixos/coredumps/package.nix
Normal file
16
tests/nixos/coredumps/package.nix
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{ lib, runCommand, shouldBePresent ? false }:
|
||||||
|
|
||||||
|
runCommand "core-dump-now" { } ''
|
||||||
|
set -m
|
||||||
|
sleep infinity &
|
||||||
|
|
||||||
|
# make a coredump
|
||||||
|
kill -SIGSEGV %1
|
||||||
|
|
||||||
|
if ${lib.optionalString (shouldBePresent) "!"} test -n "$(find . -maxdepth 1 -name 'core*' -print -quit)"; then
|
||||||
|
echo "core file was in wrong presence state, expected: ${if shouldBePresent then "present" else "missing"}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch $out
|
||||||
|
''
|
|
@ -166,4 +166,6 @@ in
|
||||||
rootInSandbox = runNixOSTestFor "x86_64-linux" ./root-in-sandbox;
|
rootInSandbox = runNixOSTestFor "x86_64-linux" ./root-in-sandbox;
|
||||||
|
|
||||||
broken-userns = runNixOSTestFor "x86_64-linux" ./broken-userns.nix;
|
broken-userns = runNixOSTestFor "x86_64-linux" ./broken-userns.nix;
|
||||||
|
|
||||||
|
coredumps = runNixOSTestFor "x86_64-linux" ./coredumps;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
mkNixBuildTest = { name, expressionFile, extraMachineConfig ? {} }:
|
mkNixBuildTest =
|
||||||
|
{ name, expressionFile, extraMachineConfig ? {}, testScriptPre ? "", testScriptPost ? "" }:
|
||||||
{ lib, pkgs, ... }:
|
{ lib, pkgs, ... }:
|
||||||
{
|
{
|
||||||
inherit name;
|
inherit name;
|
||||||
|
@ -17,7 +18,11 @@
|
||||||
testScript = { nodes }: ''
|
testScript = { nodes }: ''
|
||||||
start_all()
|
start_all()
|
||||||
|
|
||||||
|
${testScriptPre}
|
||||||
|
|
||||||
machine.succeed('nix-build --expr "let pkgs = import <nixpkgs> {}; in pkgs.callPackage ${expressionFile} {}"')
|
machine.succeed('nix-build --expr "let pkgs = import <nixpkgs> {}; in pkgs.callPackage ${expressionFile} {}"')
|
||||||
|
|
||||||
|
${testScriptPost}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue