1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00

refact: concatMapAttrs -> flatMapAttrs

This should be slightly easier to read.
We could apply this to all concatMapAttrs calls.
This commit is contained in:
Robert Hensing 2024-06-25 15:49:39 +02:00
parent ac89828b5a
commit 6a28566db6

View file

@ -58,6 +58,18 @@
"stdenv"
];
/**
`flatMapAttrs attrs f` applies `f` to each attribute in `attrs` and
merges the results into a single attribute set.
This can be nested to form a build matrix where all the attributes
generated by the innermost `f` are returned as is.
(Provided that the names are unique.)
See https://nixos.org/manual/nixpkgs/stable/index.html#function-library-lib.attrsets.concatMapAttrs
*/
flatMapAttrs = attrs: f: lib.concatMapAttrs f attrs;
forAllSystems = lib.genAttrs systems;
forAllCrossSystems = lib.genAttrs crossSystems;
@ -319,17 +331,20 @@
# system, we should reenable this.
#perlBindings = self.hydraJobs.perlBindings.${system};
}
// lib.concatMapAttrs (nixpkgsPrefix: nixpkgs:
lib.concatMapAttrs (pkgName: pkg:
lib.concatMapAttrs (testName: test: {
# Add "passthru" tests
"${nixpkgsPrefix}${pkgName}-${testName}" = test;
}) pkg.tests or {}
) nixpkgs.nix-components
) {
# Add "passthru" tests
// flatMapAttrs {
"" = nixpkgsFor.${system}.native;
"static-" = nixpkgsFor.${system}.static;
}
(nixpkgsPrefix: nixpkgs:
flatMapAttrs nixpkgs.nix-components
(pkgName: pkg:
flatMapAttrs pkg.tests or {}
(testName: test: {
"${nixpkgsPrefix}${pkgName}-${testName}" = test;
})
)
)
// devFlake.checks.${system} or {}
);