From b9096d0d865f7e0fb202490f9c554dc1b34eb06d Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Fri, 16 Aug 2024 12:08:02 +0300 Subject: [PATCH 1/3] versionCheckHook: small indentation improvement --- pkgs/by-name/ve/versionCheckHook/hook.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/ve/versionCheckHook/hook.sh b/pkgs/by-name/ve/versionCheckHook/hook.sh index cd417493e6c2..4ff808a6da51 100644 --- a/pkgs/by-name/ve/versionCheckHook/hook.sh +++ b/pkgs/by-name/ve/versionCheckHook/hook.sh @@ -1,6 +1,11 @@ _handleCmdOutput(){ local versionOutput - versionOutput="$(env --chdir=/ --argv0="$(basename "$1")" --ignore-environment "$@" 2>&1 || true)" + versionOutput="$(env \ + --chdir=/ \ + --argv0="$(basename "$1")" \ + --ignore-environment \ + "$@" 2>&1 \ + || true)" if [[ "$versionOutput" =~ "$version" ]]; then echoPrefix="Successfully managed to" else From 393e966194039c3655bd75570e74ae8696640461 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Fri, 16 Aug 2024 12:08:28 +0300 Subject: [PATCH 2/3] versionCheckHook: ignore echoed store paths This makes sure the hook will catch cases where the --version or --help output prints the installation dir or something alike that includes the builtins.storeDir, and later on the `${pname}-${version}` string. Could have avoided #334245 which was a fixup for #330456. --- pkgs/by-name/ve/versionCheckHook/hook.sh | 1 + pkgs/by-name/ve/versionCheckHook/package.nix | 3 +++ 2 files changed, 4 insertions(+) diff --git a/pkgs/by-name/ve/versionCheckHook/hook.sh b/pkgs/by-name/ve/versionCheckHook/hook.sh index 4ff808a6da51..88a046b552ee 100644 --- a/pkgs/by-name/ve/versionCheckHook/hook.sh +++ b/pkgs/by-name/ve/versionCheckHook/hook.sh @@ -5,6 +5,7 @@ _handleCmdOutput(){ --argv0="$(basename "$1")" \ --ignore-environment \ "$@" 2>&1 \ + | sed -e 's|@storeDir@/[^/ ]*/|{{storeDir}}/|g' \ || true)" if [[ "$versionOutput" =~ "$version" ]]; then echoPrefix="Successfully managed to" diff --git a/pkgs/by-name/ve/versionCheckHook/package.nix b/pkgs/by-name/ve/versionCheckHook/package.nix index ed35384d7960..d5039db3f219 100644 --- a/pkgs/by-name/ve/versionCheckHook/package.nix +++ b/pkgs/by-name/ve/versionCheckHook/package.nix @@ -5,6 +5,9 @@ makeSetupHook { name = "version-check-hook"; + substitutions = { + storeDir = builtins.storeDir; + }; meta = { description = "Lookup for $version in the output of --help and --version"; maintainers = with lib.maintainers; [ doronbehar ]; From 2ecfdda4cd6c2dabe7377a5a3e667f7b1e0637d8 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Fri, 16 Aug 2024 18:24:22 +0300 Subject: [PATCH 3/3] c3c: switch from testVersion to versionCheckHook `versionCheckHook` is much more verbose then `testVersion`, and it forces you to observe the failure when building it, and not only on CI / if you explicitly build `c3c.passthru.tests`. --- pkgs/development/compilers/c3c/default.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/c3c/default.nix b/pkgs/development/compilers/c3c/default.nix index 6187b75cc874..7b9b2086b39f 100644 --- a/pkgs/development/compilers/c3c/default.nix +++ b/pkgs/development/compilers/c3c/default.nix @@ -8,7 +8,7 @@ libxml2, libffi, xar, - testers, + versionCheckHook, }: llvmPackages.stdenv.mkDerivation (finalAttrs: { @@ -48,9 +48,8 @@ llvmPackages.stdenv.mkDerivation (finalAttrs: { runHook postCheck ''; - passthru.tests = { - version = testers.testVersion { package = finalAttrs.finalPackage; }; - }; + nativeInstallCheckInputs = [ versionCheckHook ]; + doInstallCheck = true; meta = with lib; { description = "Compiler for the C3 language";