Skip to content

Commit

Permalink
Make wrapper derivation
Browse files Browse the repository at this point in the history
This ensures just `nix build`-ing the flake doesn't forget to run all
tests. One can still specifiy specific attributes to just build one
thing.
  • Loading branch information
Ericson2314 committed Aug 14, 2024
1 parent 6f3045c commit 9cdb4c6
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 16 deletions.
7 changes: 1 addition & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@

nix = final.nixComponents.nix;

nix_noTests = final.nix.override {
doInstallCheck = false;
doCheck = false;
};

# See https://github.com/NixOS/nixpkgs/pull/214409
# Remove when fixed in this flake's nixpkgs
pre-commit =
Expand Down Expand Up @@ -222,7 +217,7 @@
# for which we don't apply the full build matrix such as cross or static.
inherit (nixpkgsFor.${system}.native)
changelog-d;
default = self.packages.${system}.nix;
default = self.packages.${system}.nix-ng;
nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-internal-api-docs;
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs;
}
Expand Down
6 changes: 4 additions & 2 deletions packaging/components.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ in

nix-cmd = callPackage ../src/libcmd/package.nix { };

# Will replace `nix` once the old build system is gone.
nix-ng = callPackage ../src/nix/package.nix { version = fineVersion; };
nix-cli = callPackage ../src/nix/package.nix { version = fineVersion; };

nix-functional-tests = callPackage ../src/nix-functional-tests/package.nix { version = fineVersion; };

nix-internal-api-docs = callPackage ../src/internal-api-docs/package.nix { version = fineVersion; };
nix-external-api-docs = callPackage ../src/external-api-docs/package.nix { version = fineVersion; };

nix-perl-bindings = callPackage ../src/perl/package.nix { };

# Will replace `nix` once the old build system is gone.
nix-ng = callPackage ../packaging/everything.nix { };
}
91 changes: 91 additions & 0 deletions packaging/everything.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
lib,
stdenv,
buildEnv,

nix-util,
nix-util-c,
nix-util-test-support,
nix-util-tests,

nix-store,
nix-store-c,
nix-store-test-support,
nix-store-tests,

nix-fetchers,
nix-fetchers-tests,

nix-expr,
nix-expr-c,
nix-expr-test-support,
nix-expr-tests,

nix-flake,
nix-flake-tests,

nix-main,
nix-main-c,

nix-cmd,

nix-cli,

nix-functional-tests,

nix-internal-api-docs,
nix-external-api-docs,

nix-perl-bindings,
}:

(buildEnv rec {
name = "nix-${nix-cli.version}";
paths = [
nix-util
nix-util-c
nix-util-test-support
nix-util-tests

nix-store
nix-store-c
nix-store-test-support
nix-store-tests

nix-fetchers
nix-fetchers-tests

nix-expr
nix-expr-c
nix-expr-test-support
nix-expr-tests

nix-flake
nix-flake-tests

nix-main
nix-main-c

nix-cmd

nix-cli

nix-internal-api-docs
nix-external-api-docs

] ++ lib.optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
nix-perl-bindings
];
}).overrideAttrs (_: {
doCheck = true;

checkInputs = [
# Actually run the unit tests too
nix-util-tests.tests.run
nix-store-tests.tests.run
nix-expr-tests.tests.run
nix-flake-tests.tests.run

nix-functional-tests
];
})
5 changes: 3 additions & 2 deletions packaging/hydra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ let
"nix-main"
"nix-main-c"
"nix-cmd"
"nix-ng"
"nix-cli"
"nix-functional-tests"
"nix-ng"
];
in
{
Expand All @@ -85,7 +86,7 @@ in
self.packages.${system}.nix.override { enableGC = false; }
);

buildNoTests = forAllSystems (system: nixpkgsFor.${system}.native.nix_noTests);
buildNoTests = forAllSystems (system: nixpkgsFor.${system}.native.nixComponents.nix-cli);

# Toggles some settings for better coverage. Windows needs these
# library combinations, and Debian build Nix with GNU readline too.
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

, nix-store
, nix-expr
, nix-ng
, nix-cli

, rapidcheck
, gtest
Expand Down Expand Up @@ -67,7 +67,7 @@ mkMesonDerivation (finalAttrs: {
];

nativeBuildInputs = finalAttrs.passthru.baseNativeBuildInputs ++ [
nix-ng
nix-cli
];

buildInputs = [
Expand Down Expand Up @@ -105,7 +105,7 @@ mkMesonDerivation (finalAttrs: {
doCheck = true;

installPhase = ''
touch $out
mkdir $out
'';

meta = {
Expand Down
6 changes: 3 additions & 3 deletions tests/nixos/quick-build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ in
};

config = {
passthru.quickBuild =
passthru.quickBuild =
let withQuickBuild = extendModules { modules = [{ quickBuild = true; }]; };
in withQuickBuild.config.test;

defaults = { pkgs, ... }: {
config = lib.mkIf test.config.quickBuild {
nix.package = pkgs.nix_noTests;
nix.package = pkgs.nixComponents.nix-cli;

system.forbiddenDependenciesRegexes = [
# This would indicate that the quickBuild feature is broken.
Expand All @@ -44,4 +44,4 @@ in
};
};
};
}
}

0 comments on commit 9cdb4c6

Please sign in to comment.