mirror of
https://github.com/nix-community/nixvim.git
synced 2025-12-05 16:41:06 +01:00
modules/version: init with nixpkgsReleaseCheck
Inspired by `home.version` and `home.enableNixpkgsReleaseCheck` in Home Manager. Print a warning when `lib` or `pkgs` are from a different release to Nixvim.
This commit is contained in:
parent
cbdfee5239
commit
b0f3a36596
4 changed files with 120 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ let
|
|||
runNvim = false;
|
||||
runCommand = runCommandLocal;
|
||||
};
|
||||
version.enableNixpkgsReleaseCheck = false;
|
||||
}
|
||||
../modules/misc
|
||||
../modules/top-level/test.nix
|
||||
|
|
|
|||
44
tests/test-sources/modules/version.nix
Normal file
44
tests/test-sources/modules/version.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{ pkgs }:
|
||||
{
|
||||
invalid-pkgs =
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
versionInfo = lib.importTOML ../../../version-info.toml;
|
||||
nixvimRelease = versionInfo.release;
|
||||
pkgsRelease = "<invalid>";
|
||||
in
|
||||
{
|
||||
# The test-suite uses `pkgs = mkForce`, so override it.
|
||||
# Overlay `pkgs` with an invalid `release`:
|
||||
_module.args.pkgs = lib.mkOverride 0 (
|
||||
pkgs.extend (
|
||||
final: prev: {
|
||||
lib = prev.lib.extend (
|
||||
final: prev: {
|
||||
trivial = prev.trivial // {
|
||||
release = pkgsRelease;
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
test.warnings = expect: [
|
||||
(expect "count" 1)
|
||||
(expect "any" "You are using:")
|
||||
(expect "any" "- Nixvim version: ${nixvimRelease}")
|
||||
(expect "any" "- Nixpkgs version used to evaluate Nixvim: ${nixvimRelease}")
|
||||
(expect "any" "- Nixpkgs version used for packages (`pkgs`): ${pkgsRelease}")
|
||||
(expect "any" "If you insist, you can disable this warning using:")
|
||||
(expect "any" " version.enableNixpkgsReleaseCheck = false;")
|
||||
];
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.version.release == nixvimRelease;
|
||||
message = "Expected `config.version.release` to be ${nixvimRelease}, found ${config.version.release}";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue