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

Use nixosTest.quickBuild behavior by default

This wasn't the default behaviour because:

> We don't enable this by default to avoid the mostly unnecessary work of
> performing an additional build of the package in cases where we build
> the package normally anyway, such as in our pre-merge CI.

Since we have a componentized build, we've solved the duplication.

In the new situation, building both with and without unit tests
isn't any slow than just a build with unit tests, so there's no
point in using the unit-tested build anymore.

By using the otherwise untested build, we reduce the minimum build
time towards the NixOS test, at no cost.

If you want to run all tests, build all attributes.
This commit is contained in:
Robert Hensing 2024-08-14 23:19:22 +02:00 committed by Tom Bereknyei
parent b02601cd0c
commit d4aa7d5dc7
3 changed files with 12 additions and 56 deletions

View file

@ -4,20 +4,24 @@ let
nixos-lib = import (nixpkgs + "/nixos/lib") { };
noTests = pkg: pkg.overrideAttrs (
finalAttrs: prevAttrs: {
doCheck = false;
doInstallCheck = false;
});
# https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
runNixOSTestFor = system: test:
(nixos-lib.runTest {
imports = [
test
# Add the quickBuild attribute to the check packages
./quick-build.nix
];
hostPkgs = nixpkgsFor.${system}.native;
defaults = {
nixpkgs.pkgs = nixpkgsFor.${system}.native;
nix.checkAllErrors = false;
nix.package = noTests nixpkgsFor.${system}.native.nix;
};
_module.args.nixpkgs = nixpkgs;
_module.args.system = system;
@ -29,6 +33,9 @@ let
forNix = nixVersion: runNixOSTestFor system {
imports = [test];
defaults.nixpkgs.overlays = [(curr: prev: {
# NOTE: noTests pkg might not have been built yet for some older versions of the package
# and in versions before 2.25, the untested build wasn't shared with the tested build yet
# Add noTests here when those versions become irrelevant.
nix = (builtins.getFlake "nix/${nixVersion}").packages.${system}.nix;
})];
};