From d26a73bfe6ee5108085a996e5dc9815daabeee8a Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sun, 30 Nov 2025 15:09:03 +0100 Subject: [PATCH] libmain/shared: factor out nix features This way, other parts of the codebase can use it. Change-Id: I58673a6a56362692980426a6c8f70f5c6aff24d4 Signed-off-by: Raito Bezarius --- lix/libmain/shared.cc | 8 ++------ lix/libutil/compile-time-features.hh | 26 ++++++++++++++++++++++++++ lix/libutil/meson.build | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 lix/libutil/compile-time-features.hh diff --git a/lix/libmain/shared.cc b/lix/libmain/shared.cc index c466f2841..6fdd27377 100644 --- a/lix/libmain/shared.cc +++ b/lix/libmain/shared.cc @@ -21,6 +21,7 @@ #include "lix/libutil/terminal.hh" #include "lix/libutil/strings.hh" #include "lix/libutil/exit.hh" +#include "lix/libutil/compile-time-features.hh" #include #include @@ -302,14 +303,9 @@ bool LegacyArgs::processArgs(const Strings & args, bool finish) void printVersion(const std::string & programName) { std::cout << fmt("%1% (Lix, like Nix) %2%", programName, nixVersion) << std::endl; - Strings cfg; -#if HAVE_BOEHMGC - cfg.push_back("gc"); -#endif - cfg.push_back("signed-caches"); std::cout << "System type: " << settings.thisSystem << "\n"; std::cout << "Additional system types: " << concatStringsSep(", ", settings.extraPlatforms.get()) << "\n"; - std::cout << "Features: " << concatStringsSep(", ", cfg) << "\n"; + std::cout << "Features: " << concatStringsSep(", ", getNixFeatures()) << "\n"; std::cout << "System configuration file: " << settings.nixConfDir + "/nix.conf" << "\n"; std::cout << "User configuration files: " << concatStringsSep(":", settings.nixUserConfFiles) diff --git a/lix/libutil/compile-time-features.hh b/lix/libutil/compile-time-features.hh new file mode 100644 index 000000000..392dbd679 --- /dev/null +++ b/lix/libutil/compile-time-features.hh @@ -0,0 +1,26 @@ +#pragma once +///@file + +#include "lix/libutil/types.hh" + +namespace nix { +/** + * This returns a list of compile-time features. + * + * Historically, `signed-caches` seemed to have been one. + * So we include it always. + * + * NOTE: There's no guarantee that the output will be stable + * across Lix versions. + */ +constexpr Strings getNixFeatures() +{ + Strings features = {"signed-caches"}; + +#if HAVE_BOEHMGC + features.push_back("gc"); +#endif + + return features; +} +} diff --git a/lix/libutil/meson.build b/lix/libutil/meson.build index d5ab3c6f2..b5f882b8b 100644 --- a/lix/libutil/meson.build +++ b/lix/libutil/meson.build @@ -81,6 +81,7 @@ libutil_headers = files( 'chunked-vector.hh', 'closure.hh', 'comparator.hh', + 'compile-time-features.hh', 'compression.hh', 'compute-levels.hh', 'concepts.hh',