Flake-Parts with `config.assertions = `

I was wondering what is needed for making assertions = [ {...} ] work in flake-parts the same way we have in NixOS and homemanager? Or is there any small workaround for this?

@roberth: Do you might have more information on that? Would be pretty helpful =).

First you need to import ${nixpkgs} /nixos/modules/misc/assertions.nix. Then you somehow need to check that no assertions failed, because the module itself doesn’t do it. There’s a few ways I can think of doing that, but you’d probably want to overwrite the final flake output, such that in case of a failed assertion it throws, otherwise it returns successfully. Then you guarantee that path will be evaluated.

The problem is it needs to be more targeted so that it doesn’t slow down targeted evaluations of specific attributes to the time it takes to check them all.
Some more discussion is in Include `assertions` and `warnings` in flake-parts? · Issue #230 · hercules-ci/flake-parts · GitHub

Coming to think of it, the triggering logic could use or extend the touchup module.
It’s important to limit the interleaving of check triggering and productive evaluation, to avoid infinite recursion. touchup is both an outer shell that can serve this role and a structure where the assertions and/or triggers could live.

2 Likes