Make wrapper derivation

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.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
John Ericson 2024-08-14 16:04:35 -04:00
parent 6f3045c2a2
commit b41cc1a755
7 changed files with 142 additions and 39 deletions

View file

@ -195,20 +195,6 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main - uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix build -L .#hydraJobs.tests.githubFlakes .#hydraJobs.tests.tarballFlakes .#hydraJobs.tests.functional_user - run: nix build -L .#hydraJobs.tests.githubFlakes .#hydraJobs.tests.tarballFlakes .#hydraJobs.tests.functional_user
meson_build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
# Only meson packages that don't have a tests.run derivation.
# Those that have it are already built and tested as part of nix flake check.
- run: nix build -L .#hydraJobs.build.{nix-cmd,nix-main}.$(nix-instantiate --eval --expr builtins.currentSystem | sed -e 's/"//g')
flake_regressions: flake_regressions:
needs: vm_tests needs: vm_tests
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04

View file

@ -139,11 +139,6 @@
nix = final.nixComponents.nix; nix = final.nixComponents.nix;
nix_noTests = final.nix.override {
doInstallCheck = false;
doCheck = false;
};
# See https://github.com/NixOS/nixpkgs/pull/214409 # See https://github.com/NixOS/nixpkgs/pull/214409
# Remove when fixed in this flake's nixpkgs # Remove when fixed in this flake's nixpkgs
pre-commit = pre-commit =
@ -222,7 +217,7 @@
# for which we don't apply the full build matrix such as cross or static. # for which we don't apply the full build matrix such as cross or static.
inherit (nixpkgsFor.${system}.native) inherit (nixpkgsFor.${system}.native)
changelog-d; 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-internal-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-internal-api-docs;
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs; nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs;
} }
@ -230,22 +225,48 @@
// flatMapAttrs // flatMapAttrs
{ # Components we'll iterate over in the upcoming lambda { # Components we'll iterate over in the upcoming lambda
"nix" = { }; "nix" = { };
# Temporarily disabled because GitHub Actions OOM issues. Once "nix-util" = { };
# the old build system is gone and we are back to one build "nix-util-c" = { };
# system, we should reenable these. "nix-util-test-support" = { };
#"nix-util" = { }; "nix-util-tests" = { };
#"nix-store" = { };
#"nix-fetchers" = { }; "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" = { supportsCross = false; };
"nix-perl-bindings" = { supportsCross = false; };
"nix-ng" = { };
} }
(pkgName: {}: { (pkgName: { supportsCross ? true }: {
# These attributes go right into `packages.<system>`. # These attributes go right into `packages.<system>`.
"${pkgName}" = nixpkgsFor.${system}.native.nixComponents.${pkgName}; "${pkgName}" = nixpkgsFor.${system}.native.nixComponents.${pkgName};
"${pkgName}-static" = nixpkgsFor.${system}.static.nixComponents.${pkgName}; "${pkgName}-static" = nixpkgsFor.${system}.static.nixComponents.${pkgName};
} }
// flatMapAttrs (lib.genAttrs crossSystems (_: { })) (crossSystem: {}: { // lib.optionalAttrs supportsCross (flatMapAttrs (lib.genAttrs crossSystems (_: { })) (crossSystem: {}: {
# These attributes go right into `packages.<system>`. # These attributes go right into `packages.<system>`.
"${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName}; "${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName};
}) }))
// flatMapAttrs (lib.genAttrs stdenvs (_: { })) (stdenvName: {}: { // flatMapAttrs (lib.genAttrs stdenvs (_: { })) (stdenvName: {}: {
# These attributes go right into `packages.<system>`. # These attributes go right into `packages.<system>`.
"${pkgName}-${stdenvName}" = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".nixComponents.${pkgName}; "${pkgName}-${stdenvName}" = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".nixComponents.${pkgName};

View file

@ -56,8 +56,7 @@ in
nix-cmd = callPackage ../src/libcmd/package.nix { }; nix-cmd = callPackage ../src/libcmd/package.nix { };
# Will replace `nix` once the old build system is gone. nix-cli = callPackage ../src/nix/package.nix { version = fineVersion; };
nix-ng = callPackage ../src/nix/package.nix { version = fineVersion; };
nix-functional-tests = callPackage ../src/nix-functional-tests/package.nix { version = fineVersion; }; nix-functional-tests = callPackage ../src/nix-functional-tests/package.nix { version = fineVersion; };
@ -65,4 +64,7 @@ in
nix-external-api-docs = callPackage ../src/external-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 { }; nix-perl-bindings = callPackage ../src/perl/package.nix { };
# Will replace `nix` once the old build system is gone.
nix-ng = callPackage ../packaging/everything.nix { };
} }

93
packaging/everything.nix Normal file
View file

@ -0,0 +1,93 @@
{
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;
doInstallCheck = 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
];
installCheckInputs = [
nix-functional-tests
];
})

View file

@ -61,8 +61,9 @@ let
"nix-main" "nix-main"
"nix-main-c" "nix-main-c"
"nix-cmd" "nix-cmd"
"nix-ng" "nix-cli"
"nix-functional-tests" "nix-functional-tests"
"nix-ng"
]; ];
in in
{ {
@ -85,7 +86,7 @@ in
self.packages.${system}.nix.override { enableGC = false; } 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 # Toggles some settings for better coverage. Windows needs these
# library combinations, and Debian build Nix with GNU readline too. # library combinations, and Debian build Nix with GNU readline too.

View file

@ -15,7 +15,7 @@
, nix-store , nix-store
, nix-expr , nix-expr
, nix-ng , nix-cli
, rapidcheck , rapidcheck
, gtest , gtest
@ -67,7 +67,7 @@ mkMesonDerivation (finalAttrs: {
]; ];
nativeBuildInputs = finalAttrs.passthru.baseNativeBuildInputs ++ [ nativeBuildInputs = finalAttrs.passthru.baseNativeBuildInputs ++ [
nix-ng nix-cli
]; ];
buildInputs = [ buildInputs = [
@ -105,7 +105,7 @@ mkMesonDerivation (finalAttrs: {
doCheck = true; doCheck = true;
installPhase = '' installPhase = ''
touch $out mkdir $out
''; '';
meta = { meta = {

View file

@ -27,13 +27,13 @@ in
}; };
config = { config = {
passthru.quickBuild = passthru.quickBuild =
let withQuickBuild = extendModules { modules = [{ quickBuild = true; }]; }; let withQuickBuild = extendModules { modules = [{ quickBuild = true; }]; };
in withQuickBuild.config.test; in withQuickBuild.config.test;
defaults = { pkgs, ... }: { defaults = { pkgs, ... }: {
config = lib.mkIf test.config.quickBuild { config = lib.mkIf test.config.quickBuild {
nix.package = pkgs.nix_noTests; nix.package = pkgs.nixComponents.nix-cli;
system.forbiddenDependenciesRegexes = [ system.forbiddenDependenciesRegexes = [
# This would indicate that the quickBuild feature is broken. # This would indicate that the quickBuild feature is broken.
@ -44,4 +44,4 @@ in
}; };
}; };
}; };
} }