Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: compactify checks flattening #371

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 27 additions & 30 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -227,39 +227,36 @@
# See ./infra/makemake/buildbot.nix for how it is set up.
# NOTE: `nix flake check` requires a flat attribute set of derivations, which is an annoying constraint...
checks = let
checksForNixosTests = projectName: tests:
concatMapAttrs
(testName: test: {"projects/${projectName}/nixos/tests/${testName}" = pkgs.nixosTest test;})
tests;

checksForNixosExamples = projectName: examples:
concatMapAttrs
(exampleName: example: {"projects/${projectName}/nixos/examples/${exampleName}" = toplevel (mkNixosSystem example.path);})
examples;

checksForProject = projectName: project:
(checksForNixosTests projectName project.nixos.tests)
// (checksForNixosExamples projectName project.nixos.examples);

checksForPackageDerivation = packageName: package: {"packages/${packageName}" = package;};

checksForPackagePassthruTests = packageName: tests:
concatMapAttrs
(passthruName: test: {"packages/${packageName}/passthru/${passthruName}" = test;})
tests;

checksForPackage = packageName: package:
(checksForPackageDerivation packageName package)
// (checksForPackagePassthruTests packageName (package.passthru.tests or {}));

# everything must evaluate for checks to run
nonBrokenPackages = filterAttrs (_: v: ! v.meta.broken or false) ngipkgs;

checksForAllProjects =
concatMapAttrs checksForProject
(importNgiProjects (pkgs // nonBrokenPackages));

checksForAllPackages = concatMapAttrs checksForPackage nonBrokenPackages;
checksForAllProjects = let
checksForProject = projectName: project: let
checksForNixosTests =
concatMapAttrs
(testName: test: {"projects/${projectName}/nixos/tests/${testName}" = pkgs.nixosTest test;})
project.nixos.tests;

checksForNixosExamples =
concatMapAttrs
(exampleName: example: {"projects/${projectName}/nixos/examples/${exampleName}" = toplevel (mkNixosSystem example.path);})
project.nixos.examples;
in
checksForNixosTests // checksForNixosExamples;
in
concatMapAttrs checksForProject (importNgiProjects (pkgs // nonBrokenPackages));

checksForAllPackages = let
checksForPackage = packageName: package: let
checksForPackageDerivation = {"packages/${packageName}" = package;};
checksForPackagePassthruTests =
concatMapAttrs
(passthruName: test: {"packages/${packageName}/passthru/${passthruName}" = test;})
(package.passthru.tests or {});
in
checksForPackageDerivation // checksForPackagePassthruTests;
in
concatMapAttrs checksForPackage nonBrokenPackages;

checksForInfrastructure = {
"infra/pre-commit" = pre-commit-hooks.lib.${system}.run {
Expand Down