modular-flake/nix/output/checks.nix
2026-10-10 19:03:51 +01:00

39 lines
1 KiB
Nix

{ safeSeq, mkNop, ... }:
{ lib, ... }:
with lib;
{
config.outputKinds = [
(
{ hasSystem, ... }:
optionalAttrs hasSystem {
options = {
checks = mkOption {
type = with types; attrsOf anything;
description = ''
Evaluated by `nix flake check`
NOTE: this is different from the flakes themselves -- this version accepts
anything (not just a derivation):
- for a derivation type, the behavior is unchanged
- for a non-derivation type, expression gets shallow-evaluated instead
'';
};
};
outputs =
{
lib,
hasSystem,
config,
system,
pkgs,
...
}:
lib.optionalAttrs hasSystem {
checks.${system} = builtins.mapAttrs (
_: val: if val.type or "" == "derivation" then val else safeSeq val (mkNop pkgs)
) config.checks;
};
}
)
];
}