From 64b9427f9849144d761bc48e3e1e7fe5a4b65480 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Tue, 28 Oct 2025 20:27:17 +0100 Subject: [PATCH] legacy/nix-build: return exit codes Legacy commands "main function" will now return an exit code. Fun fact: `main_nix_build` was the only one not returning integers already. Change-Id: Ia43a16c3c3fb9a670e8889aefc4ee9b6528a7df4 Signed-off-by: Raito Bezarius --- lix/legacy/nix-build.cc | 12 +++++++++--- lix/libcmd/legacy.hh | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lix/legacy/nix-build.cc b/lix/legacy/nix-build.cc index ac091b783..cbcdefd76 100644 --- a/lix/legacy/nix-build.cc +++ b/lix/legacy/nix-build.cc @@ -30,7 +30,7 @@ namespace nix { using namespace std::string_literals; -static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings argv) +static int main_nix_build(AsyncIoRoot & aio, std::string programName, Strings argv) { auto dryRun = false; auto runEnv = std::regex_search(programName, regex::parse("nix-shell$")); @@ -400,7 +400,9 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a buildPaths(pathsToBuild); - if (dryRun) return; + if (dryRun) { + return 0; + } if (shellDrv) { auto shellDrvOutputs = @@ -584,7 +586,9 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a buildPaths(pathsToBuild); - if (dryRun) return; + if (dryRun) { + return 0; + } std::vector outPaths; @@ -613,6 +617,8 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a for (auto & path : outPaths) std::cout << store->printStorePath(path) << '\n'; } + + return 0; } void registerLegacyNixBuildAndNixShell() { diff --git a/lix/libcmd/legacy.hh b/lix/libcmd/legacy.hh index 068fb9eb9..93b8a5f9f 100644 --- a/lix/libcmd/legacy.hh +++ b/lix/libcmd/legacy.hh @@ -9,7 +9,7 @@ namespace nix { -typedef std::function)> MainFunction; +typedef std::function)> MainFunction; struct LegacyCommandRegistry {