1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

Merge pull request #12506 from NixOS/mergify/bp/2.26-maintenance/pr-12498

Restore detailed Nix CLI version (backport #12498)
This commit is contained in:
mergify[bot] 2025-02-19 00:29:13 +00:00 committed by GitHub
commit 8a2bb811ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 35 additions and 181 deletions

View file

@ -42,6 +42,18 @@ let
mkPackageBuilder = mkPackageBuilder =
exts: userFn: stdenv.mkDerivation (lib.extends (lib.composeManyExtensions exts) userFn); exts: userFn: stdenv.mkDerivation (lib.extends (lib.composeManyExtensions exts) userFn);
setVersionLayer = finalAttrs: prevAttrs: {
preConfigure =
prevAttrs.prevAttrs or ""
+
# Update the repo-global .version file.
# Symlink ./.version points there, but by default only workDir is writable.
''
chmod u+w ./.version
echo ${finalAttrs.version} > ./.version
'';
};
localSourceLayer = localSourceLayer =
finalAttrs: prevAttrs: finalAttrs: prevAttrs:
let let
@ -180,12 +192,14 @@ scope:
mkMesonDerivation = mkPackageBuilder [ mkMesonDerivation = mkPackageBuilder [
miscGoodPractice miscGoodPractice
localSourceLayer localSourceLayer
setVersionLayer
mesonLayer mesonLayer
]; ];
mkMesonExecutable = mkPackageBuilder [ mkMesonExecutable = mkPackageBuilder [
miscGoodPractice miscGoodPractice
bsdNoLinkAsNeeded bsdNoLinkAsNeeded
localSourceLayer localSourceLayer
setVersionLayer
mesonLayer mesonLayer
mesonBuildLayer mesonBuildLayer
]; ];
@ -194,6 +208,7 @@ scope:
bsdNoLinkAsNeeded bsdNoLinkAsNeeded
localSourceLayer localSourceLayer
mesonLayer mesonLayer
setVersionLayer
mesonBuildLayer mesonBuildLayer
mesonLibraryLayer mesonLibraryLayer
]; ];

View file

@ -64,14 +64,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json nlohmann_json
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
(lib.mesonEnable "markdown" enableMarkdown) (lib.mesonEnable "markdown" enableMarkdown)
(lib.mesonOption "readline-flavor" readlineFlavor) (lib.mesonOption "readline-flavor" readlineFlavor)

View file

@ -36,14 +36,6 @@ mkMesonLibrary (finalAttrs: {
nix-expr nix-expr
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -40,14 +40,6 @@ mkMesonLibrary (finalAttrs: {
rapidcheck rapidcheck
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -46,14 +46,6 @@ mkMesonExecutable (finalAttrs: {
gtest gtest
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -77,14 +77,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json nlohmann_json
] ++ lib.optional enableGC boehmgc; ] ++ lib.optional enableGC boehmgc;
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
(lib.mesonEnable "gc" enableGC) (lib.mesonEnable "gc" enableGC)
]; ];

View file

@ -44,14 +44,6 @@ mkMesonExecutable (finalAttrs: {
gtest gtest
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -41,14 +41,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json nlohmann_json
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
meta = { meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows; platforms = lib.platforms.unix ++ lib.platforms.windows;
}; };

View file

@ -38,14 +38,6 @@ mkMesonLibrary (finalAttrs: {
nix-flake nix-flake
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -46,14 +46,6 @@ mkMesonExecutable (finalAttrs: {
gtest gtest
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -40,14 +40,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json nlohmann_json
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
meta = { meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows; platforms = lib.platforms.unix ++ lib.platforms.windows;
}; };

View file

@ -40,14 +40,6 @@ mkMesonLibrary (finalAttrs: {
nix-main nix-main
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -37,14 +37,6 @@ mkMesonLibrary (finalAttrs: {
openssl openssl
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
meta = { meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows; platforms = lib.platforms.unix ++ lib.platforms.windows;
}; };

View file

@ -36,14 +36,6 @@ mkMesonLibrary (finalAttrs: {
nix-store nix-store
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -40,14 +40,6 @@ mkMesonLibrary (finalAttrs: {
rapidcheck rapidcheck
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -52,14 +52,6 @@ mkMesonExecutable (finalAttrs: {
nix-store-test-support nix-store-test-support
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -242,7 +242,7 @@ Path Settings::getDefaultSSLCertFile()
return ""; return "";
} }
const std::string nixVersion = PACKAGE_VERSION; std::string nixVersion = PACKAGE_VERSION;
NLOHMANN_JSON_SERIALIZE_ENUM(SandboxMode, { NLOHMANN_JSON_SERIALIZE_ENUM(SandboxMode, {
{SandboxMode::smEnabled, true}, {SandboxMode::smEnabled, true},

View file

@ -1248,7 +1248,15 @@ void loadConfFile(AbstractConfig & config);
// Used by the Settings constructor // Used by the Settings constructor
std::vector<Path> getUserConfigFiles(); std::vector<Path> getUserConfigFiles();
extern const std::string nixVersion; /**
* The version of Nix itself.
*
* This is not `const`, so that the Nix CLI can provide a more detailed version
* number including the git revision, without having to "re-compile" the entire
* set of Nix libraries to include that version, even when those libraries are
* not affected by the change.
*/
extern std::string nixVersion;
/** /**
* @param loadConfig Whether to load configuration from `nix.conf`, `NIX_CONFIG`, etc. May be disabled for unit tests. * @param loadConfig Whether to load configuration from `nix.conf`, `NIX_CONFIG`, etc. May be disabled for unit tests.

View file

@ -69,14 +69,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json nlohmann_json
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = mesonFlags =
[ [
(lib.mesonEnable "seccomp-sandboxing" stdenv.hostPlatform.isLinux) (lib.mesonEnable "seccomp-sandboxing" stdenv.hostPlatform.isLinux)

View file

@ -34,14 +34,6 @@ mkMesonLibrary (finalAttrs: {
nix-util nix-util
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -38,14 +38,6 @@ mkMesonLibrary (finalAttrs: {
rapidcheck rapidcheck
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -45,14 +45,6 @@ mkMesonExecutable (finalAttrs: {
gtest gtest
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -52,17 +52,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json nlohmann_json
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
#
# TODO: change release process to add `pre` in `.version`, remove it
# before tagging, and restore after.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [ mesonFlags = [
(lib.mesonEnable "cpuid" stdenv.hostPlatform.isx86_64) (lib.mesonEnable "cpuid" stdenv.hostPlatform.isx86_64)
]; ];

View file

@ -557,6 +557,9 @@ void mainWrapped(int argc, char * * argv)
int main(int argc, char * * argv) int main(int argc, char * * argv)
{ {
// The CLI has a more detailed version than the libraries; see nixVersion.
nix::nixVersion = NIX_CLI_VERSION;
// Increase the default stack size for the evaluator and for // Increase the default stack size for the evaluator and for
// libstdc++'s std::regex. // libstdc++'s std::regex.
nix::setStackSize(64 * 1024 * 1024); nix::setStackSize(64 * 1024 * 1024);

View file

@ -35,6 +35,9 @@ subdir('nix-meson-build-support/windows-version')
configdata = configuration_data() configdata = configuration_data()
# The CLI has a more detailed version string than the libraries; see `nixVersion`
configdata.set_quoted('NIX_CLI_VERSION', meson.project_version())
fs = import('fs') fs = import('fs')
bindir = get_option('bindir') bindir = get_option('bindir')

View file

@ -91,14 +91,6 @@ mkMesonExecutable (finalAttrs: {
nix-cmd nix-cmd
]; ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
'';
mesonFlags = [ mesonFlags = [
]; ];

View file

@ -11,7 +11,7 @@ source common.sh
#nix-hash --help | grepQuiet base32 #nix-hash --help | grepQuiet base32
# Can we ask for the version number? # Can we ask for the version number?
nix-env --version | grep "$version" nix-env --version | grep -F "${_NIX_TEST_CLIENT_VERSION:-$version}"
nix_env=$(type -P nix-env) nix_env=$(type -P nix-env)
(PATH=""; ! $nix_env --help 2>&1 ) | grepQuiet -F "The 'man' command was not found, but it is needed for 'nix-env' and some other 'nix-*' commands' help text. Perhaps you could install the 'man' command?" (PATH=""; ! $nix_env --help 2>&1 ) | grepQuiet -F "The 'man' command was not found, but it is needed for 'nix-env' and some other 'nix-*' commands' help text. Perhaps you could install the 'man' command?"

View file

@ -75,16 +75,10 @@ mkMesonDerivation (
]; ];
preConfigure = preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
''
# TEMP hack for Meson before make is gone, where # TEMP hack for Meson before make is gone, where
# `src/nix-functional-tests` is during the transition a symlink and # `src/nix-functional-tests` is during the transition a symlink and
# not the actual directory directory. # not the actual directory directory.
+ '' ''
cd $(readlink -e $PWD) cd $(readlink -e $PWD)
echo $PWD | grep tests/functional echo $PWD | grep tests/functional
''; '';
@ -105,6 +99,8 @@ mkMesonDerivation (
} }
// lib.optionalAttrs (test-daemon != null) { // lib.optionalAttrs (test-daemon != null) {
# TODO rename to _NIX_TEST_DAEMON_PACKAGE
NIX_DAEMON_PACKAGE = test-daemon; NIX_DAEMON_PACKAGE = test-daemon;
_NIX_TEST_CLIENT_VERSION = nix-cli.version;
} }
) )