From 42877a5b2cb5867b5ae3c691add25c05cc69dccb Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Fri, 28 Jun 2024 14:41:48 +0200 Subject: [PATCH] nixVersions.*.tests.srcVersion: Test that version is ${src}/.version --- pkgs/tools/package-management/nix/common.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkgs/tools/package-management/nix/common.nix b/pkgs/tools/package-management/nix/common.nix index f7b0dff33472..e98371a1e757 100644 --- a/pkgs/tools/package-management/nix/common.nix +++ b/pkgs/tools/package-management/nix/common.nix @@ -85,6 +85,7 @@ in # passthru tests , pkgsi686Linux +, runCommand }: let self = stdenv.mkDerivation { pname = "nix"; @@ -259,6 +260,21 @@ self = stdenv.mkDerivation { # Basic smoke test that needs to pass when upgrading nix. # Note that this test does only test the nixVersions.stable attribute. misc = nixosTests.nix-misc.default; + + srcVersion = runCommand "nix-src-version" { + inherit version; + } '' + # This file is an implementation detail, but it's a good sanity check + # If upstream changes that, we'll have to adapt. + srcVersion=$(cat ${src}/.version) + echo "Version in nix nix expression: $version" + echo "Version in nix.src: $srcVersion" + if [ "$version" != "$srcVersion" ]; then + echo "Version mismatch!" + exit 1 + fi + touch $out + ''; }; };