From 6dbbac29f90c5a4f0acfeceab45e0da4364e3708 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 14 Aug 2025 03:20:52 +0200 Subject: [PATCH] Check release version compat To move into a better position to align this project with nixpkgs unstable breaking changes we now default to require a matching nixpkgs release. --- default.nix | 15 +++++++++++++++ mail-server/assertions.nix | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/default.nix b/default.nix index d3de212..97485a4 100644 --- a/default.nix +++ b/default.nix @@ -41,6 +41,21 @@ in options.mailserver = { enable = mkEnableOption "nixos-mailserver"; + enableNixpkgsReleaseCheck = mkOption { + type = types.bool; + default = true; + description = '' + Whether to check for a release mismatch between NixOS mailserver and + Nixpkgs. + + Using mismatched versions is likely to cause compatibility issues + and may require migrations that make an eventual rollback tricky. + + It is therefore highly recommended to use a release of NixOS mailserver + that corresponds with your chosen release of Nixpkgs. + ''; + }; + stateVersion = mkOption { type = types.nullOr types.ints.positive; default = null; diff --git a/mail-server/assertions.nix b/mail-server/assertions.nix index c606bda..374c17b 100644 --- a/mail-server/assertions.nix +++ b/mail-server/assertions.nix @@ -3,7 +3,34 @@ lib, ... }: + +let + mailserverRelease = "25.11"; + nixpkgsRelease = lib.trivial.release; + releaseMismatch = + config.mailserver.enableNixpkgsReleaseCheck && mailserverRelease != nixpkgsRelease; +in + { + warnings = lib.optional releaseMismatch '' + You are using + + NixOS Mailserver version ${mailserverRelease} and + Nixpkgs version ${nixpkgsRelease}. + + Using mismatched versions is likely to cause compatibility issues + and may require migrations that make an eventual rollback tricky. + + It is therefore highly recommended to use a release of + NixOS mailserver that corresponds with your chosen release of Nixpkgs. + + If you insist then you can disable this warning by adding + + mailserver.enableNixpkgsReleaseCheck = false; + + to your configuration. + ''; + # We guard all assertions by requiring mailserver to be actually enabled assertions = lib.optionals config.mailserver.enable ( [