···169170Checks that the output from running a command contains the specified version string in it as a whole word.
171172-NOTE: In most cases, [`versionCheckHook`](#versioncheckhook) should be preferred, but this function is provided and documented here anyway. The motivation for adding either tests would be:
173174- Catch dynamic linking errors and such and missing environment variables that should be added by wrapping.
175- Probable protection against accidentally building the wrong version, for example when using an "old" hash in a fixed-output derivation.
···169170Checks that the output from running a command contains the specified version string in it as a whole word.
171172+NOTE: This is a check you add to `passthru.tests` which is mainly run by OfBorg, but not in Hydra. If you want a version check failure to block the build altogether, then [`versionCheckHook`](#versioncheckhook) is the tool you're looking for (and recommended for quick builds). The motivation for adding either of these checks would be:
173174- Catch dynamic linking errors and such and missing environment variables that should be added by wrapping.
175- Probable protection against accidentally building the wrong version, for example when using an "old" hash in a fixed-output derivation.
+5-1
doc/hooks/versionCheckHook.section.md
···1# versionCheckHook {#versioncheckhook}
23-This hook adds a `versionCheckPhase` to the [`preInstallCheckHooks`](#ssec-installCheck-phase) that runs the main program of the derivation with a `--help` or `--version` argument, and checks that the `${version}` string is found in that output. You use it like this:
0045```nix
6{
···33- `versionCheckProgramArg`: The argument that needs to be passed to `versionCheckProgram`. If undefined the hook tries first `--help` and then `--version`. Examples: `version`, `-V`, `-v`.
34- `preVersionCheck`: A hook to run before the check is done.
35- `postVersionCheck`: A hook to run after the check is done.
00
···1# versionCheckHook {#versioncheckhook}
23+This hook adds a `versionCheckPhase` to the [`preInstallCheckHooks`](#ssec-installCheck-phase) that runs the main program of the derivation with a `--help` or `--version` argument, and checks that the `${version}` string is found in that output. If this check fails then the whole build will fail. _(A softer option is [`testers.testVersion`](#tester-testVersion).)_
4+5+You use it like this:
67```nix
8{
···35- `versionCheckProgramArg`: The argument that needs to be passed to `versionCheckProgram`. If undefined the hook tries first `--help` and then `--version`. Examples: `version`, `-V`, `-v`.
36- `preVersionCheck`: A hook to run before the check is done.
37- `postVersionCheck`: A hook to run after the check is done.
38+39+This check assumes the executable is _hermetic_. If environment variables such as `PATH` or `HOME` are required for the program to function, then [`testers.testVersion`](#tester-testVersion) is currently the better alternative.
···283 # It's similar to Nix daemon so there's no question whether or not this
284 # should be sandboxed.
285 systemd.services.guix-daemon = {
286- environment = serviceEnv;
287 script = ''
288 exec ${lib.getExe' package "guix-daemon"} \
289 --build-users-group=${cfg.group} \
···283 # It's similar to Nix daemon so there's no question whether or not this
284 # should be sandboxed.
285 systemd.services.guix-daemon = {
286+ environment = serviceEnv // config.networking.proxy.envVars;
287 script = ''
288 exec ${lib.getExe' package "guix-daemon"} \
289 --build-users-group=${cfg.group} \
···66 nativeInstallCheckInputs = [ versionCheckHook ];
67 versionCheckProgram = "${placeholder "out"}/bin/mongod";
68 versionCheckProgramArg = [ "--version" ];
69+ # Only enable the version install check on darwin.
70+ # On Linux, this would fail as mongod relies on tcmalloc, which
71+ # requires access to `/sys/devices/system/cpu/possible`.
72+ # See https://github.com/NixOS/nixpkgs/issues/377016
73+ doInstallCheck = stdenv.hostPlatform.isDarwin;
7475 passthru = {
76