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 b8b679c
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 36 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,6 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main
- 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:
needs: vm_tests
runs-on: ubuntu-22.04
Expand Down
48 changes: 36 additions & 12 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,20 +217,49 @@
# 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;
}
# We need to flatten recursive attribute sets of derivations to pass `flake check`.
// flatMapAttrs
{ # Components we'll iterate over in the upcoming lambda
"nix" = { };
# Temporarily disabled because GitHub Actions OOM issues. Once
# the old build system is gone and we are back to one build
# system, we should reenable these.
#"nix-util" = { };
#"nix-store" = { };
#"nix-fetchers" = { };
"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" = { };
"nix-ng" = { };
}
(pkgName: {}: {
# These attributes go right into `packages.<system>`.
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 b8b679c

Please sign in to comment.