Files
home-manager/tests/modules/home-environment/nixpkgs-release-check-pkgs.nix
Matt Sturgeon ab8e4b2b5a home-environment: extend release check to include pkgs
`lib` comes from the Nixpkgs used to instantiate Home Manager itself and
cannot change within the module fixpoint. However, `pkgs` is configurable
(via `nixpkgs.*` or `_module.args`) and may come from a different Nixpkgs
instance from the one providing `lib`.

Mismatches between Home Manager's release and the release of the `pkgs`
instance are more common and also more likely to cause subtle issues.

This change extends the release check to include `pkgs.lib.trivial.release`
so that such mismatches can be detected and reported.
2025-12-02 21:35:34 -06:00

40 lines
974 B
Nix

{ lib, ... }:
let
releaseInfo = lib.importJSON ../../../release.json;
hmRelease = releaseInfo.release;
pkgsRelease = "<invalid>";
in
{
test.asserts.warnings.expected = [
''
You are using
Home Manager version: ${hmRelease}
Nixpkgs version used to evaluate Home Manager: ${hmRelease}
Nixpkgs version used for packages (`pkgs`): ${pkgsRelease}
Using mismatched versions is likely to cause errors and unexpected
behavior. It is therefore highly recommended to use a release of Home
Manager that corresponds with your chosen release of Nixpkgs.
If you insist then you can disable this warning by adding
home.enableNixpkgsReleaseCheck = false;
to your configuration.
''
];
nixpkgs.overlays = [
(final: prev: {
lib = prev.lib.extend (
final: prev: {
trivial = prev.trivial // {
release = pkgsRelease;
};
}
);
})
];
}