|
3 | 3 | config, |
4 | 4 | options, |
5 | 5 | lib, |
| 6 | + helpers, |
| 7 | + extendModules, |
6 | 8 | ... |
7 | 9 | }: |
8 | 10 | let |
|
263 | 265 |
|
264 | 266 | config = |
265 | 267 | let |
| 268 | + # Reevaluate the nixvim configuration in "test mode" |
| 269 | + # This allows users to use `lib.nixvim.enableExceptInTests` |
| 270 | + testConfiguration = |
| 271 | + let |
| 272 | + # TODO: replace and deprecate enableExceptInTests |
| 273 | + # We shouldn't need to use another instance of `lib` when building a test drv |
| 274 | + # Maybe add a context option e.g. `config.isTest`? |
| 275 | + nixvimLibOverlay = final: prev: { |
| 276 | + utils = prev.utils // { |
| 277 | + enableExceptInTests = false; |
| 278 | + }; |
| 279 | + }; |
| 280 | + extendedConfiguration = extendModules { |
| 281 | + specialArgs = { |
| 282 | + lib = lib.extend ( |
| 283 | + final: prev: { |
| 284 | + nixvim = prev.nixvim.extend nixvimLibOverlay; |
| 285 | + } |
| 286 | + ); |
| 287 | + helpers = helpers.extend nixvimLibOverlay; |
| 288 | + }; |
| 289 | + }; |
| 290 | + in |
| 291 | + if lib.nixvim.enableExceptInTests then extendedConfiguration else { inherit config options; }; |
| 292 | + |
266 | 293 | input = { |
267 | | - inherit (config) warnings; |
268 | | - assertions = builtins.concatMap (x: lib.optional (!x.assertion) x.message) config.assertions; |
| 294 | + inherit (testConfiguration.config) warnings; |
| 295 | + assertions = builtins.concatMap ( |
| 296 | + x: lib.optional (!x.assertion) x.message |
| 297 | + ) testConfiguration.config.assertions; |
269 | 298 | }; |
270 | 299 |
|
271 | 300 | expectationMessages = |
|
323 | 352 | nativeBuildInputs = |
324 | 353 | cfg.extraInputs |
325 | 354 | ++ lib.optionals cfg.buildNixvim [ |
326 | | - config.build.nvimPackage |
| 355 | + testConfiguration.config.build.nvimPackage |
327 | 356 | ]; |
328 | 357 |
|
329 | 358 | inherit (failedExpectations) warnings assertions; |
|
335 | 364 | # |
336 | 365 | # Yes, three levels of `entries` is cursed. |
337 | 366 | passthru = { |
338 | | - inherit config options; |
| 367 | + inherit (testConfiguration) config options; |
| 368 | + configuration = testConfiguration; |
339 | 369 | }; |
340 | 370 | } |
341 | 371 | ( |
|
0 commit comments