assertions: fix eval error when mailserver.stateVersion is unset (null)

Eval does not stop on the first assertion failure it encouters.
Instead, it tries to evaluate all assertions and returns with a list of
those that failed.

This means our very top `config.mailserver.stateVersion != null`
assertion does not gate against any other assertions trying to compare
null against an integer.

The error prior to this commit can be reproduced by removing
`mailserver.stateVersion = 999;` in tests/lib/config.nix and then trying
to evaluate any of the tests:

~~~bash
# nix eval --raw .#checks.x86_64-linux.internal-unstable
error:
       … while evaluating the attribute 'outPath'
         at /nix/store/syvnmj3hhckkbncm94kfkbl76qsdqqj3-source/lib/customisation.nix:421:7:
          420|         drv.drvPath;
          421|       outPath =
             |       ^
          422|         assert condition;

       … while calling the 'getAttr' builtin
         at «internal»:1:500:
       (stack trace truncated; use '--show-trace' to show the full trace)

       error: cannot compare null with an integer
~~~
This commit is contained in:
emilylange 2025-06-21 20:15:46 +02:00
parent 9d8caf5944
commit 6ef1eb9ce1
No known key found for this signature in database
GPG key ID: 0AD773CE46FD0F87
2 changed files with 3 additions and 3 deletions

View file

@ -85,7 +85,7 @@ section on the migration page in the documentation.
{
assertions = [
{
assertion = config.mailserver.stateVersion >= 1;
assertion = config.mailserver.stateVersion != null -> config.mailserver.stateVersion >= 1;
message = ''
Problem: The home directory for the foobar service is snafu.
Remediation: